-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrdfc-pipeline.ttl
439 lines (397 loc) · 16.1 KB
/
rdfc-pipeline.ttl
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
@prefix js: <https://w3id.org/conn/js#>.
@prefix : <https://w3id.org/conn#>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
@prefix idlab-fn: <https://w3id.org/imec/idlab/function#>.
@prefix as: <https://www.w3.org/ns/activitystreams#>.
@prefix dct: <http://purl.org/dc/terms/>.
@prefix formats: <http://www.w3.org/ns/formats/>.
@prefix era: <http://data.europa.eu/949/>.
<> owl:imports <./node_modules/@rdfc/js-runner/ontology.ttl>,
<./node_modules/@rdfc/js-runner/channels/file.ttl>,
<./node_modules/@rdfc/js-runner/channels/http.ttl>,
<./node_modules/@rdfc/file-utils-processors-ts/processors.ttl>,
<./node_modules/@rdfc/xml-utils-processors-ts/processors.ttl>,
<./node_modules/@rdfc/rml-utils-processor-ts/processors.ttl>,
<./node_modules/@rdfc/sds-processors-ts/configs/sdsify.ttl>,
<./node_modules/@rdfc/sds-processors-ts/configs/stream_join.ttl>,
<./node_modules/@rdfc/sds-storage-writer-ts/processor.ttl>.
#########################################
# Channel definitions
#########################################
# HTTP channel for js:GlobRead → js:UnzipFile and for external update input
<rinf/http/reader> a :HttpReaderChannel;
:httpPort 3333;
:binary true.
<rinf/http/writer> a :HttpWriterChannel;
:httpEndpoint "http://localhost:3333";
:httpMethod "POST".
[ ] a :Channel;
:reader <rinf/http/reader>;
:writer <rinf/http/writer>.
# Channel for js:GlobRead → js:Y2R
<yarrrml/reader> a js:JsReaderChannel.
<yarrrml/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <yarrrml/reader>;
:writer <yarrrml/writer>.
# Channel for js:GlobRead → js:Y2R (versioned entities)
<yarrrml/versioned/reader> a js:JsReaderChannel.
<yarrrml/versioned/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <yarrrml/versioned/reader>;
:writer <yarrrml/versioned/writer>.
# Channel for js:Y2R → js:StreamJoin
<rml/reader> a js:JsReaderChannel.
<rml/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <rml/reader>;
:writer <rml/writer>.
# Channel for js:Y2R → js:IncRMLTransformer (versioned entities)
<rml/versioned/reader> a js:JsReaderChannel.
<rml/versioned/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <rml/versioned/reader>;
:writer <rml/versioned/writer>.
# Channel for js:IncRMLTransformer → js:StreamJoin (versioned entities)
<incrml/reader> a js:JsReaderChannel.
<incrml/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <incrml/reader>;
:writer <incrml/writer>.
# Channel for js:StreamJoin → js:RMLMapperReader
<rml/joined/reader> a js:JsReaderChannel.
<rml/joined/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <rml/joined/reader>;
:writer <rml/joined/writer>.
# Channel for js:ReadFile → js:XQueryProcessor and js:RMLMapperReader
<rinfxml/reader> a js:JsReaderChannel.
<rinfxml/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <rinfxml/reader>;
:writer <rinfxml/writer>.
# Channel 1 for js:XQueryProcessor → js:RMLMapperReader
<internal-node-link-in-out/reader> a js:JsReaderChannel.
<internal-node-link-in-out/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <internal-node-link-in-out/reader>;
:writer <internal-node-link-in-out/writer>.
# Channel 2 for js:XQueryProcessor → js:RMLMapperReader
<internal-node-link-no-in/reader> a js:JsReaderChannel.
<internal-node-link-no-in/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <internal-node-link-no-in/reader>;
:writer <internal-node-link-no-in/writer>.
# Channel 3 for js:XQueryProcessor → js:RMLMapperReader
<internal-node-link-no-out/reader> a js:JsReaderChannel.
<internal-node-link-no-out/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <internal-node-link-no-out/reader>;
:writer <internal-node-link-no-out/writer>.
# Channel for js:RMLMapperReader → js:Sdsify
<ldes-raw/reader> a js:JsReaderChannel.
<ldes-raw/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <ldes-raw/reader>;
:writer <ldes-raw/writer>.
# Channel for js:Sdsify → js:Ingest
<sds/reader> a js:JsReaderChannel.
<sds/writer> a js:JsWriterChannel.
[ ] a js:JsChannel;
:reader <sds/reader>;
:writer <sds/writer>.
# File reader channel for input on js:RMLMapperReader
<countriesSource> a :FileReaderChannel;
:fileOnReplace true;
:fileReadFirstContent true;
:filePath <./rawdata/countries.csv>.
# File reader channel for input on js:RMLMapperReader
<predicateIndexSource> a :FileReaderChannel;
:fileOnReplace true;
:fileReadFirstContent true;
:filePath <./rawdata/index_predicate_mappings.csv>.
# File reader channel for metadata input on js:Ingest
<sdsMetadataSource> a :FileReaderChannel;
:fileOnReplace true;
:fileReadFirstContent true;
:filePath <./config/sds-metadata.ttl>.
#########################################
# Processor definitions
#########################################
# Processor to unzip RINF XML source file
[ ] a js:UnzipFile;
js:input <rinf/http/reader>;
js:output <rinfxml/writer>.
# Processor to read and stream out a set of YARRRML mapping files
[ ] a js:GlobRead;
js:glob <./mappings/non-versioned/*.yml>;
js:output <yarrrml/writer>.
# Processor to read and stream out a set of YARRRML mapping files (versioned entities)
[ ] a js:GlobRead;
js:glob <./mappings/versioned/*.yml>;
js:output <yarrrml/versioned/writer>.
# Processor to convert YARRRML to RML mappings
[ ] a js:Y2R;
js:input <yarrrml/reader>;
js:output <rml/writer>.
# Processor to convert YARRRML to RML mappings (versioned entities)
[ ] a js:Y2R;
js:input <yarrrml/versioned/reader>;
js:output <rml/versioned/writer>.
# Processor to expand RML mappings to IncRML mappings
[ ] a js:IncRMLTransformer;
js:rmlStream <rml/versioned/reader>;
js:config [
js:stateBasePath <./state>;
js:lifeCycleConfig [
js:predicate era:lifecycleType;
js:create [
js:function idlab-fn:explicitCreate;
js:type as:Create;
];
js:update [
js:function idlab-fn:implicitUpdate;
js:type as:Update;
];
js:delete [
js:function idlab-fn:implicitDelete;
js:type as:Delete;
];
];
js:targetConfig [
js:targetPath <./output.nt>;
js:timestampPath dct:modified;
js:versionOfPath dct:isVersionOf;
js:serialization formats:N-Triples;
js:uniqueIRIs true
];
];
js:incrmlStream <incrml/writer>;
js:bulkMode true.
# Processor to join the versioned and non-versioned mapping streams
[ ] a js:StreamJoin;
js:input <incrml/reader>;
js:input <rml/reader>;
js:output <rml/joined/writer>.
# Processor to execute XQueries over XML documents
[ ] a js:XQueryProcessor;
js:xmlInput <rinfxml/reader>;
js:xquery [
js:name "internal-node-link-in-out";
js:query """
<RINFData>{
for $op in //OperationalPoint/UniqueOPID
return (
let $sol1 := //SOLTrack/../SOLOPEnd[@Value=$op/@Value and //SectionOfLine/SOLOPStart[@Value=$op/@Value]]/../SOLTrack
let $sol2 := //SOLTrack/../SOLOPStart[@Value=$op/@Value and //SectionOfLine/SOLOPEnd[@Value=$op/@Value]]/../SOLTrack
for $tr1 in $sol1
return (
for $tr2 in $sol2
return
<netElement>
<INCOMING_LINE>{$tr1/../SOLLineIdentification/@Value}</INCOMING_LINE>
<INCOMING_REMOTE_OP>{$tr1/../SOLOPStart/@Value}</INCOMING_REMOTE_OP>
<INCOMING>{$tr1/SOLTrackIdentification/@Value}</INCOMING>
<INCOMING_DIRECTION>{$tr1/SOLTrackDirection/@Value}</INCOMING_DIRECTION>
<UOPID>{$op}</UOPID>
<OUTGOING>{$tr2/SOLTrackIdentification/@Value}</OUTGOING>
<OUTGOING_DIRECTION>{$tr2/SOLTrackDirection/@Value}</OUTGOING_DIRECTION>
<OUTGOING_REMOTE_OP>{$tr2/../SOLOPEnd/@Value}</OUTGOING_REMOTE_OP>
<OUTGOING_LINE>{$tr2/../SOLLineIdentification/@Value}</OUTGOING_LINE>
<value> { concat (
$tr1/../SOLLineIdentification/@Value,'_',
$tr1/../SOLOPStart/@Value,'_',
$tr1/SOLTrackIdentification/@Value,'_',
$op/@Value,'_',
$tr2/SOLTrackIdentification/@Value,'_',
$tr2/../SOLOPEnd/@Value,'_',
$tr2/../SOLLineIdentification/@Value
)}</value>
</netElement>
)
)
}</RINFData>
""";
js:outputStream <internal-node-link-in-out/writer>;
], [
js:name "internal-node-link-no-in";
js:query """
<RINFData>{
for $op in //OperationalPoint/UniqueOPID
return(
for $tr1 in //SOLTrack/../SOLOPStart[@Value=$op/@Value]/../SOLTrack
return(
for $tr2 in reverse(//SOLTrack/../SOLOPStart[@Value=$op/@Value]/../SOLTrack )
where($tr1/SOLTrackIdentification/@Value != $tr2/SOLTrackIdentification/@Value or ($tr1/../SOLOPEnd/@Value != $tr2/../SOLOPEnd/@Value))
return
<netElement>
<INCOMING_LINE>{$tr1/../SOLLineIdentification/@Value}</INCOMING_LINE>
<INCOMING_REMOTE_OP>{$tr1/../SOLOPEnd/@Value}</INCOMING_REMOTE_OP>
<INCOMING>{$tr1/SOLTrackIdentification/@Value}</INCOMING>
<INCOMING_DIRECTION>{$tr1/SOLTrackDirection/@Value}</INCOMING_DIRECTION>
<UOPID>{$op}</UOPID>
<OUTGOING>{$tr2/SOLTrackIdentification/@Value}</OUTGOING>
<OUTGOING_DIRECTION>{$tr2/SOLTrackDirection/@Value}</OUTGOING_DIRECTION>
<OUTGOING_REMOTE_OP>{$tr2/../SOLOPEnd/@Value}</OUTGOING_REMOTE_OP>
<OUTGOING_LINE>{$tr2/../SOLLineIdentification/@Value}</OUTGOING_LINE>
<value> {(concat(
$tr1/../SOLLineIdentification/@Value,'_',
$tr1/../SOLOPEnd/@Value,'_',
$tr1/SOLTrackIdentification/@Value,'_',
$op/@Value,'_',
$tr2/SOLTrackIdentification/@Value,'_',
$tr2/../SOLOPEnd/@Value,'_',
$tr2/../SOLLineIdentification/@Value
))}</value>
</netElement>
)
)
}</RINFData>
""";
js:outputStream <internal-node-link-no-in/writer>;
], [
js:name "internal-node-link-no-out";
js:query """
<RINFData>{
for $op in //OperationalPoint/UniqueOPID
return (
for $tr1 in //SOLTrack/../SOLOPEnd[@Value=$op/@Value ]/../SOLTrack
return (
for $tr2 in reverse(//SOLTrack/../SOLOPEnd[@Value=$op/@Value]/../SOLTrack)
where($tr1/SOLTrackIdentification/@Value != $tr2/SOLTrackIdentification/@Value or ($tr1/../SOLOPStart/@Value!=$tr2/../SOLOPStart/@Value))
return
<netElement>
<INCOMING_LINE>{$tr1/../SOLLineIdentification/@Value}</INCOMING_LINE>
<INCOMING_REMOTE_OP>{$tr1/../SOLOPStart/@Value}</INCOMING_REMOTE_OP>
<INCOMING>{$tr1/SOLTrackIdentification/@Value}</INCOMING>
<INCOMING_DIRECTION>{$tr1/SOLTrackDirection/@Value}</INCOMING_DIRECTION>
<UOPID>{$op}</UOPID>
<OUTGOING>{$tr2/SOLTrackIdentification/@Value}</OUTGOING>
<OUTGOING_DIRECTION>{$tr2/SOLTrackDirection/@Value}</OUTGOING_DIRECTION>
<OUTGOING_REMOTE_OP>{$tr2/../SOLOPStart/@Value}</OUTGOING_REMOTE_OP>
<OUTGOING_LINE>{$tr2/../SOLLineIdentification/@Value}</OUTGOING_LINE>
<value>{(
concat(
$tr1/../SOLLineIdentification/@Value,'_',
$tr1/../SOLOPStart/@Value,'_',
$tr1/SOLTrackIdentification/@Value,'_',
$op/@Value,'_',
$tr2/SOLTrackIdentification/@Value,'_',
$tr2/../SOLOPStart/@Value,'_',
$tr2/../SOLLineIdentification/@Value
)
)}</value>
</netElement>
)
)
}</RINFData>
""";
js:outputStream <internal-node-link-no-out/writer>;
].
# Processor to execute RML mappings
[ ] a js:RMLMapperReader;
js:output <ldes-raw/writer>;
js:rmlSource [
js:sourceLocation "data/countries.csv";
js:input <countriesSource>;
], [
js:sourceLocation "data/index_predicate_mappings.csv";
js:input <predicateIndexSource>;
], [
js:sourceLocation "dataset/internal-node-link-in-out.xml";
js:input <internal-node-link-in-out/reader>;
js:trigger true;
], [
js:sourceLocation "dataset/internal-node-link-no-in.xml";
js:input <internal-node-link-no-in/reader>;
js:trigger true;
], [
js:sourceLocation "dataset/internal-node-link-no-out.xml";
js:input <internal-node-link-no-out/reader>;
js:trigger true;
], [
js:sourceLocation "dataset/data.xml";
js:input <rinfxml/reader>;
js:trigger true;
js:incRMLStateIndex "IMCode Value=\\\"([^\\\"]+)\\\""
];
js:rmlTarget [
js:targetLocation <./output.nt>;
js:output <ldes-raw/writer>
];
js:mappings <rml/joined/reader>;
js:rmlJar <https://github.com/RMLio/rmlmapper-java/releases/download/v7.0.0/rmlmapper-7.0.0-r374-all.jar>.
# Processor to describe every entity as part of a SDS stream for further processing
[ ] a js:Sdsify;
js:input <ldes-raw/reader>;
js:output <sds/writer>;
js:stream <https://era.ilabt.imec.be/ldes/metadata#generation-stream>;
js:timestampPath dct:modified;
js:typeFilter era:NationalRailwayLine, era:SectionOfLine, era:OperationalPoint,
era:NetElement, era:NetRelation, era:Track, era:LoadCapability, era:ContactLineSystem,
era:ETCSLevel, era:TrainDetectionSystem;
js:shape """
@prefix sh: <http://www.w3.org/ns/shacl#>.
@prefix gsp: <http://www.opengis.net/ont/geosparql#>.
@prefix era: <http://data.europa.eu/949/>.
@prefix era-sh: <http://data.europa.eu/949/shapes/>.
[ ] a sh:NodeShape;
sh:xone (
era-sh:nationalRailwayLineShape
era-sh:sectionOfLineShape
era-sh:operationalPointShape
era-sh:netElementShape
era-sh:netRelationShape
era-sh:trackShape
era-sh:loadCapabilityShape
era-sh:contactLineSystemShape
era-sh:etcsLevelShape
era-sh:trainDetectionSystemShape
).
era-sh:nationalRailwayLineShape a sh:NodeShape;
sh:targetClass era:NationalRailwayLine.
era-sh:sectionOfLineShape a sh:NodeShape;
sh:targetClass era:SectionOfLine.
era-sh:operationalPointShape a sh:NodeShape;
sh:targetClass era:OperationalPoint;
sh:property [
sh:path gsp:hasGeometry;
sh:node [
a sh:NodeShape;
sh:targetClass gsp:Geometry
]
], [
sh:path era:lineReference;
sh:node [
a sh:NodeShape;
sh:targetClass era:LineReference
]
].
era-sh:netElementShape a sh:NodeShape;
sh:targetClass era:NetElement.
era-sh:netRelationShape a sh:NodeShape;
sh:targetClass era:NetRelation.
era-sh:trackShape a sh:NodeShape;
sh:targetClass era:Track.
era-sh:loadCapabilityShape a sh:NodeShape;
sh:targetClass era:LoadCapability.
era-sh:contactLineSystemShape a sh:NodeShape;
sh:targetClass era:ContactLineSystem.
era-sh:etcsLevelShape a sh:NodeShape;
sh:targetClass era:ETCSLevel.
era-sh:trainDetectionSystemShape a sh:NodeShape;
sh:targetClass era:TrainDetectionSystem.
""".
# Processor to persist the SDS stream into a MongoDB instance
[ ] a js:Ingest;
js:dataInput <sds/reader>;
js:metadataInput <sdsMetadataSource>;
js:database [
js:url <mongodb://era:rinfldes@mongodb:27017/rinf-ldes?authSource=admin>;
js:metadata "METADATA";
js:data "DATA";
js:index "INDEX";
];
js:pageSize 1000;
js:branchSize 4;
js:minBucketSpan 60.