@@ -267,7 +267,7 @@ private CWLElement getDetails(JsonNode inputOutput) {
267
267
} else {
268
268
details .setLabel (extractLabel (inputOutput ));
269
269
details .setDoc (extractDoc (inputOutput ));
270
- details . addSourceID ( extractOutputSource (inputOutput ));
270
+ extractOutputSource (inputOutput ). forEach ( details :: addSourceID );
271
271
details .setDefaultVal (extractDefault (inputOutput ));
272
272
273
273
// Type is only for inputs
@@ -318,38 +318,66 @@ private String extractDefault(JsonNode node) {
318
318
}
319
319
320
320
/**
321
- * Extract the outputSource from a node
322
- * @param node The node to have the label extracted from
323
- * @return The string for the outputSource of the node
321
+ * Extract the source or outputSource from a node
322
+ * @param node The node to have the sources extracted from
323
+ * @return A list of strings for the sources
324
324
*/
325
- private String extractOutputSource (JsonNode node ) {
325
+ private List < String > extractOutputSource (JsonNode node ) {
326
326
if (node != null ) {
327
- String source = null ;
327
+ List <String > sources = new ArrayList <String >();
328
+ JsonNode sourceNode = null ;
329
+
330
+ // outputSource and source treated the same
328
331
if (node .has ("outputSource" )) {
329
- source = node .get ("outputSource" ). asText ( );
332
+ sourceNode = node .get ("outputSource" );
330
333
} else if (node .has ("source" )) {
331
- source = node .get ("source" ). asText ( );
334
+ sourceNode = node .get ("source" );
332
335
}
333
336
334
- // Get step ID from a SALAD ID
335
- if (source != null ) {
336
- // Strip leading # if it exists
337
- if (source .charAt (0 ) == '#' ) {
338
- source = source .substring (1 );
337
+ if (sourceNode != null ) {
338
+ // Single source
339
+ if (sourceNode .getClass () == TextNode .class ) {
340
+ sources .add (stepIDFromSource (sourceNode .asText ()));
339
341
}
340
-
341
- // Get segment before / (step ID)
342
- int slashSplit = source . indexOf ( "/" );
343
- if ( slashSplit != - 1 ) {
344
- source = source . substring ( 0 , slashSplit );
342
+ // Can be an array of multiple sources
343
+ if ( sourceNode . getClass () == ArrayNode . class ) {
344
+ for ( JsonNode source : sourceNode ) {
345
+ sources . add ( stepIDFromSource ( source . asText ()));
346
+ }
345
347
}
346
348
}
347
349
348
- return source ;
350
+ return sources ;
349
351
}
350
352
return null ;
351
353
}
352
354
355
+ /**
356
+ * Gets just the step ID from source of format 'stepID/outputID'
357
+ * @param source The source
358
+ * @return The step ID
359
+ */
360
+ private String stepIDFromSource (String source ) {
361
+ if (source != null ) {
362
+ // Strip leading # if it exists
363
+ if (source .charAt (0 ) == '#' ) {
364
+ source = source .substring (1 );
365
+ }
366
+
367
+ // Get segment before / (step ID)
368
+ int slashSplit = source .indexOf ("/" );
369
+ if (slashSplit != -1 ) {
370
+ source = source .substring (0 , slashSplit );
371
+ } else {
372
+ int dotSplit = source .indexOf ("." );
373
+ if (dotSplit != -1 ) {
374
+ source = "#" + source .substring (0 , dotSplit );
375
+ }
376
+ }
377
+ }
378
+ return source ;
379
+ }
380
+
353
381
/**
354
382
* Extract the doc or description from a node
355
383
* @param node The node to have the doc/description extracted from
0 commit comments