@@ -72,6 +72,7 @@ public class CWLCollection {
72
72
private final String DESCRIPTION = "description" ;
73
73
private final String ARRAY = "array" ;
74
74
private final String ARRAY_ITEMS = "items" ;
75
+ private final String LOCATION = "location" ;
75
76
76
77
/**
77
78
* Creates a new collection of CWL files from a Github repository
@@ -237,11 +238,11 @@ private Map<String, CWLStep> getSteps(JsonNode cwlDoc) {
237
238
private Map <String , CWLElement > getInputs (JsonNode cwlDoc ) {
238
239
if (cwlDoc != null ) {
239
240
if (cwlDoc .has (INPUTS )) {
240
- // For workflow
241
+ // For workflow/draft steps
241
242
return getInputsOutputs (cwlDoc .get (INPUTS ));
242
243
} else if (cwlDoc .has (IN )) {
243
- // For steps
244
- return getInputsOutputs (cwlDoc .get (IN ));
244
+ // For V1.0 steps
245
+ return getStepInputsOutputs (cwlDoc .get (IN ));
245
246
}
246
247
}
247
248
return null ;
@@ -255,16 +256,49 @@ private Map<String, CWLElement> getInputs(JsonNode cwlDoc) {
255
256
private Map <String , CWLElement > getOutputs (JsonNode cwlDoc ) {
256
257
if (cwlDoc != null ) {
257
258
if (cwlDoc .has (OUTPUTS )) {
258
- // For workflow
259
+ // For workflow/draft steps
259
260
return getInputsOutputs (cwlDoc .get (OUTPUTS ));
260
261
} else if (cwlDoc .has (OUT )) {
261
- // For steps
262
- return getInputsOutputs (cwlDoc .get (OUT ));
262
+ // For V1.0 steps
263
+ return getStepInputsOutputs (cwlDoc .get (OUT ));
263
264
}
264
265
}
265
266
return null ;
266
267
}
267
268
269
+ /**
270
+ * Get inputs or outputs from an in or out node
271
+ * @param inOut The in or out node
272
+ * @return A map of input IDs and details related to them
273
+ */
274
+ private Map <String , CWLElement > getStepInputsOutputs (JsonNode inOut ) {
275
+ Map <String , CWLElement > returnMap = new HashMap <>();
276
+
277
+ if (inOut .getClass () == ArrayNode .class ) {
278
+ // array<WorkflowStepInput>
279
+ int test = 1 ;
280
+ } else if (inOut .getClass () == ObjectNode .class ) {
281
+ // map<WorkflowStepInput.id, WorkflowStepInput.source>
282
+ Iterator <Map .Entry <String , JsonNode >> iterator = inOut .fields ();
283
+ while (iterator .hasNext ()) {
284
+ Map .Entry <String , JsonNode > inOutNode = iterator .next ();
285
+ CWLElement inputOutput = new CWLElement ();
286
+ if (inOutNode .getValue ().getClass () == ObjectNode .class ) {
287
+ inputOutput .setDefaultVal (extractDefault (inOutNode .getValue ()));
288
+ } else if (inOutNode .getValue ().getClass () == ArrayNode .class ) {
289
+ for (JsonNode key : inOutNode .getValue ()) {
290
+ inputOutput .addSourceID (stepIDFromSource (key .asText ()));
291
+ }
292
+ } else {
293
+ inputOutput .addSourceID (stepIDFromSource (inOutNode .getValue ().asText ()));
294
+ }
295
+ returnMap .put (inOutNode .getKey (), inputOutput );
296
+ }
297
+ }
298
+
299
+ return returnMap ;
300
+ }
301
+
268
302
/**
269
303
* Get inputs or outputs from an inputs or outputs node
270
304
* @param inputsOutputs The inputs or outputs node
@@ -355,7 +389,11 @@ private String extractLabel(JsonNode node) {
355
389
*/
356
390
private String extractDefault (JsonNode node ) {
357
391
if (node != null && node .has (DEFAULT )) {
358
- return node .get (DEFAULT ).asText ();
392
+ if (node .get (DEFAULT ).has (LOCATION )) {
393
+ return node .get (DEFAULT ).get (LOCATION ).asText ();
394
+ } else {
395
+ return node .get (DEFAULT ).asText ();
396
+ }
359
397
}
360
398
return null ;
361
399
}
@@ -401,7 +439,7 @@ private List<String> extractOutputSource(JsonNode node) {
401
439
* @return The step ID
402
440
*/
403
441
private String stepIDFromSource (String source ) {
404
- if (source != null ) {
442
+ if (source != null && source . length () > 0 ) {
405
443
// Strip leading # if it exists
406
444
if (source .charAt (0 ) == '#' ) {
407
445
source = source .substring (1 );
0 commit comments