forked from DylanVanAssche/RML-LDES-prototype
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmapping-webapi-official.rml.ttl
324 lines (295 loc) · 9.1 KB
/
mapping-webapi-official.rml.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
#
# RML mapping rules for https://datapiloten.be/bluebike/availabilities.geojson
# (c) Dylan Van Assche (2021)
# IDLab - Ghent University - imec
#
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix rmlt: <http://semweb.mmlab.be/ns/rml-target#> .
@prefix rdfs: <https://www.w3.org/2000/01/rdf-schema#> .
@prefix comp: <http://semweb.mmlab.be/ns/rml-compression#> .
@prefix formats: <http://www.w3.org/ns/formats/> .
@prefix gbfs: <https://w3id.org/gbfs#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix td: <https://www.w3.org/2019/wot/td#> .
@prefix htv: <http://www.w3.org/2011/http#> .
@prefix hctl: <https://www.w3.org/2019/wot/hypermedia#> .
@prefix schema: <http://schema.org/> .
@prefix gtfs: <http://vocab.gtfs.org/terms#> .
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix fnml: <http://semweb.mmlab.be/ns/fnml#> .
@prefix fno: <https://w3id.org/function/ontology#> .
@prefix grel: <http://users.ugent.be/~bjdmeest/function/grel.ttl#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix tree: <https://w3id.org/tree#> .
@prefix ldes: <https://w3id.org/ldes#> .
@prefix idlab: <http://example.com/idlab/function/> .
@base <http://example.org/rules/> .
<#TargetDump> a rmlt:LogicalTarget;
rmlt:target [ a void:Dataset;
void:dataDump <file://./history/bluebike.ttl>;
];
rmlt:serialization formats:Turtle;
.
<#TDForm> a td:Form;
# URL
# See private security file
# Content type
hctl:forContentType "application/json";
# Read only
hctl:hasOperationType td:readproperty;
# Set HTTP method and headers
htv:methodName "GET";
htv:headers ([
htv:fieldName "User-Agent";
htv:fieldValue "IDLab - Ghent University - imec (RMLMapper)";
]);
.
<#WoTWebAPISource> a td:PropertyAffordance;
td:hasForm <#TDForm>;
.
<#WoTWebAPI> a td:Thing;
td:hasPropertyAffordance <#WoTWebResource>;
.
# TREE view
<#ViewTriplesMap> a rr:TriplesMap;
rml:logicalSource [
rml:source "ldes.json";
rml:referenceFormulation ql:JSONPath;
rml:iterator "$";
];
rr:subjectMap[
rml:reference "ldes.iri";
rr:termType rr:IRI;
rml:logicalTarget <#TargetDump>;
];
# LDES retention policy
rr:predicateObjectMap [
rr:predicate ldes:retentionPolicy;
rr:objectMap [
fnml:functionValue [
rr:predicateObjectMap [
rr:predicate fno:executes ;
rr:objectMap [ rr:constant grel:array_join ]
];
rr:predicateObjectMap [
rr:predicate grel:p_array_a ;
rr:objectMap [ rml:reference "ldes.iri" ]
];
rr:predicateObjectMap [
rr:predicate grel:p_array_a ;
rr:objectMap [ rr:constant "#retention"; ]
];
rr:predicateObjectMap [
rr:predicate grel:p_string_sep ;
rr:objectMap [ rr:constant ""; ]
];
];
rr:termType rr:IRI;
];
];
.
# LDES RetentionPolicy
<#RetentionPolicyTriplesMap> a rr:TriplesMap;
rml:logicalSource [
rml:source "ldes.json";
rml:referenceFormulation ql:JSONPath;
rml:iterator "$";
];
rr:subjectMap[
fnml:functionValue [
rr:predicateObjectMap [
rr:predicate fno:executes ;
rr:objectMap [ rr:constant grel:array_join ]
];
rr:predicateObjectMap [
rr:predicate grel:p_array_a ;
rr:objectMap [ rml:reference "ldes.iri" ]
];
rr:predicateObjectMap [
rr:predicate grel:p_array_a ;
rr:objectMap [ rr:constant "#retention"; ]
];
];
rr:termType rr:IRI;
rml:logicalTarget <#TargetDump>;
];
# rdf:type
rr:predicateObjectMap [
rr:predicate rdf:type;
rr:objectMap [ rml:reference "ldes.retentionPolicy.type"; rr:termType rr:IRI; ];
];
rr:predicateObjectMap [
rr:predicate ldes:amount;
rr:objectMap [ rml:reference "ldes.retentionPolicy.amount"; rr:datatype xsd:integer; ];
];
rr:predicateObjectMap [
rr:predicate ldes:timestampPath;
rr:object dcterms:created;
];
rr:predicateObjectMap [
rr:predicate ldes:versionOfPath;
rr:object dcterms:isVersionOf;
];
.
<#TreeTriplesMap> a rr:TriplesMap;
rml:logicalSource [
rml:source "ldes.json";
rml:referenceFormulation ql:JSONPath;
rml:iterator "$"
];
# LDES stream
rr:subjectMap[
fnml:functionValue [
rr:predicateObjectMap [
rr:predicate fno:executes ;
rr:objectMap [ rr:constant grel:array_join ]
];
rr:predicateObjectMap [
rr:predicate grel:p_array_a ;
rr:objectMap [ rml:reference "ldes.iri" ]
];
rr:predicateObjectMap [
rr:predicate grel:p_array_a ;
rr:objectMap [ rr:constant "#eventstream"; ]
];
];
rr:termType rr:IRI;
rr:class ldes:EventStream;
rml:logicalTarget <#TargetDump>;
];
# TREE member
rr:predicateObjectMap [
rr:predicate tree:member;
rr:objectMap [
a rr:ObjectMap;
rr:parentTriplesMap <#StationsTriplesMap>;
rr:termType rr:IRI;
];
];
# TREE view
rr:predicateObjectMap [
rr:predicate tree:view;
rr:objectMap [ a rr:ObjectMap;
rml:reference "ldes.iri";
rr:termType rr:IRI;
];
];
.
<#StationsTriplesMap> a rr:TriplesMap;
rml:logicalSource [ a rml:LogicalSource;
rml:source <#WoTWebAPISource>;
rml:referenceFormulation ql:JSONPath;
rml:iterator "$.[*]";
];
# Unique IRI generation: $stationId#$generatedAtTime
rr:subjectMap [
fnml:functionValue [
rr:predicateObjectMap [
rr:predicate fno:executes ;
rr:objectMap [ rr:constant grel:array_join ]
];
rr:predicateObjectMap [
rr:predicate grel:p_array_a ;
rr:objectMap [ rr:template "https://blue-bike.be/stations/{id}" ]
];
rr:predicateObjectMap [
rr:predicate grel:p_array_a ;
rr:objectMap [
fnml:functionValue [
rr:predicateObjectMap [
rr:predicate fno:executes ;
rr:objectMap [ rr:constant grel:array_join ]
];
rr:predicateObjectMap [
rr:predicate grel:p_array_a ;
rr:objectMap [ rr:constant "#" ]
];
rr:predicateObjectMap [
rr:predicate grel:p_array_a ;
rr:objectMap [ rml:reference "last_seen" ]
];
];
];
];
];
rr:termType rr:IRI;
rml:logicalTarget <#TargetDump>;
];
# rdf:type
rr:predicateObjectMap [
rr:predicate rdf:type;
rr:objectMap [
fnml:functionValue [
rr:predicateObjectMap [
rr:predicate fno:executes ;
rr:objectMap [ rr:constant grel:controls_if ]
];
rr:predicateObjectMap [
rr:predicate grel:bool_b ;
rr:objectMap [
fnml:functionValue [
rr:predicateObjectMap [
rr:predicate fno:executes;
rr:objectMap [ rr:constant idlab:equal ];
];
rr:predicateObjectMap [
rr:predicate grel:valueParameter;
rr:objectMap [ rml:reference "type" ];
];
rr:predicateObjectMap [
rr:predicate grel:valueParameter2;
rr:objectMap [ rr:constant "1" ];
];
];
rr:datatype xsd:boolean
];
];
rr:predicateObjectMap [
rr:predicate grel:any_true ;
rr:objectMap [ rr:constant "https://w3id.org/gbfs#Station"; rr:termType rr:IRI ]
];
rr:predicateObjectMap [
rr:predicate grel:any_false ;
rr:objectMap [ rr:constant "https://w3id.org/gbfs#Station"; rr:termType rr:IRI ]
];
];
rr:termType rr:IRI;
];
];
# BlueBike station: name
rr:predicateObjectMap [
rr:predicate schema:name ;
rr:objectMap [ rml:reference "name"; rr:datatype xsd:string; ]
];
# BlueBike station: available bicycles
rr:predicateObjectMap [
rr:predicate gbfs:bikes_available ;
rr:objectMap [ rml:reference "bikes_available"; rr:datatype xsd:integer; ]
];
# BlueBike station: available docks = bikes_in_use
rr:predicateObjectMap [
rr:predicate gbfs:docks_in_use ;
rr:objectMap [ rml:reference "bikes_in_use"; rr:datatype xsd:integer; ]
];
# Geo location
rr:predicateObjectMap [
rr:predicate geo:latitude ;
rr:objectMap [ rml:reference "latitude"; rr:datatype xsd:float; ]
];
rr:predicateObjectMap [
rr:predicate geo:longitude ;
rr:objectMap [ rml:reference "longitude"; rr:datatype xsd:float; ]
];
# Versioning
rr:predicateObjectMap [
rr:predicate dcterms:created ;
rr:objectMap [ rml:reference "last_seen"; rr:dataType xsd:dateTime; ]
];
rr:predicateObjectMap [
rr:predicate dcterms:isVersionOf ;
rr:objectMap [ rr:template "https://blue-bike.be/stations/{id}"; rr:termType rr:IRI; ]
];
.