Skip to content

Commit 27bf76a

Browse files
authored
Merge pull request #52 from common-workflow-language/hotfix-array-inout
Add support for ArrayNode in/out representation
2 parents 35bb7d6 + ddf0684 commit 27bf76a

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,20 @@ private Map<String, CWLElement> getStepInputsOutputs(JsonNode inOut) {
276276

277277
if (inOut.getClass() == ArrayNode.class) {
278278
// array<WorkflowStepInput>
279-
int test = 1;
279+
for (JsonNode inOutNode : inOut) {
280+
if (inOutNode.getClass() == ObjectNode.class) {
281+
CWLElement inputOutput = new CWLElement();
282+
List<String> sources = extractSource(inOutNode);
283+
if (sources.size() > 0) {
284+
for (String source : sources) {
285+
inputOutput.addSourceID(source);
286+
}
287+
} else {
288+
inputOutput.setDefaultVal(extractDefault(inOutNode));
289+
}
290+
returnMap.put(extractID(inOutNode), inputOutput);
291+
}
292+
}
280293
} else if (inOut.getClass() == ObjectNode.class) {
281294
// map<WorkflowStepInput.id, WorkflowStepInput.source>
282295
Iterator<Map.Entry<String, JsonNode>> iterator = inOut.fields();
@@ -340,7 +353,7 @@ private CWLElement getDetails(JsonNode inputOutput) {
340353
} else {
341354
details.setLabel(extractLabel(inputOutput));
342355
details.setDoc(extractDoc(inputOutput));
343-
extractOutputSource(inputOutput).forEach(details::addSourceID);
356+
extractSource(inputOutput).forEach(details::addSourceID);
344357
details.setDefaultVal(extractDefault(inputOutput));
345358

346359
// Type is only for inputs
@@ -403,7 +416,7 @@ private String extractDefault(JsonNode node) {
403416
* @param node The node to have the sources extracted from
404417
* @return A list of strings for the sources
405418
*/
406-
private List<String> extractOutputSource(JsonNode node) {
419+
private List<String> extractSource(JsonNode node) {
407420
if (node != null) {
408421
List<String> sources = new ArrayList<String>();
409422
JsonNode sourceNode = null;

0 commit comments

Comments
 (0)