-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimport-data
More file actions
executable file
·260 lines (234 loc) · 10.6 KB
/
Copy pathimport-data
File metadata and controls
executable file
·260 lines (234 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!/bin/bash
#
# curl commands to reload the data from the previous tutorial
#
#
set -e
echo -e "⏳ Loading context data in \033[1mNGSI-LD\033[0m format"
echo -e " - all entity data models are defined referencing the"
echo -e " \033[1m"${TUTORIAL_DATA_MODELS_CONTEXT}"\033[0m JSON-LD context"
echo -e "\nCreating buildings for the farm ..."
curl -F "file=@./data/building.csv" http://tutorial:3000/csv/Building
curl -s -H "NGSILD-Tenant: farmer" -iX POST 'http://'"${CONTEXT_BROKER}"'/ngsi-ld/v1/entityOperations/upsert' \
-H 'Content-Type: application/json' \
-H 'Link: <'"${TUTORIAL_DATA_MODELS_CONTEXT}"'>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Accept: application/ld+json' \
--data-raw '[
{
"id": "urn:ngsi-ld:Animal:cow001",
"type": "Animal"
}
]'
sleep 3
curl -s -o /dev/null -H "NGSILD-Tenant: openiot" -iX POST 'http://'"${CONTEXT_BROKER}"'/ngsi-ld/v1/entityOperations/upsert' \
-H 'Content-Type: application/json' \
-H 'Link: <'"${TUTORIAL_DATA_MODELS_CONTEXT}"'>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Accept: application/ld+json' \
--data-raw '[
{
"id": "urn:ngsi-ld:Device:cow001",
"type": "Device"
}
]'
sleep 3
echo -e "\nCreating animals for the farm ..."
curl -s -o /dev/null -H "NGSILD-Tenant: openiot" -H "offset-duration: MONTH" -F "file=@./data/cow-history.csv" http://tutorial:3000/csv/Animal
curl -s -o /dev/null -H "NGSILD-Tenant: openiot" -H "offset-duration: WEEK" -F "file=@./data/cow-history-young.csv" http://tutorial:3000/csv/Animal
curl -s -o /dev/null -H "NGSILD-Tenant: openiot" -F "file=@./data/cow.csv" http://tutorial:3000/csv/Animal
curl -s -o /dev/null -H "NGSILD-Tenant: openiot" -F "file=@./data/pig.csv" http://tutorial:3000/csv/Animal
echo -e "Creating devices for the animals ..."
curl -s -o /dev/null -H "NGSILD-Tenant: openiot" -F "file=@./data/device.csv" http://tutorial:3000/csv/Device
echo -e "Creating agri-data for the farmer ..."
curl -s -o /dev/null -H "NGSILD-Tenant: farmer" -F "file=@./data/agri-parcel.csv" http://tutorial:3000/csv/AgriParcel
curl -s -o /dev/null -H "NGSILD-Tenant: farmer" -F "file=@./data/agri-crop.csv" http://tutorial:3000/csv/AgriCrop
curl -s -o /dev/null -H "NGSILD-Tenant: farmer" -F "file=@./data/agri-farm.csv" http://tutorial:3000/csv/AgriFarm
curl -s -o /dev/null -H "NGSILD-Tenant: farmer" -F "file=@./data/agri-pest.csv" http://tutorial:3000/csv/AgriPest
curl -s -o /dev/null -H "NGSILD-Tenant: farmer" -F "file=@./data/agri-soil.csv" http://tutorial:3000/csv/AgriSoil
echo -e "Creating personnel for the farm ..."
curl -s -o /dev/null -H "NGSILD-Tenant: farmer" -F "file=@./data/person.csv" http://tutorial:3000/csv/Person
echo -e "Creating weather observations readings ..."
curl -s -o /dev/null -F "file=@./data/weather.csv" http://tutorial:3000/csv/Weather
echo -e "\nRegistering Farmer as data source ...\n"
curl -s -iX POST 'http://'"${CONTEXT_BROKER}"'/ngsi-ld/v1/csourceRegistrations/' \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Content-Type: application/json' \
-d '{
"type": "ContextSourceRegistration",
"information": [
{
"entities": [
{"type": "Animal"},
{"type": "AgriParcel"},
{"type": "AgriCrop"},
{"type": "AgriFarm"},
{"type": "AgriPest"},
{"type": "AgriSoil"},
{"type": "Person"},
{"type": "Device"}
]
}
],
"mode": "redirect",
"operations": ["redirectionOps"],
"endpoint": "http://farmer"
}'
echo -e "\nRegistering Devices as data source ...\n"
curl -s -iX POST 'http://'"${CONTEXT_BROKER}"'/ngsi-ld/v1/csourceRegistrations/' \
-H "NGSILD-Tenant: farmer" \
-H 'Link: <http://context/user-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'Content-Type: application/json' \
-d '{
"type": "ContextSourceRegistration",
"information": [
{
"entities": [
{"type": "Animal"},
{"type": "Device"}
]
}
],
"mode": "inclusive",
"operations": ["federationOps"],
"endpoint": "http://devices"
}'
echo -e "\nInitialising devices readings ... \n"
curl -s -o /dev/null -iX PUT --location ''"${IOT_DEVICES}"'/devices' \
-H 'Content-Type: application/json' \
-d '{
"cow001": "o|1|hide|o,x|d|AT_REST|bpm|51|gps|13.3497,52.5113|s|0",
"cow002": "o|1|hide|o,x|d|AT_REST|bpm|54|gps|13.3480,52.5118|s|0",
"cow003": "o|1|hide|o,x|d|AT_REST|bpm|51|gps|13.3550,52.5152|s|0",
"cow004": "o|1|hide|o,x|d|GRAZING|bpm|54|gps|13.3545,52.5136|s|0",
"cow006": "o|1|hide|o,x|d|AT_REST|bpm|52|gps|13.3698,52.5163|s|0",
"cow010": "o|1|hide|o,x|d|AT_REST|bpm|55|gps|13.3485,52.5112|s|0",
"cow009": "o|1|hide|o,x|d|AT_REST|bpm|54|gps|13.3489,52.5171|s|0",
"cow008": "o|1|hide|o,x|d|GRAZING|bpm|50|gps|13.3482,52.5184|s|0",
"cow007": "o|1|hide|o,x|d|AT_REST|bpm|55|gps|13.3559,52.5156|s|0",
"cow005": "o|1|hide|o,x|d|AT_REST|bpm|70|gps|13.3556,52.5151|s|0",
"cow011": "o|1|hide|o,x|d|GRAZING|bpm|55|gps|13.3489,52.5175|s|0",
"cow012": "o|1|hide|o,x|d|GRAZING|bpm|55|gps|13.3527,52.5136|s|0",
"cow019": "o|1|hide|o,x|d|GRAZING|bpm|55|gps|13.3542,52.5136|s|0",
"cow018": "o|1|hide|o,x|d|GRAZING|bpm|52|gps|13.3529,52.5135|s|0",
"cow017": "o|1|hide|o,x|d|AT_REST|bpm|54|gps|13.3553,52.5158|s|0",
"cow016": "o|1|hide|o,x|d|AT_REST|bpm|52|gps|13.3544,52.5158|s|0",
"cow015": "o|1|hide|o,x|d|GRAZING|bpm|55|gps|13.3482,52.5171|s|0",
"cow014": "o|1|hide|o,x|d|GRAZING|bpm|54|gps|13.3524,52.5133|s|0",
"cow013": "o|1|hide|o,x|d|GRAZING|bpm|51|gps|13.3498,52.5113|s|0",
"cow021": "o|1|hide|o,x|d|AT_REST|bpm|51|gps|13.3495,52.5117|s|0",
"cow020": "o|1|hide|o,x|d|AT_REST|bpm|55|gps|13.3489,52.5184|s|0",
"cow023": "o|1|hide|o,x|d|GRAZING|bpm|53|gps|13.3534,52.5132|s|0",
"cow022": "o|1|hide|o,x|d|AT_REST|bpm|50|gps|13.3483,52.5169|s|0",
"cow024": "o|1|hide|o,x|d|AT_REST|bpm|54|gps|13.3541,52.5158|s|0",
"cow025": "o|1|hide|o,x|d|DRINKING|bpm|50|gps|13.3550,52.5150|s|0",
"cow026": "o|1|hide|o,x|d|AT_REST|bpm|54|gps|13.3545,52.5159|s|0",
"cow027": "o|1|hide|o,x|d|AT_REST|bpm|52|gps|13.3558,52.5152|s|0",
"cow029": "o|1|hide|o,x|d|AT_REST|bpm|51|gps|13.3495,52.5111|s|0",
"cow028": "o|1|hide|o,x|d|DRINKING|bpm|54|gps|13.348,52.5111|s|0",
"cow033": "o|1|hide|o,x|d|AT_REST|bpm|54|gps|13.3489,52.5179|s|0",
"cow031": "o|1|hide|o,x|d|GRAZING|bpm|53|gps|13.355,52.5159|s|0",
"cow030": "o|1|hide|o,x|d|GRAZING|bpm|52|gps|13.3543,52.5154|s|0",
"cow037": "o|1|hide|o,x|d|GRAZING|bpm|54|gps|13.3494,52.5118|s|0",
"cow036": "o|1|hide|o,x|d|GRAZING|bpm|50|gps|13.3487,52.5185|s|0",
"cow035": "o|1|hide|o,x|d|GRAZING|bpm|52|gps|13.3539,52.5139|s|0",
"cow034": "o|1|hide|o,x|d|AT_REST|bpm|55|gps|13.3543,52.5151|s|0",
"cow032": "o|1|hide|o,x|d|AT_REST|bpm|51|gps|13.3489,52.5114|s|0",
"cow038": "o|1|hide|o,x|d|GRAZING|bpm|50|gps|13.3547,52.5156|s|0",
"cow039": "o|1|hide|o,x|d|AT_REST|bpm|51|gps|13.3533,52.5138|s|0",
"cow040": "o|1|hide|o,x|d|AT_REST|bpm|55|gps|13.3483,52.5168|s|0",
"pig001": "d|AT_REST|bpm|64|gps|13.3507,52.5183|s|0",
"pig002": "d|AT_REST|bpm|61|gps|13.3500,52.5188|s|0",
"pig003": "d|FORAGING|bpm|62|gps|13.350,52.518|s|0",
"pig004": "d|FORAGING|bpm|63|gps|13.3505,52.5186|s|0",
"pig007": "d|FORAGING|bpm|64|gps|13.3509,52.5186|s|0",
"pig008": "d|AT_REST|bpm|60|gps|13.3502,52.5184|s|0",
"pig009": "d|AT_REST|bpm|65|gps|13.3509,52.5181|s|0",
"pig006": "d|FORAGING|bpm|61|gps|13.3504,52.5184|s|0",
"pig005": "d|WALLOWING|bpm|62|gps|13.3506,52.5181|s|0",
"pig012": "d|FORAGING|bpm|63|gps|13.3507,52.5186|s|0",
"pig010": "d|FORAGING|bpm|65|gps|13.3505,52.5182|s|0",
"pig011": "d|FORAGING|bpm|63|gps|13.3509,52.5185|s|0",
"pig013": "d|FORAGING|bpm|60|gps|13.3508,52.5183|s|0",
"pig018": "d|FORAGING|bpm|60|gps|13.3509,52.5180|s|0",
"pig019": "d|AT_REST|bpm|62|gps|13.3500,52.5186|s|0",
"pig016": "d|AT_REST|bpm|63|gps|13.3504,52.5188|s|0",
"pig017": "d|FORAGING|bpm|64|gps|13.3503,52.5188|s|0",
"pig014": "d|FORAGING|bpm|64|gps|13.3504,52.5183|s|0",
"pig015": "d|FORAGING|bpm|62|gps|13.3502,52.5181|s|0",
"pig021": "d|FORAGING|bpm|60|gps|13.3505,52.5187|s|0",
"pig020": "d|AT_REST|bpm|61|gps|13.3509,52.5184|s|0",
"pig023": "d|WALLOWING|bpm|62|gps|13.3504,52.5182|s|0",
"pig022": "d|AT_REST|bpm|61|gps|13.3503,52.5189|s|0",
"pig024": "d|AT_REST|bpm|60|gps|13.3501,52.5188|s|0",
"pig028": "d|DRINKING|bpm|61|gps|13.3501,52.5181|s|0",
"pig029": "d|AT_REST|bpm|60|gps|13.3505,52.5181|s|0",
"pig027": "d|AT_REST|bpm|64|gps|13.3508,52.5182|s|0",
"pig025": "d|AT_REST|bpm|61|gps|13.3507,52.5180|s|0",
"pig026": "d|DRINKING|bpm|63|gps|13.3505,52.5189|s|0",
"pig030": "d|AT_REST|bpm|64|gps|13.3503,52.5184|s|0",
"pig033": "d|FORAGING|bpm|65|gps|13.3509,52.5189|s|0",
"pig032": "d|FORAGING|bpm|60|gps|13.3509,52.5184|s|0",
"pig038": "d|FORAGING|bpm|60|gps|13.3507,52.5186|s|0",
"pig037": "d|FORAGING|bpm|61|gps|13.3504,52.518|s|0",
"pig036": "d|FORAGING|bpm|64|gps|13.3507,52.5185|s|0",
"pig031": "d|FORAGING|bpm|63|gps|13.3500,52.5189|s|0",
"pig035": "d|AT_REST|bpm|62|gps|13.3509,52.5189|s|0",
"pig034": "d|WALLOWING|bpm|62|gps|13.3503,52.5181|s|0",
"pig039": "d|AT_REST|bpm|64|gps|13.3503,52.5188|s|0",
"pig040": "d|AT_REST|bpm|64|gps|13.3503,52.5188|s|0"
}'
curl -s -o /dev/null -X POST 'http://'"${CONTEXT_BROKER}"'/ngsi-ld/v1/entityOperations/upsert' \
-H 'Content-Type: application/json' \
-H 'Link: <'"${TUTORIAL_DATA_MODELS_CONTEXT}"'>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"' \
-H 'NGSILD-Tenant: openiot' \
-H 'Accept: application/ld+json' \
--data-raw '[
{
"id": "urn:ngsi-ld:Device:tractor001",
"type": "Tractor"
},
{
"id": "urn:ngsi-ld:Device:tractor002",
"type": "Tractor"
},
{
"id": "urn:ngsi-ld:Device:tractor003",
"type": "Tractor"
},
{
"id": "urn:ngsi-ld:Device:tractor004",
"type": "Tractor"
},
{
"id": "urn:ngsi-ld:Device:water001",
"type": "Water"
},
{
"id": "urn:ngsi-ld:Device:water002",
"type": "Water"
},
{
"id": "urn:ngsi-ld:Device:water003",
"type": "Water"
},
{
"id": "urn:ngsi-ld:Device:water004",
"type": "Water"
},
{
"id": "urn:ngsi-ld:Device:filling001",
"type": "FillingLevelSensor"
},
{
"id": "urn:ngsi-ld:Device:filling002",
"type": "FillingLevelSensor"
},
{
"id": "urn:ngsi-ld:Device:filling003",
"type": "FillingLevelSensor"
},
{
"id": "urn:ngsi-ld:Device:filling004",
"type": "FillingLevelSensor"
}
]'
echo -e "\n \033[1;32mdone\033[0m"