Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "This package.json file is only used for installing npm dependencies. But this is not an installable node package, but a WireCloud operator. Take a look into src/config.xml for more details about this operator",
"devDependencies": {
"grunt": "^1.0.4",
"grunt": "^1.1.0",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-compress": "^1.6.0",
"grunt-contrib-copy": "^1.0.0",
Expand All @@ -15,8 +15,8 @@
"karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^2.0.1",
"karma-firefox-launcher": "^1.2.0",
"karma-jasmine": "^2.0.1",
"karma-firefox-launcher": "^1.3.0",
"karma-jasmine": "^3.1.1",
"karma-junit-reporter": "^2.0.1",
"mock-applicationmashup": "^1.0.0-g",
"wirecloud-config-parser": "^0.2.2"
Expand Down
7 changes: 4 additions & 3 deletions src/config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<operator xmlns="http://wirecloud.conwet.fi.upm.es/ns/macdescription/1" vendor="FISUDA" name="ngsi-entity-filter" version="0.1.0">
<operator xmlns="http://wirecloud.conwet.fi.upm.es/ns/macdescription/1" vendor="FISUDA" name="ngsi-entity-filter" version="0.1.1">

<details>
<title>NGSI Entity filter</title>
Expand All @@ -22,8 +22,9 @@
</requirements>

<preferences>
<preference
name="types" type="text" label="Entity types" description="A comma separated list of Entity types to filter" default="" />
<preference name="types" type="text" label="Entity types" description="A comma separated list of Entity types to filter" default="" />
<preference name="send_nulls" type="boolean" label="Send Nulls" description="Enable this option to propagate null values when array is empty" default="false" />

</preferences>

<wiring>
Expand Down
3 changes: 3 additions & 0 deletions src/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
return types.indexOf(e.type) !== -1;
});

if (MashupPlatform.prefs.get('send_nulls') && new_entites.length == 0) {
new_entites = null;
}
MashupPlatform.wiring.pushEvent("entityOutput", new_entites);
}
}
Expand Down
12 changes: 11 additions & 1 deletion tests/js/NgsiEntityFilterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
window.MashupPlatform = new MockMP({
type: 'operator',
prefs: {
'types': 'test'
'types': 'test',
'send_nulls': false
},
inputs: ['entityInput'],
outputs: ['entityOutput']
Expand Down Expand Up @@ -46,6 +47,15 @@
expect(MashupPlatform.wiring.pushEvent).toHaveBeenCalledWith('entityOutput', []);
});

it("send nulls", function () {
MashupPlatform.prefs.set('types', '');
MashupPlatform.prefs.set('send_nulls', true);

ngsiEntityFilter([{'type': 'test'}, {'type': 'abc'}, {'type': 'xyz'}, {'type': '123'}]);

expect(MashupPlatform.wiring.pushEvent).toHaveBeenCalledWith('entityOutput', null);
});

it("output endoint is not connected", function () {
MashupPlatform.operator.outputs.entityOutput.disconnect();

Expand Down