4040import org .apache .jena .query .ResultSet ;
4141import org .apache .jena .rdf .model .Model ;
4242import org .apache .jena .rdf .model .ModelFactory ;
43- import org .apache .jena .rdf .model .Statement ;
44- import org .apache .jena .rdf .model .StmtIterator ;
4543import org .apache .jena .riot .RiotException ;
4644import org .commonwl .view .docker .DockerService ;
4745import 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
0 commit comments