Skip to content

Commit a888c09

Browse files
author
Mark Robinson
committed
Add support for multiple outputs->one input in data structures
1 parent 98dfaad commit a888c09

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private CWLElement getDetails(JsonNode inputOutput) {
267267
} else {
268268
details.setLabel(extractLabel(inputOutput));
269269
details.setDoc(extractDoc(inputOutput));
270-
details.setSourceID(extractOutputSource(inputOutput));
270+
details.addSourceID(extractOutputSource(inputOutput));
271271
details.setDefaultVal(extractDefault(inputOutput));
272272

273273
// Type is only for inputs

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,24 @@
1919

2020
package org.commonwl.viewer.domain;
2121

22+
import java.util.ArrayList;
23+
import java.util.List;
24+
2225
/**
23-
* Represents the input/output/step of a workflow/tool
26+
* Represents the input/output of a workflow/tool
2427
*/
2528
public class CWLElement {
2629

2730
private String label;
2831
private String doc;
2932
private String type;
30-
private String sourceID;
33+
private List<String> sourceID;
3134
private String defaultVal;
3235

36+
public CWLElement() {
37+
this.sourceID = new ArrayList<String>();
38+
}
39+
3340
public String getLabel() {
3441
return label;
3542
}
@@ -54,12 +61,14 @@ public void setType(String type) {
5461
this.type = type;
5562
}
5663

57-
public String getSourceID() {
64+
public List<String> getSourceIDs() {
5865
return sourceID;
5966
}
6067

61-
public void setSourceID(String sourceID) {
62-
this.sourceID = sourceID;
68+
public void addSourceID(String sourceID) {
69+
if (sourceID != null) {
70+
this.sourceID.add(sourceID);
71+
}
6372
}
6473

6574
public String getDefaultVal() {

src/main/java/org/commonwl/viewer/services/DotWriter.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,31 @@ private void writeSteps(Workflow workflow) throws IOException {
160160
// Write the links between nodes
161161
// Write links between outputs and penultimate steps
162162
for (Map.Entry<String, CWLElement> output : workflow.getOutputs().entrySet()) {
163-
writeLine(" \"" + output.getValue().getSourceID() + "\" -> \"" + output.getKey() + "\";");
163+
for (String sourceID : output.getValue().getSourceIDs()) {
164+
writeLine(" \"" + sourceID + "\" -> \"" + output.getKey() + "\";");
165+
}
164166
}
165167

166168
// Write links between the remaining steps
167169
int defaultCount = 0;
168170
for (Map.Entry<String, CWLStep> step : workflow.getSteps().entrySet()) {
169171
if (step.getValue().getInputs() != null) {
170172
for (Map.Entry<String, CWLElement> input : step.getValue().getInputs().entrySet()) {
171-
String sourceID = input.getValue().getSourceID();
173+
List<String> sourceIDs = input.getValue().getSourceIDs();
174+
175+
// Draw the default value on the graph if there are no step inputs (it is a constant)
172176
String defaultVal = input.getValue().getDefaultVal();
173-
if (sourceID != null) {
174-
// Regular link from source step to destination step
175-
writeLine(" \"" + sourceID + "\" -> \"" + step.getKey() + "\";");
176-
} else if (defaultVal != null) {
177+
if (sourceIDs.isEmpty() && defaultVal != null) {
177178
// New node for a default value to be used as the source
178179
defaultCount++;
179180
writeLine(" \"default" + defaultCount + "\" [label=\"" + defaultVal + "\", fillcolor=\"#D5AEFC\"]");
180181
writeLine(" \"default" + defaultCount + "\" -> \"" + step.getKey() + "\";");
181182
}
183+
184+
// Otherwise write regular links from source step to destination step
185+
for (String sourceID : sourceIDs) {
186+
writeLine(" \"" + sourceID + "\" -> \"" + step.getKey() + "\";");
187+
}
182188
}
183189
}
184190
}

0 commit comments

Comments
 (0)