Skip to content

Commit 96fb347

Browse files
committed
Updated flow example
1 parent 21a5da1 commit 96fb347

File tree

2 files changed

+95
-46
lines changed

2 files changed

+95
-46
lines changed
Lines changed: 95 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
11
[
2-
{
3-
"id": "739f17c6.5cdae8",
4-
"type": "inject",
5-
"z": "51af8c53.929c6c",
6-
"name": "Non-standard (JSON) message",
7-
"topic": "",
8-
"payload": "{\"id\":\"vehicle:WasteManagement:1\",\"type\":\"BasicVehicle\",\"vehicleType\":\"lorry\",\"category1\":\"municipalServices\",\"latitude\":-3.164485591715449,\"longitude\":40.62785133667262,\"name\":\"C Recogida 1\",\"speed\":50,\"cargoWeight\":314,\"serviceStatus\":\"onRoute\",\"serviceProvided1\":\"garbageCollection\",\"serviceProvided2\":\"wasteContainerCleaning\",\"areaServed\":\"Centro\",\"refVehicleModel\":\"vehiclemodel:econic\",\"vehiclePlateIdentifier\":\"3456ABC\"}",
9-
"payloadType": "json",
10-
"repeat": "",
11-
"crontab": "",
12-
"once": false,
13-
"onceDelay": 0.1,
14-
"x": 210,
15-
"y": 820,
16-
"wires": [
17-
[
18-
"707f7dae.377adc"
19-
]
20-
]
21-
},
222
{
233
"id": "707f7dae.377adc",
244
"type": "json-multi-schema-transformer",
255
"z": "51af8c53.929c6c",
266
"name": "",
27-
"transformsUrl": "https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/smart-data-transforms.json",
28-
"x": 590,
29-
"y": 820,
7+
"x": 650,
8+
"y": 840,
309
"wires": [
3110
[
3211
"1a287ba9.00e0d4"
@@ -39,8 +18,8 @@
3918
"z": "51af8c53.929c6c",
4019
"name": "",
4120
"mappingsUrl": "https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/smart-data-models.json",
42-
"x": 580,
43-
"y": 900,
21+
"x": 640,
22+
"y": 920,
4423
"wires": [
4524
[
4625
"80ef3fce.aa4c2"
@@ -52,8 +31,8 @@
5231
"type": "json-multi-schema-validator",
5332
"z": "51af8c53.929c6c",
5433
"name": "",
55-
"x": 580,
56-
"y": 980,
34+
"x": 640,
35+
"y": 1000,
5736
"wires": [
5837
[
5938
"935312e9.392738"
@@ -65,11 +44,11 @@
6544
"type": "function",
6645
"z": "51af8c53.929c6c",
6746
"name": "Result formatter based on \"msg.error\"",
68-
"func": "if (msg.error) {\n msg.payload = '❌ Invalid according to ' + msg.schemaUrl + ' : ' + msg.error;\n} else {\n msg.payload = '✔ Valid️ according to ' + msg.schemaUrl;\n}\nreturn msg;\n",
47+
"func": "if (msg.error || !msg.validUrl ) {\n msg.result = '❌ Invalid according to ' + msg.validUrl + ' : ' + msg.error;\n} else {\n msg.result = '✔ Valid️ according to ' + msg.validUrl;\n}\nreturn msg;\n",
6948
"outputs": 1,
7049
"noerr": 0,
71-
"x": 610,
72-
"y": 1060,
50+
"x": 670,
51+
"y": 1080,
7352
"wires": [
7453
[
7554
"e3a048d.4f836b8"
@@ -85,10 +64,10 @@
8564
"tosidebar": true,
8665
"console": false,
8766
"tostatus": false,
88-
"complete": "payload",
67+
"complete": "result",
8968
"targetType": "msg",
90-
"x": 890,
91-
"y": 1060,
69+
"x": 950,
70+
"y": 1080,
9271
"wires": []
9372
},
9473
{
@@ -97,14 +76,14 @@
9776
"z": "51af8c53.929c6c",
9877
"name": "Standard message with unknown schema",
9978
"topic": "",
100-
"payload": "{\"id\":\"vehicle:WasteManagement:1\",\"type\":\"Vehicle\",\"vehicleType\":\"lorry\",\"category\":[\"municipalServices\"],\"location\":{\"type\":\"Point\",\"coordinates\":[40.62785133667262,-3.164485591715449]},\"name\":\"C Recogida 1\",\"speed\":50,\"cargoWeight\":314,\"serviceStatus\":\"onRoute\",\"serviceProvided\":[\"garbageCollection\",\"wasteContainerCleaning\"],\"areaServed\":\"Centro\",\"refVehicleModel\":\"vehiclemodel:econic\",\"vehiclePlateIdentifier\":\"3456ABC\"}",
79+
"payload": "{\"id\":\"wastecontainer:Fleming:12a\",\"type\":\"WasteContainer\",\"status\":\"ok\",\"category\":[\"underground\"],\"dateLastEmptying\":\"2016-06-21T15:05:59.408Z\",\"serialNumber\":\"ab56kjl\",\"nextActuationDeadline\":\"2016-06-28T15:05:59.408Z\",\"refWasteContainerIsle\":\"wastecontainerisle:Fleming:12\",\"refDevice\":[\"device-Fleming:12a:1\"],\"location\":{\"type\":\"Point\",\"coordinates\":[-3.164485591715,40.62785133667]},\"fillingLevel\":0.4,\"refWasteContainerModel\":\"wastecontainermodel:c1\"}",
10180
"payloadType": "json",
10281
"repeat": "",
10382
"crontab": "",
10483
"once": false,
10584
"onceDelay": 0.1,
106-
"x": 240,
107-
"y": 900,
85+
"x": 200,
86+
"y": 920,
10887
"wires": [
10988
[
11089
"1a287ba9.00e0d4"
@@ -123,8 +102,8 @@
123102
"crontab": "",
124103
"once": false,
125104
"onceDelay": 0.1,
126-
"x": 130,
127-
"y": 1060,
105+
"x": 90,
106+
"y": 1000,
128107
"wires": [
129108
[
130109
"c16edc29.b8e628"
@@ -136,11 +115,11 @@
136115
"type": "function",
137116
"z": "51af8c53.929c6c",
138117
"name": "Standard message with known schema",
139-
"func": "msg.payload = {\n \"id\": \"vehicle:WasteManagement:1\",\n \"type\": \"Vehicle\",\n \"vehicleType\": \"lorry\",\n \"category\": [\n \"municipalServices\"\n ],\n \"location\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 40.62785133667262,\n -3.164485591715449\n ]\n },\n \"name\": \"C Recogida 1\",\n \"speed\": 50,\n \"cargoWeight\": 314,\n \"serviceStatus\": \"onRoute\",\n \"serviceProvided\": [\n \"garbageCollection\",\n \"wasteContainerCleaning\"\n ],\n \"areaServed\": \"Centro\",\n \"refVehicleModel\": \"vehiclemodel:econic\",\n \"vehiclePlateIdentifier\": \"3456ABC\"\n };\nmsg.schemaUrl = \"https://smart-data-models.github.io/data-models/specs/Transportation/Vehicle/Vehicle/schema.json\";\nreturn msg;\n",
118+
"func": "msg.payload = {\n \"id\": \"urn:ngsi-ld:Alert:Alert:1\",\n \"type\": \"Alert\",\n \"createdAt\": \"2019-06-06T12:06:06\",\n \"modifiedAt\": \"2019-06-07T12:07:06\",\n \"category\": {\n \"type\": \"Property\",\n \"value\": \"traffic\"\n },\n \"subCategory\": {\n \"type\": \"Property\",\n \"value\": \"trafficJam\"\n },\n \"validTo\": {\n \"type\": \"Property\",\n \"value\": {\n \"@type\": \"DateTime\",\n \"@value\": \"2017-01-02T10:25:55.00Z\"\n }\n },\n \"description\": {\n \"type\": \"Property\",\n \"value\": \"The road is completely blocked for 3kms\"\n },\n \"location\": {\n \"type\": \"GeoProperty\",\n \"value\": {\n \"type\": \"Point\",\n \"coordinates\": [-3.712247222222222, 40.423852777777775]\n }\n },\n \"dateIssued\": {\n \"type\": \"Property\",\n \"value\": {\n \"@type\": \"DateTime\",\n \"@value\": \"2017-01-02T09:25:55.00Z\"\n }\n },\n \"alertSource\": {\n \"type\": \"Property\",\n \"value\": \"https://account.lab.fiware.org/users/8\"\n },\n \"validFrom\": {\n \"type\": \"Property\",\n \"value\": {\n \"@type\": \"DateTime\",\n \"@value\": \"2017-01-02T09:25:55.00Z\"\n }\n },\n \"severity\": {\n \"type\": \"Property\",\n \"value\": \"high\"\n },\n \"@context\": [\n \"https://schema.lab.fiware.org/ld/context\",\n \"https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld\"\n ]\n};\nmsg.schemaUrl = \"https://smart-data-models.github.io/data-models/specs/Alert/alert-schema.json\";\nreturn msg;\n",
140119
"outputs": 1,
141120
"noerr": 0,
142-
"x": 240,
143-
"y": 980,
121+
"x": 320,
122+
"y": 1000,
144123
"wires": [
145124
[
146125
"80ef3fce.aa4c2"
@@ -153,18 +132,88 @@
153132
"z": "51af8c53.929c6c",
154133
"name": "using \"Mappings URL\" property",
155134
"info": "",
156-
"x": 890,
135+
"x": 950,
157136
"y": 900,
158137
"wires": []
159138
},
160139
{
161-
"id": "7f14c104.4f98e8",
140+
"id": "51317bda.0a468c",
141+
"type": "inject",
142+
"z": "51af8c53.929c6c",
143+
"name": "Non-standard message with unknown transformation",
144+
"topic": "",
145+
"payload": "{\"id\":\"TA120-T246177\",\"type\":\"Cesva-TA120\",\"NoiseLevelObserved\":{\"id\":\"TA120-T246177-NoiseLevelObserved-2018-09-17T07:01:09.000000Z\",\"sonometerClass\":\"1\",\"location\":{\"coordinates\":[24.985891,60.274286],\"type\":\"Point\"},\"measurand\":[\"LAeq | 48.6 | A-weighted, equivalent, sound level\"],\"dateObserved\":\"2018-09-17T07:01:09.000000Z\",\"LAeq\":48.6,\"type\":\"NoiseLevelObserved\"}}",
146+
"payloadType": "json",
147+
"repeat": "",
148+
"crontab": "",
149+
"once": false,
150+
"onceDelay": 0.1,
151+
"x": 230,
152+
"y": 760,
153+
"wires": [
154+
[
155+
"cd146fe0.82e9f"
156+
]
157+
]
158+
},
159+
{
160+
"id": "cd146fe0.82e9f",
161+
"type": "json-multi-schema-resolver",
162+
"z": "51af8c53.929c6c",
163+
"name": "",
164+
"mappingsUrl": "https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/smart-data-transforms.json",
165+
"x": 640,
166+
"y": 760,
167+
"wires": [
168+
[
169+
"707f7dae.377adc"
170+
]
171+
]
172+
},
173+
{
174+
"id": "80f398e9.42f2c",
162175
"type": "comment",
163176
"z": "51af8c53.929c6c",
164-
"name": "using \"Transforms URL\" property",
177+
"name": "using \"Mappings URL\" property",
165178
"info": "",
166-
"x": 890,
167-
"y": 820,
179+
"x": 950,
180+
"y": 760,
168181
"wires": []
182+
},
183+
{
184+
"id": "c9e40c.0b8663f8",
185+
"type": "inject",
186+
"z": "51af8c53.929c6c",
187+
"name": "Trigger",
188+
"topic": "",
189+
"payload": "",
190+
"payloadType": "date",
191+
"repeat": "",
192+
"crontab": "",
193+
"once": false,
194+
"onceDelay": 0.1,
195+
"x": 90,
196+
"y": 840,
197+
"wires": [
198+
[
199+
"67995555.798d54"
200+
]
201+
]
202+
},
203+
{
204+
"id": "67995555.798d54",
205+
"type": "function",
206+
"z": "51af8c53.929c6c",
207+
"name": "Standard message with known schema",
208+
"func": "msg.payload = {\n \"id\": \"TA120-T246177\",\n \"type\": \"Cesva-TA120\",\n \"NoiseLevelObserved\": {\n \"id\": \"TA120-T246177-NoiseLevelObserved-2018-09-17T07:01:09.000000Z\",\n \"sonometerClass\": \"1\",\n \"location\": {\n \"coordinates\": [\n 24.985891,\n 60.274286\n ],\n \"type\": \"Point\"\n },\n \"measurand\": [\n \"LAeq | 48.6 | A-weighted, equivalent, sound level\"\n ],\n \"dateObserved\": \"2018-09-17T07:01:09.000000Z\",\n \"LAeq\": 48.6,\n \"type\": \"NoiseLevelObserved\"\n }\n};\nmsg.schemaUrl = \"https://raw.githubusercontent.com/alexandrainst/node-red-contrib-json-multi-schema/master/examples/Cesva-TA120-to-NoiseLevelObserved.jsonata.js\";\nreturn msg;\n",
209+
"outputs": 1,
210+
"noerr": 0,
211+
"x": 320,
212+
"y": 840,
213+
"wires": [
214+
[
215+
"707f7dae.377adc"
216+
]
217+
]
169218
}
170219
]
4.34 KB
Loading

0 commit comments

Comments
 (0)