Skip to content

Commit 3cc5c87

Browse files
committed
Update SPARQL queries for optional and array types
1 parent 326f60e commit 3cc5c87

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

src/main/java/org/commonwl/view/cwl/RDFService.java

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,29 @@ public String getOntLabel(String ontologyURI) {
158158
public ResultSet getInputs(String path, String workflowURI) {
159159
ParameterizedSparqlString inputsQuery = new ParameterizedSparqlString();
160160
inputsQuery.setCommandText(queryCtx +
161-
"SELECT ?name ?type ?format ?label ?doc\n" +
161+
"SELECT ?name ?type ?items ?null ?format ?label ?doc\n" +
162162
"WHERE {\n" +
163163
" GRAPH ?graphName {" +
164164
" ?wf rdf:type cwl:Workflow .\n" +
165165
" ?wf cwl:inputs ?name .\n" +
166-
" OPTIONAL { ?name sld:type ?type }\n" +
166+
" OPTIONAL {\n" +
167+
" { \n" +
168+
" ?name sld:type ?type\n" +
169+
" FILTER(?type != sld:null) \n" +
170+
" FILTER (!isBlank(?type))\n" +
171+
" } UNION { \n" +
172+
" ?name sld:type ?arraytype .\n" +
173+
" ?arraytype sld:type ?type .\n" +
174+
" ?arraytype sld:items ?items \n" +
175+
" }\n" +
176+
" }\n" +
177+
" OPTIONAL { \n" +
178+
" ?name sld:type ?null\n" +
179+
" FILTER(?null = sld:null)\n" +
180+
" }\n" +
167181
" OPTIONAL { ?name cwl:format ?format }\n" +
168182
" OPTIONAL { ?name sld:label|rdfs:label ?label }\n" +
169-
" OPTIONAL { ?name sld:doc|rdfs:comment ?doc }\n" +
183+
" OPTIONAL { ?name sld:doc|rdfs:comment ?doc }" +
170184
" FILTER(regex(str(?wf), ?wfFilter, \"i\" ))" +
171185
" }" +
172186
"}");
@@ -184,15 +198,29 @@ public ResultSet getInputs(String path, String workflowURI) {
184198
public ResultSet getOutputs(String path, String workflowURI) {
185199
ParameterizedSparqlString outputsQuery = new ParameterizedSparqlString();
186200
outputsQuery.setCommandText(queryCtx +
187-
"SELECT ?name ?type ?format ?label ?doc\n" +
201+
"SELECT ?name ?type ?items ?null ?format ?label ?doc\n" +
188202
"WHERE {\n" +
189203
" GRAPH ?graphName {" +
190204
" ?wf rdf:type cwl:Workflow .\n" +
191205
" ?wf cwl:outputs ?name .\n" +
192-
" OPTIONAL { ?name sld:type ?type }\n" +
206+
" OPTIONAL {\n" +
207+
" { \n" +
208+
" ?name sld:type ?type\n" +
209+
" FILTER(?type != sld:null) \n" +
210+
" FILTER (!isBlank(?type))\n" +
211+
" } UNION { \n" +
212+
" ?name sld:type ?arraytype .\n" +
213+
" ?arraytype sld:type ?type .\n" +
214+
" ?arraytype sld:items ?items \n" +
215+
" }\n" +
216+
" }\n" +
217+
" OPTIONAL { \n" +
218+
" ?name sld:type ?null\n" +
219+
" FILTER(?null = sld:null)\n" +
220+
" }\n" +
193221
" OPTIONAL { ?name cwl:format ?format }\n" +
194222
" OPTIONAL { ?name sld:label|rdfs:label ?label }\n" +
195-
" OPTIONAL { ?name sld:doc|rdfs:comment ?doc }\n" +
223+
" OPTIONAL { ?name sld:doc|rdfs:comment ?doc }" +
196224
" FILTER(regex(str(?wf), ?wfFilter, \"i\" ))" +
197225
" }" +
198226
"}");

0 commit comments

Comments
 (0)