Skip to content

Commit 7818a9c

Browse files
authored
Merge pull request #36 from common-workflow-language/v1-step-parsing
V1 step parsing
2 parents b4dd88d + b508ff8 commit 7818a9c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+19317
-2318
lines changed

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

Lines changed: 46 additions & 8 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
@@ -237,11 +238,11 @@ private Map<String, CWLStep> getSteps(JsonNode cwlDoc) {
237238
private Map<String, CWLElement> getInputs(JsonNode cwlDoc) {
238239
if (cwlDoc != 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,49 @@ 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+
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+
268302
/**
269303
* Get inputs or outputs from an inputs or outputs node
270304
* @param inputsOutputs The inputs or outputs node
@@ -355,7 +389,11 @@ private String extractLabel(JsonNode node) {
355389
*/
356390
private String extractDefault(JsonNode node) {
357391
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+
}
359397
}
360398
return null;
361399
}
@@ -401,7 +439,7 @@ private List<String> extractOutputSource(JsonNode node) {
401439
* @return The step ID
402440
*/
403441
private String stepIDFromSource(String source) {
404-
if (source != null) {
442+
if (source != null && source.length() > 0) {
405443
// Strip leading # if it exists
406444
if (source.charAt(0) == '#') {
407445
source = source.substring(1);

src/main/resources/static/bower_components/graphviz-d3-renderer/.bower.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "graphviz-d3-renderer",
3-
"version": "0.9.21",
3+
"version": "0.9.24",
44
"dependencies": {
55
"requirejs": "2.1.15",
66
"d3": "3.5.3",
77
"requirejs-web-workers": "~1.0.1",
8-
"viz.js": "~1.4.1"
8+
"viz.js": "~1.5.1"
99
},
1010
"devDependencies": {
1111
"rfactory": "1.1.0",
@@ -46,11 +46,11 @@
4646
"karma.conf.js"
4747
],
4848
"homepage": "https://github.com/mstefaniuk/graph-viz-d3-js",
49-
"_release": "0.9.21",
49+
"_release": "0.9.24",
5050
"_resolution": {
5151
"type": "version",
52-
"tag": "0.9.21",
53-
"commit": "9cba7e58b832f59e51271f8f98367ab676ef206f"
52+
"tag": "0.9.24",
53+
"commit": "9588a63ee3d5ff651b00a6168340a8b7477b9845"
5454
},
5555
"_source": "https://github.com/mstefaniuk/graph-viz-d3-js.git",
5656
"_target": "^0.9.18",

src/main/resources/static/bower_components/graphviz-d3-renderer/bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "graphviz-d3-renderer",
3-
"version": "0.9.18",
3+
"version": "0.9.24",
44
"dependencies": {
55
"requirejs": "2.1.15",
66
"d3": "3.5.3",
77
"requirejs-web-workers": "~1.0.1",
8-
"viz.js": "~1.4.1"
8+
"viz.js": "~1.5.1"
99
},
1010
"devDependencies": {
1111
"rfactory": "1.1.0",

0 commit comments

Comments
 (0)