Skip to content

Commit d144a14

Browse files
authored
Merge branch 'master' into cwltool-threadjoin
2 parents 602d3ce + e580782 commit d144a14

File tree

3 files changed

+53
-75
lines changed

3 files changed

+53
-75
lines changed

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

Lines changed: 18 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
import org.apache.jena.query.ResultSet;
4141
import org.apache.jena.rdf.model.Model;
4242
import org.apache.jena.rdf.model.ModelFactory;
43-
import org.apache.jena.rdf.model.Statement;
44-
import org.apache.jena.rdf.model.StmtIterator;
4543
import org.apache.jena.riot.RiotException;
4644
import org.commonwl.view.docker.DockerService;
4745
import org.commonwl.view.git.GitDetails;
@@ -239,42 +237,18 @@ public Workflow parseWorkflowWithCwltool(Workflow basicModel,
239237
String inputName = rdfService.stepNameFromURI(gitPath, input.get("name").toString());
240238

241239
CWLElement wfInput = new CWLElement();
242-
243-
// Array types
244240
if (input.contains("type")) {
245-
StmtIterator itr = input.get("type").asResource().listProperties();
246-
if (itr.hasNext()) {
247-
while (itr.hasNext()) {
248-
Statement complexType = itr.nextStatement();
249-
if (complexType.getPredicate().toString()
250-
.equals("https://w3id.org/cwl/salad#items")) {
251-
if (wfInputs.containsKey(inputName)
252-
&& wfInputs.get(inputName).getType().equals("?")) {
253-
wfInput.setType(typeURIToString(complexType.getObject().toString()) + "[]?");
254-
} else {
255-
wfInput.setType(typeURIToString(complexType.getObject().toString()) + "[]");
256-
}
257-
}
258-
}
241+
String type;
242+
if (input.get("type").toString().equals("https://w3id.org/cwl/salad#array")) {
243+
type = typeURIToString(input.get("items").toString()) + "[]";
259244
} else {
260-
// Optional types
261-
if (input.get("type").toString().equals("https://w3id.org/cwl/salad#null")) {
262-
if (wfInputs.containsKey(inputName)) {
263-
CWLElement inputInMap = wfInputs.get(inputName);
264-
inputInMap.setType(inputInMap.getType() + "?");
265-
} else {
266-
wfInput.setType("?");
267-
}
268-
} else if (wfInput.getType() != null && wfInput.getType().equals("?")
269-
&& !wfInput.getType().endsWith("[]")) {
270-
wfInput.setType(typeURIToString(input.get("type").toString()) + "?");
271-
} else {
272-
// Standard type
273-
wfInput.setType(typeURIToString(input.get("type").toString()));
274-
}
245+
type = typeURIToString(input.get("type").toString());
246+
}
247+
if (input.contains("null")) {
248+
type += " (Optional)";
275249
}
250+
wfInput.setType(type);
276251
}
277-
278252
if (input.contains("format")) {
279253
String format = input.get("format").toString();
280254
setFormat(wfInput, format);
@@ -296,41 +270,17 @@ public Workflow parseWorkflowWithCwltool(Workflow basicModel,
296270
CWLElement wfOutput = new CWLElement();
297271

298272
String outputName = rdfService.stepNameFromURI(gitPath, output.get("name").toString());
299-
300-
// Array types
301273
if (output.contains("type")) {
302-
StmtIterator itr = output.get("type").asResource().listProperties();
303-
if (itr.hasNext()) {
304-
while (itr.hasNext()) {
305-
Statement complexType = itr.nextStatement();
306-
if (complexType.getPredicate().toString()
307-
.equals("https://w3id.org/cwl/salad#items")) {
308-
if (wfOutputs.containsKey(outputName)
309-
&& wfOutputs.get(outputName).getType().equals("?")) {
310-
wfOutput.setType(typeURIToString(complexType.getObject().toString()) + "[]?");
311-
} else {
312-
wfOutput.setType(typeURIToString(complexType.getObject().toString()) + "[]");
313-
}
314-
}
315-
}
274+
String type;
275+
if (output.get("type").toString().equals("https://w3id.org/cwl/salad#array")) {
276+
type = typeURIToString(output.get("items").toString()) + "[]";
316277
} else {
317-
// Standard types
318-
if (wfOutput.getType() != null && wfOutput.getType().equals("?")) {
319-
wfOutput.setType(typeURIToString(output.get("type").toString()) + "?");
320-
} else {
321-
wfOutput.setType(typeURIToString(output.get("type").toString()));
322-
}
323-
324-
// Optional types
325-
if (output.get("type").toString().equals("https://w3id.org/cwl/salad#null")) {
326-
if (wfOutputs.containsKey(outputName)) {
327-
CWLElement outputInMap = wfOutputs.get(outputName);
328-
outputInMap.setType(outputInMap.getType() + "?");
329-
} else {
330-
wfOutput.setType("?");
331-
}
332-
}
278+
type = typeURIToString(output.get("type").toString());
279+
}
280+
if (output.contains("null")) {
281+
type += " (Optional)";
333282
}
283+
wfOutput.setType(type);
334284
}
335285

336286
if (output.contains("src")) {
@@ -500,9 +450,9 @@ private void setFormat(CWLElement inputOutput, String format) {
500450
rdfService.addToOntologies(ontModel);
501451
}
502452
String formatLabel = rdfService.getOntLabel(format);
503-
inputOutput.setType(inputOutput.getType() + " (" + formatLabel + ")");
453+
inputOutput.setType(inputOutput.getType() + " [" + formatLabel + "]");
504454
} catch (RiotException ex) {
505-
inputOutput.setType(inputOutput.getType() + " (format)");
455+
inputOutput.setType(inputOutput.getType() + " [format]");
506456
}
507457
}
508458

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
"}");

src/main/resources/templates/workflow.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<meta name="twitter:site" content="@commonwl" />
2727
<meta name="twitter:title" th:content="${'CWL Workflow: ' + workflow.label}" />
2828
<meta name="twitter:description" th:if="${workflow.doc != null}" th:content="${workflow.doc}" />
29-
<meta name="twitter:image" th:content="${appURL + '/workflows/' + workflow.id + '/graph/png'}" />
29+
<meta name="twitter:image" th:content="@{${workflow.getVisualisationPng()}}" />
3030
<title th:text="${workflow.label + ' - Common Workflow Language Viewer'}">Common Workflow Language Viewer</title>
3131
<link rel="stylesheet" th:href="@{/bower_components/bootstrap/dist/css/bootstrap.min.css}" href="../static/bower_components/bootstrap/dist/css/bootstrap.min.css" />
3232
<link rel="stylesheet" type="text/css" th:href="@{/css/main-20170616.css}" href="../static/css/main-20170616.css" />

0 commit comments

Comments
 (0)