Skip to content

Commit 5dd26b3

Browse files
committed
Allow non-ontology formats to be linked for inputs and outputs
1 parent 388414d commit 5dd26b3

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

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

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.jena.rdf.model.ModelFactory;
3434
import org.apache.jena.rdf.model.Statement;
3535
import org.apache.jena.rdf.model.StmtIterator;
36+
import org.apache.jena.riot.RiotException;
3637
import org.commonwl.view.docker.DockerService;
3738
import org.commonwl.view.github.GitHubService;
3839
import org.commonwl.view.github.GithubDetails;
@@ -268,15 +269,7 @@ public Workflow parseWorkflowWithCwltool(GithubDetails githubInfo,
268269

269270
if (input.contains("format")) {
270271
String format = input.get("format").toString();
271-
wfInput.setFormat(format);
272-
273-
if (!rdfService.ontPropertyExists(format)) {
274-
Model ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
275-
ontModel.read(format, null, "RDF/XML");
276-
rdfService.addToOntologies(ontModel);
277-
}
278-
String formatLabel = rdfService.getOntLabel(format);
279-
wfInput.setType(wfInput.getType() + " (" + formatLabel + " format)");
272+
setFormat(wfInput, format);
280273
}
281274
if (input.contains("label")) {
282275
wfInput.setLabel(input.get("label").toString());
@@ -338,15 +331,7 @@ public Workflow parseWorkflowWithCwltool(GithubDetails githubInfo,
338331
}
339332
if (output.contains("format")) {
340333
String format = output.get("format").toString();
341-
wfOutput.setFormat(format);
342-
343-
if (!rdfService.ontPropertyExists(format)) {
344-
Model ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
345-
ontModel.read(format, null, "RDF/XML");
346-
rdfService.addToOntologies(ontModel);
347-
}
348-
String formatLabel = rdfService.getOntLabel(format);
349-
wfOutput.setType(wfOutput.getType() + " (" + formatLabel + " format)");
334+
setFormat(wfOutput, format);
350335
}
351336
if (output.contains("label")) {
352337
wfOutput.setLabel(output.get("label").toString());
@@ -492,6 +477,26 @@ public WorkflowOverview getWorkflowOverview(GithubDetails githubInfo) throws IOE
492477

493478
}
494479

480+
/**
481+
* Set the format for an input or output, handling ontologies
482+
* @param inputOutput The input or output CWL Element
483+
* @param format The format URI
484+
*/
485+
private void setFormat(CWLElement inputOutput, String format) {
486+
inputOutput.setFormat(format);
487+
try {
488+
if (!rdfService.ontPropertyExists(format)) {
489+
Model ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
490+
ontModel.read(format, null, "RDF/XML");
491+
rdfService.addToOntologies(ontModel);
492+
}
493+
String formatLabel = rdfService.getOntLabel(format);
494+
inputOutput.setType(inputOutput.getType() + " (" + formatLabel + " format)");
495+
} catch (RiotException ex) {
496+
inputOutput.setType(inputOutput.getType() + " (format)");
497+
}
498+
}
499+
495500
/**
496501
* Convert RDF URI for a type to a name
497502
* @param uri The URI for the type

src/main/resources/templates/workflow.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ <h2>Inputs</h2>
199199
<tr th:each="input : ${workflow.inputs}">
200200
<td th:text="${input.key}">ID</td>
201201
<td>
202-
<a th:href="@{${input.value.format}}" th:text="${input.value.type}">Type</a>
202+
<a th:href="@{${input.value.format}}" th:text="${input.value.type}" target="_blank" rel="noopener">Type</a>
203203
</td>
204204
<td th:text="${input.value.label}">Label</td>
205205
<td>

0 commit comments

Comments
 (0)