forked from reeco-framework/reeco-jekyll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
components-to-rdf.sparql
259 lines (241 loc) · 8.34 KB
/
components-to-rdf.sparql
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
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX schema: <https://schema.org/>
PREFIX fabio: <http://purl.org/spar/fabio/>
PREFIX frapo: <http://purl.org/cerif/frapo/>
CONSTRUCT {
# #--> Step 6. Construct Knowledge Graph (when the Ontology evolves, change this!!!)
# Container triples:
?container a schema:Collection, ?Type ;
schema:identifier ?id ;
schema:title ?title ;
schema:abstract ?description ;
schema:image ?image ;
schema:logo ?logo ;
schema:funding ?grant ;
schema:creditText ?credits ;
schema:isPartOf ?w_package , ?pilot_ , ?project_ ;
schema:citation ?main_pub_ ;
schema:subjectOf ?publication_ , ?report_ , ?main_report_, ?deliverable_doc_ ;
schema:hasPart ?part .
# Component triples:
?component a frapo:MaterialOutput, ?Type ;
schema:identifier ?id , ?bnode2 ;
schema:abstract ?label ;
schema:title ?title ;
schema:releasedEvent ?bnode0 ;
schema:image ?image ;
schema:logo ?logo ;
schema:isPartOf ?w_package , ?pilot_ , ?project_ , ?extends ;
schema:discussionUrl ?log ;
schema:license ?licence ;
schema:copyrightNotice ?copyright ;
schema:contributor ?contributor ;
schema:distribution ?resource ;
schema:workExample ?demo ;
schema:usageInfo ?usage_info ;
schema:assesses ?use_case ;
schema:isBasedOn ?story , ?persona_ , ?description ;
schema:subjectOf ?documentation_ , ?publication_ , ?main_report_ , ?report_ , ?deliverable_doc_ ;
schema:review ?evaluated_in_ ;
schema:hasPart ?reuses ;
schema:supportingData ?serves ;
schema:provider ?generated_by ;
schema:mainEntityOfPage ?published_in ;
schema:citation ?main_pub_ ;
schema:creditText ?credits .
# DOI triples:
?bnode2 a schema:PropertyValue ;
schema:PropertyID "doi" ;
schema:value ?doi .
# Release Event triples:
?bnode0 schema:startDate ?date ;
schema:softwareVersion ?number ;
schema:releaseNotes ?link .
# Work Package triples:
?w_package a fabio:WorkPackage .
# Pilot triples:
?pilot_ a frapo:Investigation .
# Project triples:
?project_ a schema:Project .
# Related Componenets triples:
?persona_ a schema:ShortStory .
?documentation_ a schema:HowTo .
?evaluated_in_ a schema:Review .
# Grant triples:
?grant a schema:Grant ;
schema:funder ?bnode1 .
?bnode1 schema:name ?funder_name ;
schema:url ?funder_url .
# Bibliography triples:
?main_pub_ a schema:Article .
?publication_ a schema:Article .
?main_report_ a schema:Report .
?report_ a schema:Report .
?deliverable_doc_ a schema:TechArticle .
}
WHERE {
SERVICE <x-sparql-anything:> {
SERVICE <x-sparql-anything:> {
# --> Step 2. extract the YAML fontmatter from files with component annotations
fx:properties fx:location ?_componentFile .
[] a xyz:YamlFrontMatter ; fx:anySlot ?yaml
}
BIND ( ?yaml as ?content ) .
#--> Step 3. parse the YAML content
fx:properties fx:content ?content ;
fx:triplifier "com.github.sparqlanything.yaml.YAMLTriplifier" ; fx:blank-nodes "false".
#--> Step 4. Query the Ecosystem Schema annotations (when the schema evolves, change only this!)
{ # Components:
# Id
?x xyz:component-id ?id .
# Type
optional { ?x xyz:type ?type . filter (!isIRI(?type)) }
optional { ?x xyz:type [ fx:anySlot ?type ] }
# Name
optional{ ?x xyz:name ?name }
# Description
optional { ?x xyz:description ?description }
# Image
optional { ?x xyz:image ?image }
# Logo
optional { ?x xyz:logo ?logo }
# Work Package
optional { ?x xyz:work-package [ fx:anySlot ?wp ] }
# Pilot
optional { ?x xyz:pilot [ fx:anySlot ?pilot ] }
# Project
optional { ?x xyz:project ?project }
# Resource
optional { ?x xyz:resource ?resource }
# Demo
optional { ?x xyz:demo ?demo }
# Release-date
optional { ?x xyz:release-date ?date }
# Release-number
optional { ?x xyz:release-number ?number }
# Release-link
optional { ?x xyz:release-link ?link }
# Doi
optional { ?x xyz:doi ?doi }
# Changelog
optional { ?x xyz:changelog ?log }
# License
optional { ?x xyz:licence [ fx:anySlot ?licence ] }
# Copyright
optional { ?x xyz:copyright ?copyright }
# Contributors
optional { ?x xyz:contributors [ fx:anySlot ?contributor ] }
# Related-components
optional {
?x xyz:related-components ?blank .
optional {
?blank fx:anySlot ?blank2 .
optional{ ?blank2 xyz:informed-by [ fx:anySlot ?usage_info ] }
optional{ ?blank2 xyz:use-case [ fx:anySlot ?use_case ] }
optional{ ?blank2 xyz:story [ fx:anySlot ?story ] }
optional{ ?blank2 xyz:persona [ fx:anySlot ?persona ] }
optional{ ?blank2 xyz:documentation [ fx:anySlot ?documentation ] }
optional{ ?blank2 xyz:evaluated-in [ fx:anySlot ?evaluated_in ] }
optional{ ?blank2 xyz:extends [ fx:anySlot ?extends ] }
optional{ ?blank2 xyz:reuses [ fx:anySlot ?reuses ] }
optional{ ?blank2 xyz:serves [ fx:anySlot ?serves ] }
optional{ ?blank2 xyz:generated-by [ fx:anySlot ?generated_by ] }
optional{ ?blank2 xyz:derived-from [ fx:anySlot ?derived_from ] }
}
}
# Bibliography
optional {
?x xyz:bibliography ?blank1 .
optional {
?blank1 fx:anySlot ?blank3 .
optional { ?blank3 xyz:published-in [ fx:anySlot ?published_in ] }
optional { ?blank3 xyz:main-publication ?main_pub }
optional { ?blank3 xyz:publication [ fx:anySlot ?publication ] }
optional { ?blank3 xyz:main-report [ fx:anySlot ?main_report ] }
optional { ?blank3 xyz:report [ fx:anySlot ?report ] }
optional { ?blank3 xyz:deliverable-document [ fx:anySlot ?deliverable_doc ] }
}
}
# Credits
optional{ ?x xyz:credits ?credits }
} union {
# Containers:
# Container ID
?x xyz:container-id ?container_id .
# Type
optional { ?x xyz:type ?type . filter (!isIRI(?type)) }
optional { ?x xyz:type [ fx:anySlot ?type ] }
# Name
optional { ?x xyz:name ?name }
# Description
optional { ?x xyz:description ?description }
# Image
optional { ?x xyz:image ?image }
# Logo
optional { ?x xyz:logo ?logo }
# Funder
optional {
?x xyz:funder ?blank1 .
optional {
?blank1 fx:anySlot ?blank2 .
optional{ ?blank2 xyz:grant-agreement ?funder_grant }
optional{ ?blank2 xyz:name ?funder_name }
optional{ ?blank2 xyz:url ?funder_url }
}
}
# Credits
optional{ ?x xyz:credits ?credits }
# Work Package
optional { ?x xyz:work-package [ fx:anySlot ?wp ] }
# Pilot
optional { ?x xyz:pilot [ fx:anySlot ?pilot ] }
# Project
optional { ?x xyz:project ?project }
# Bibliography
optional {
?x xyz:bibliography ?blank3 .
optional {
?blank3 fx:anySlot ?blank4 .
optional { ?blank4 xyz:main-publication ?main_pub }
optional { ?blank4 xyz:publication [ fx:anySlot ?publication ] }
optional { ?blank4 xyz:report [ fx:anySlot ?report ] }
optional { ?blank4 xyz:main-report [ fx:anySlot ?main_report ] }
optional { ?blank4 xyz:deliverable-document [ fx:anySlot ?deliverable_doc ] }
}
}
# Has-part
optional { ?x xyz:has-part [ fx:anySlot ?part ] }
}
#filter (?id != "")
}
#--> Step 5. Build entities (when entity IRIs design change, modify this!)
BIND ( ?_namespace AS ?ns ) .
# Entities:
BIND ( fx:entity ( ?ns, ?container_id ) AS ?container )
BIND ( fx:entity ( ?ns, ?id ) AS ?component )
BIND ( fx:entity ( ?ns, ?funder_grant ) AS ?grant )
BIND ( fx:entity ( ?ns, replace(?type, " ", "") ) AS ?Type )
BIND ( fx:entity ( ?ns, ?wp ) AS ?w_package )
BIND ( fx:entity ( ?ns, ?id ) AS ?r_event )
BIND ( fx:entity ( ?ns, ?pilot) AS ?pilot_ )
BIND ( fx:entity ( ?ns, ?project) AS ?project_ )
BIND ( ?main_pub AS ?main_pub_ )
BIND ( ?publication AS ?publication_ )
BIND ( ?report AS ?report_)
BIND ( ?main_report AS ?main_report_)
BIND ( ?deliverable_doc AS ?deliverable_doc_ )
BIND ( fx:entity ( ?ns, ?persona) AS ?persona_ )
BIND ( fx:entity ( ?ns, ?documentation) AS ?documentation_ )
BIND ( fx:entity ( ?ns, ?evaluated_in) AS ?evaluated_in_ )
# Blank Nodes
BIND ( fx:bnode ( ?link ) AS ?bnode0 )
BIND ( fx:bnode ( ?funder_grant ) AS ?bnode1 )
BIND ( fx:bnode ( ?doi ) as ?bnode2 )
# Literals:
BIND ( fx:literal ( ?description, "en" ) AS ?label )
BIND ( fx:literal ( ?name, "en" ) AS ?title )
}