Skip to content

Commit b508ff8

Browse files
author
Mark Robinson
committed
Fix parsing for default values in CWL V1.0
1 parent 312e27d commit b508ff8

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/main/java/org/commonwl/viewer/domain/CWLCollection.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public class CWLCollection {
7272
private final String DESCRIPTION = "description";
7373
private final String ARRAY = "array";
7474
private final String ARRAY_ITEMS = "items";
75+
private final String LOCATION = "location";
7576

7677
/**
7778
* Creates a new collection of CWL files from a Github repository
@@ -275,13 +276,22 @@ private Map<String, CWLElement> getStepInputsOutputs(JsonNode inOut) {
275276

276277
if (inOut.getClass() == ArrayNode.class) {
277278
// array<WorkflowStepInput>
279+
int test = 1;
278280
} else if (inOut.getClass() == ObjectNode.class) {
279281
// map<WorkflowStepInput.id, WorkflowStepInput.source>
280282
Iterator<Map.Entry<String, JsonNode>> iterator = inOut.fields();
281283
while (iterator.hasNext()) {
282284
Map.Entry<String, JsonNode> inOutNode = iterator.next();
283285
CWLElement inputOutput = new CWLElement();
284-
inputOutput.addSourceID(stepIDFromSource(inOutNode.getValue().asText()));
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+
}
285295
returnMap.put(inOutNode.getKey(), inputOutput);
286296
}
287297
}
@@ -379,7 +389,11 @@ private String extractLabel(JsonNode node) {
379389
*/
380390
private String extractDefault(JsonNode node) {
381391
if (node != null && node.has(DEFAULT)) {
382-
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+
}
383397
}
384398
return null;
385399
}
@@ -425,7 +439,7 @@ private List<String> extractOutputSource(JsonNode node) {
425439
* @return The step ID
426440
*/
427441
private String stepIDFromSource(String source) {
428-
if (source != null) {
442+
if (source != null && source.length() > 0) {
429443
// Strip leading # if it exists
430444
if (source.charAt(0) == '#') {
431445
source = source.substring(1);

0 commit comments

Comments
 (0)