40
40
import org .apache .jena .query .ResultSet ;
41
41
import org .apache .jena .rdf .model .Model ;
42
42
import org .apache .jena .rdf .model .ModelFactory ;
43
- import org .apache .jena .rdf .model .Statement ;
44
- import org .apache .jena .rdf .model .StmtIterator ;
45
43
import org .apache .jena .riot .RiotException ;
46
44
import org .commonwl .view .docker .DockerService ;
47
45
import org .commonwl .view .git .GitDetails ;
@@ -239,42 +237,18 @@ public Workflow parseWorkflowWithCwltool(Workflow basicModel,
239
237
String inputName = rdfService .stepNameFromURI (gitPath , input .get ("name" ).toString ());
240
238
241
239
CWLElement wfInput = new CWLElement ();
242
-
243
- // Array types
244
240
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 ()) + "[]" ;
259
244
} 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)" ;
275
249
}
250
+ wfInput .setType (type );
276
251
}
277
-
278
252
if (input .contains ("format" )) {
279
253
String format = input .get ("format" ).toString ();
280
254
setFormat (wfInput , format );
@@ -296,41 +270,17 @@ public Workflow parseWorkflowWithCwltool(Workflow basicModel,
296
270
CWLElement wfOutput = new CWLElement ();
297
271
298
272
String outputName = rdfService .stepNameFromURI (gitPath , output .get ("name" ).toString ());
299
-
300
- // Array types
301
273
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 ()) + "[]" ;
316
277
} 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)" ;
333
282
}
283
+ wfOutput .setType (type );
334
284
}
335
285
336
286
if (output .contains ("src" )) {
@@ -500,9 +450,9 @@ private void setFormat(CWLElement inputOutput, String format) {
500
450
rdfService .addToOntologies (ontModel );
501
451
}
502
452
String formatLabel = rdfService .getOntLabel (format );
503
- inputOutput .setType (inputOutput .getType () + " ( " + formatLabel + ") " );
453
+ inputOutput .setType (inputOutput .getType () + " [ " + formatLabel + "] " );
504
454
} catch (RiotException ex ) {
505
- inputOutput .setType (inputOutput .getType () + " ( format) " );
455
+ inputOutput .setType (inputOutput .getType () + " [ format] " );
506
456
}
507
457
}
508
458
0 commit comments