Skip to content

Commit 2ac32b0

Browse files
author
Mark Robinson
committed
Add different coloured graph steps for workflow elements
1 parent b6189a0 commit 2ac32b0

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ public Workflow(String label, String doc, Map<String, CWLElement> inputs,
8181
this.outputs = outputs;
8282
this.steps = steps;
8383
this.dockerLink = dockerLink;
84+
}
8485

85-
// Create a DOT graph for this workflow and store it
86+
/**
87+
* Create a DOT graph for this workflow and store it
88+
*/
89+
public void generateDOT() {
8690
StringWriter graphWriter = new StringWriter();
8791
DotWriter dotWriter = new DotWriter(graphWriter);
8892
try {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ public Workflow getWorkflow() {
277277
Workflow workflowModel = new Workflow(label, extractDoc(mainWorkflow), getInputs(mainWorkflow),
278278
getOutputs(mainWorkflow), getSteps(mainWorkflow), getDockerLink(mainWorkflow));
279279
fillStepRunTypes(workflowModel);
280+
workflowModel.generateDOT();
280281
return workflowModel;
281282
}
282283

@@ -298,6 +299,13 @@ private void fillStepRunTypes(Workflow workflow) {
298299
if (cwlDocs.containsKey(filePath.toString())) {
299300
JsonNode runDoc = cwlDocs.get(filePath.toString());
300301
step.setRunType(extractProcess(runDoc));
302+
// Set label/doc from linked document if none exists for step
303+
if (step.getLabel() == null) {
304+
step.setLabel(extractLabel(runDoc));
305+
}
306+
if (step.getDoc() == null) {
307+
step.setDoc(extractDoc(runDoc));
308+
}
301309
}
302310
}
303311
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.commonwl.viewer.domain.Workflow;
2323
import org.commonwl.viewer.domain.cwl.CWLElement;
24+
import org.commonwl.viewer.domain.cwl.CWLProcess;
2425
import org.commonwl.viewer.domain.cwl.CWLStep;
2526

2627
import java.io.IOException;
@@ -152,9 +153,13 @@ private void writeOutputs(Workflow workflow) throws IOException {
152153
* @throws IOException Any errors in writing which may have occurred
153154
*/
154155
private void writeSteps(Workflow workflow) throws IOException {
155-
// Write each of the steps as a node
156+
// Write each of the steps as a node or subgraph if it is a nested workflow
156157
for (Map.Entry<String, CWLStep> step : workflow.getSteps().entrySet()) {
157-
writeLine(" \"" + step.getKey() + "\"");
158+
if (step.getValue().getRunType() == CWLProcess.WORKFLOW) {
159+
writeLine(" \"" + step.getKey() + "\" [fillcolor=\"#F3CEA1\"];");
160+
} else {
161+
writeLine(" \"" + step.getKey() + "\";");
162+
}
158163
}
159164

160165
// Write the links between nodes

0 commit comments

Comments
 (0)