3131import org .apache .jena .query .ResultSet ;
3232import org .apache .jena .rdf .model .Model ;
3333import org .apache .jena .rdf .model .ModelFactory ;
34- import org .apache .jena .rdf .model .Statement ;
35- import org .apache .jena .rdf .model .StmtIterator ;
3634import org .apache .jena .riot .RiotException ;
3735import org .commonwl .view .docker .DockerService ;
3836import org .commonwl .view .git .GitDetails ;
@@ -232,42 +230,18 @@ public Workflow parseWorkflowWithCwltool(Workflow basicModel,
232230 String inputName = rdfService .stepNameFromURI (gitPath , input .get ("name" ).toString ());
233231
234232 CWLElement wfInput = new CWLElement ();
235-
236- // Array types
237233 if (input .contains ("type" )) {
238- StmtIterator itr = input .get ("type" ).asResource ().listProperties ();
239- if (itr .hasNext ()) {
240- while (itr .hasNext ()) {
241- Statement complexType = itr .nextStatement ();
242- if (complexType .getPredicate ().toString ()
243- .equals ("https://w3id.org/cwl/salad#items" )) {
244- if (wfInputs .containsKey (inputName )
245- && wfInputs .get (inputName ).getType ().equals ("?" )) {
246- wfInput .setType (typeURIToString (complexType .getObject ().toString ()) + "[]?" );
247- } else {
248- wfInput .setType (typeURIToString (complexType .getObject ().toString ()) + "[]" );
249- }
250- }
251- }
234+ String type ;
235+ if (input .get ("type" ).toString ().equals ("https://w3id.org/cwl/salad#array" )) {
236+ type = typeURIToString (input .get ("items" ).toString ()) + "[]" ;
252237 } else {
253- // Optional types
254- if (input .get ("type" ).toString ().equals ("https://w3id.org/cwl/salad#null" )) {
255- if (wfInputs .containsKey (inputName )) {
256- CWLElement inputInMap = wfInputs .get (inputName );
257- inputInMap .setType (inputInMap .getType () + "?" );
258- } else {
259- wfInput .setType ("?" );
260- }
261- } else if (wfInput .getType () != null && wfInput .getType ().equals ("?" )
262- && !wfInput .getType ().endsWith ("[]" )) {
263- wfInput .setType (typeURIToString (input .get ("type" ).toString ()) + "?" );
264- } else {
265- // Standard type
266- wfInput .setType (typeURIToString (input .get ("type" ).toString ()));
267- }
238+ type = typeURIToString (input .get ("type" ).toString ());
239+ }
240+ if (input .contains ("null" )) {
241+ type += " (Optional)" ;
268242 }
243+ wfInput .setType (type );
269244 }
270-
271245 if (input .contains ("format" )) {
272246 String format = input .get ("format" ).toString ();
273247 setFormat (wfInput , format );
@@ -289,41 +263,17 @@ public Workflow parseWorkflowWithCwltool(Workflow basicModel,
289263 CWLElement wfOutput = new CWLElement ();
290264
291265 String outputName = rdfService .stepNameFromURI (gitPath , output .get ("name" ).toString ());
292-
293- // Array types
294266 if (output .contains ("type" )) {
295- StmtIterator itr = output .get ("type" ).asResource ().listProperties ();
296- if (itr .hasNext ()) {
297- while (itr .hasNext ()) {
298- Statement complexType = itr .nextStatement ();
299- if (complexType .getPredicate ().toString ()
300- .equals ("https://w3id.org/cwl/salad#items" )) {
301- if (wfOutputs .containsKey (outputName )
302- && wfOutputs .get (outputName ).getType ().equals ("?" )) {
303- wfOutput .setType (typeURIToString (complexType .getObject ().toString ()) + "[]?" );
304- } else {
305- wfOutput .setType (typeURIToString (complexType .getObject ().toString ()) + "[]" );
306- }
307- }
308- }
267+ String type ;
268+ if (output .get ("type" ).toString ().equals ("https://w3id.org/cwl/salad#array" )) {
269+ type = typeURIToString (output .get ("items" ).toString ()) + "[]" ;
309270 } else {
310- // Standard types
311- if (wfOutput .getType () != null && wfOutput .getType ().equals ("?" )) {
312- wfOutput .setType (typeURIToString (output .get ("type" ).toString ()) + "?" );
313- } else {
314- wfOutput .setType (typeURIToString (output .get ("type" ).toString ()));
315- }
316-
317- // Optional types
318- if (output .get ("type" ).toString ().equals ("https://w3id.org/cwl/salad#null" )) {
319- if (wfOutputs .containsKey (outputName )) {
320- CWLElement outputInMap = wfOutputs .get (outputName );
321- outputInMap .setType (outputInMap .getType () + "?" );
322- } else {
323- wfOutput .setType ("?" );
324- }
325- }
271+ type = typeURIToString (output .get ("type" ).toString ());
272+ }
273+ if (output .contains ("null" )) {
274+ type += " (Optional)" ;
326275 }
276+ wfOutput .setType (type );
327277 }
328278
329279 if (output .contains ("src" )) {
0 commit comments