Skip to content

Commit 17ded37

Browse files
author
Mark Robinson
committed
Add simple v1 'in' parameter step parsing
1 parent b4dd88d commit 17ded37

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

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

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,13 @@ private Map<String, CWLStep> getSteps(JsonNode cwlDoc) {
236236
*/
237237
private Map<String, CWLElement> getInputs(JsonNode cwlDoc) {
238238
if (cwlDoc != null) {
239+
Map<String, CWLElement> inputsOutputs = null;
239240
if (cwlDoc.has(INPUTS)) {
240-
// For workflow
241+
// For workflow/draft steps
241242
return getInputsOutputs(cwlDoc.get(INPUTS));
242243
} 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));
245246
}
246247
}
247248
return null;
@@ -255,16 +256,40 @@ private Map<String, CWLElement> getInputs(JsonNode cwlDoc) {
255256
private Map<String, CWLElement> getOutputs(JsonNode cwlDoc) {
256257
if (cwlDoc != null) {
257258
if (cwlDoc.has(OUTPUTS)) {
258-
// For workflow
259+
// For workflow/draft steps
259260
return getInputsOutputs(cwlDoc.get(OUTPUTS));
260261
} 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));
263264
}
264265
}
265266
return null;
266267
}
267268

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+
} else if (inOut.getClass() == ObjectNode.class) {
280+
// map<WorkflowStepInput.id, WorkflowStepInput.source>
281+
Iterator<Map.Entry<String, JsonNode>> iterator = inOut.fields();
282+
while (iterator.hasNext()) {
283+
Map.Entry<String, JsonNode> inOutNode = iterator.next();
284+
CWLElement input = new CWLElement();
285+
input.addSourceID(stepIDFromSource(inOutNode.getValue().asText()));
286+
returnMap.put(inOutNode.getKey(), input);
287+
}
288+
}
289+
290+
return returnMap;
291+
}
292+
268293
/**
269294
* Get inputs or outputs from an inputs or outputs node
270295
* @param inputsOutputs The inputs or outputs node

0 commit comments

Comments
 (0)