28
28
import java .io .Writer ;
29
29
import java .nio .file .Path ;
30
30
import java .nio .file .Paths ;
31
- import java .util .*;
31
+ import java .util .ArrayList ;
32
+ import java .util .HashSet ;
33
+ import java .util .List ;
34
+ import java .util .Set ;
32
35
33
36
/**
34
37
* Writes GraphViz DOT files from a workflow RDF model
35
38
*/
36
39
public class RDFDotWriter extends DotWriter {
37
40
38
41
private RDFService rdfService ;
39
- private Map <String , String > subworkflows = new HashMap <>();
40
42
private String gitPath ;
41
43
42
44
public RDFDotWriter (Writer writer , RDFService rdfService , String gitPath ) {
@@ -133,14 +135,8 @@ private void writeSteps(String workflowUri, boolean subworkflow) throws IOExcept
133
135
// Distinguish nested workflows
134
136
CWLProcess runType = rdfService .strToRuntype (step .get ("runtype" ).toString ());
135
137
if (runType == CWLProcess .WORKFLOW ) {
136
- //if (subworkflow) {
137
- writeLine (" \" " + stepName + "\" [label=\" " + label +
138
- "\" , fillcolor=\" #F3CEA1\" ];" );
139
- /*} else {
140
- String runFile = step.get("run").toString();
141
- subworkflows.put(stepName, FilenameUtils.getName(runFile));
142
- writeSubworkflow(stepName, runFile);
143
- }*/
138
+ writeLine (" \" " + stepName + "\" [label=\" " + label +
139
+ "\" , fillcolor=\" #F3CEA1\" ];" );
144
140
} else {
145
141
writeLine (" \" " + stepName + "\" [label=\" " + label + "\" ];" );
146
142
}
@@ -163,9 +159,9 @@ private void writeStepLinks(String workflowUri) throws IOException {
163
159
QuerySolution stepLink = stepLinks .nextSolution ();
164
160
if (stepLink .contains ("src" )) {
165
161
// Normal link from step
166
- String sourceID = nodeIDFromUri (workflowUri , stepLink .get ("src" ).toString ());
162
+ String sourceID = nodeIDFromUri (stepLink .get ("src" ).toString ());
167
163
String dest = stepLink .get ("dest" ).toString ();
168
- String destID = nodeIDFromUri (workflowUri , dest );
164
+ String destID = nodeIDFromUri (dest );
169
165
String destInput = dest .substring (dest .replaceAll ("#" , "/" ).lastIndexOf ("/" ) + 1 );
170
166
writeLine (" \" " + sourceID + "\" -> \" " + destID + "\" [label=\" " + destInput + "\" ];" );
171
167
} else if (stepLink .contains ("default" )) {
@@ -197,51 +193,19 @@ private void writeStepLinks(String workflowUri) throws IOException {
197
193
ResultSet outputLinks = rdfService .getOutputLinks (gitPath , workflowUri );
198
194
while (outputLinks .hasNext ()) {
199
195
QuerySolution outputLink = outputLinks .nextSolution ();
200
- String sourceID = nodeIDFromUri (workflowUri , outputLink .get ("src" ).toString ());
201
- String destID = nodeIDFromUri (workflowUri , outputLink .get ("dest" ).toString ());
196
+ String sourceID = nodeIDFromUri (outputLink .get ("src" ).toString ());
197
+ String destID = nodeIDFromUri (outputLink .get ("dest" ).toString ());
202
198
writeLine (" \" " + sourceID + "\" -> \" " + destID + "\" ;" );
203
199
}
204
200
}
205
201
206
202
/**
207
203
* Get a node ID from a URI, with ID handling for subworkflows
208
- * @param workflowUri The URI of the workflow in the model
209
204
* @param uri The URI of the step
210
205
* @return A string in the format filename#stepID
211
206
*/
212
- private String nodeIDFromUri (String workflowUri , String uri ) {
213
-
214
- String nodeID = rdfService .stepNameFromURI (gitPath , uri );
215
- if (subworkflows .containsKey (nodeID )) {
216
- int slashAfterHashIndex = uri .indexOf ('/' , uri .lastIndexOf ('#' ));
217
- if (slashAfterHashIndex != -1 ) {
218
- String subworkflowStepID = uri .substring (slashAfterHashIndex + 1 );
219
- nodeID = subworkflows .get (nodeID ) + "#" + subworkflowStepID ;
220
- }
221
- }
222
- return nodeID ;
223
- }
224
-
225
- /**
226
- * Writes a subworkflow as a cluster on the graph
227
- * @param name The name of the step the subworkflow is running in
228
- * @param subWorkflowUri The URI of the subworkflow in the model
229
- */
230
- private void writeSubworkflow (String name , String subWorkflowUri ) throws IOException {
231
-
232
- // Start of subgraph with styling
233
- writeLine (" subgraph \" cluster_" + name + "\" {" );
234
- writeLine (" rank = \" same\" ;" );
235
- writeLine (" style=\" filled,dotted\" ;" );
236
- writeLine (" color=\" black\" ;" );
237
- writeLine (" fillcolor=\" #F9DBB7\" ;" );
238
- writeLine (" label = \" " + rdfService .labelFromName (name ) + "\" ;" );
239
-
240
- writeInputs (subWorkflowUri );
241
- writeSteps (subWorkflowUri , true );
242
- writeOutputs (subWorkflowUri );
243
-
244
- writeLine (" }" );
207
+ private String nodeIDFromUri (String uri ) {
208
+ return rdfService .stepNameFromURI (gitPath , uri );
245
209
}
246
210
247
211
/**
0 commit comments