|
33 | 33 | import org.apache.jena.rdf.model.ModelFactory;
|
34 | 34 | import org.apache.jena.rdf.model.Statement;
|
35 | 35 | import org.apache.jena.rdf.model.StmtIterator;
|
| 36 | +import org.apache.jena.riot.RiotException; |
36 | 37 | import org.commonwl.view.docker.DockerService;
|
37 | 38 | import org.commonwl.view.github.GitHubService;
|
38 | 39 | import org.commonwl.view.github.GithubDetails;
|
@@ -268,15 +269,7 @@ public Workflow parseWorkflowWithCwltool(GithubDetails githubInfo,
|
268 | 269 |
|
269 | 270 | if (input.contains("format")) {
|
270 | 271 | 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); |
280 | 273 | }
|
281 | 274 | if (input.contains("label")) {
|
282 | 275 | wfInput.setLabel(input.get("label").toString());
|
@@ -338,15 +331,7 @@ public Workflow parseWorkflowWithCwltool(GithubDetails githubInfo,
|
338 | 331 | }
|
339 | 332 | if (output.contains("format")) {
|
340 | 333 | 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); |
350 | 335 | }
|
351 | 336 | if (output.contains("label")) {
|
352 | 337 | wfOutput.setLabel(output.get("label").toString());
|
@@ -492,6 +477,26 @@ public WorkflowOverview getWorkflowOverview(GithubDetails githubInfo) throws IOE
|
492 | 477 |
|
493 | 478 | }
|
494 | 479 |
|
| 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 | + |
495 | 500 | /**
|
496 | 501 | * Convert RDF URI for a type to a name
|
497 | 502 | * @param uri The URI for the type
|
|
0 commit comments