Author: bfoster
Date: Thu Mar 3 22:19:21 2011
New Revision: 1076838
URL: http://svn.apache.org/viewvc?rev=1076838&view=rev
Log:
- updates to TraceWorkflow
----------------------------
Modified:
oodt/branches/wengine-branch/wengine/src/main/java/org/apache/oodt/cas/workflow/server/action/TraceWorkflow.java
Modified:
oodt/branches/wengine-branch/wengine/src/main/java/org/apache/oodt/cas/workflow/server/action/TraceWorkflow.java
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/wengine/src/main/java/org/apache/oodt/cas/workflow/server/action/TraceWorkflow.java?rev=1076838&r1=1076837&r2=1076838&view=diff
==============================================================================
---
oodt/branches/wengine-branch/wengine/src/main/java/org/apache/oodt/cas/workflow/server/action/TraceWorkflow.java
(original)
+++
oodt/branches/wengine-branch/wengine/src/main/java/org/apache/oodt/cas/workflow/server/action/TraceWorkflow.java
Thu Mar 3 22:19:21 2011
@@ -40,6 +40,11 @@ public class TraceWorkflow extends Workf
private String instanceId;
public enum Mode { COMBINED, COMPLETE, RELATIVES, CHILDREN };
private Mode mode;
+ private boolean firstRun;
+
+ public TraceWorkflow() {
+ this.firstRun = true;
+ }
@Override
public void performAction(WorkflowEngineClient weClient) throws
Exception {
@@ -66,14 +71,14 @@ public class TraceWorkflow extends Workf
}
this.printTree(weClient, this.instanceId,
(parentSkeleton != null ? parentSkeleton.getModelId() : null), indent);
}else if (this.mode.equals(Mode.COMPLETE)) {
- this.printTree(weClient, currentInstanceId,
null, "");
+ this.printTree(weClient, currentInstanceId,
null);
}else if (this.mode.equals(Mode.COMBINED)) {
ProcessorSkeleton skeleton =
weClient.getWorkflow(currentInstanceId);
buildMasterWorkflow(weClient, skeleton);
System.out.println(WorkflowUtils.toString(skeleton));
}
}else if (this.mode.equals(Mode.CHILDREN)){
- this.printTree(weClient, this.instanceId, null, "");
+ this.printTree(weClient, this.instanceId, null);
}
}
@@ -91,15 +96,20 @@ public class TraceWorkflow extends Workf
task.setSubProcessors(subProcessors);
}
}
-
+
+ private void printTree(WorkflowEngineClient weClient, String
instanceId, String parentModelId) throws EngineException {
+ this.printTree(weClient, instanceId, parentModelId, "");
+ }
+
private void printTree(WorkflowEngineClient weClient, String
instanceId, String parentModelId, String indent) throws EngineException {
ProcessorSkeleton skeleton = weClient.getWorkflow(instanceId);
- System.out.println(indent + (this.instanceId.equals(instanceId)
? "*" : "[") + "InstanceId = '" + instanceId + "' : ModelId = '" +
skeleton.getModelId() + "' : State = '" + skeleton.getState().getName() + "'" +
(parentModelId != null ? " : SpawnedBy = '" + parentModelId + "'" : "") +
(this.instanceId.equals(instanceId) ? "*" : "]"));
+ if (this.instanceId.equals(instanceId) && this.firstRun) {
this.firstRun = false; indent += " "; }
+ System.out.println((this.instanceId.equals(instanceId) ? " >> "
: indent) + "[InstanceId = '" + instanceId + "' : ModelId = '" +
skeleton.getModelId() + "' : State = '" + skeleton.getState().getName() + "'" +
(parentModelId != null ? " : SpawnedBy = '" + parentModelId + "']" : "]"));
for (ProcessorSkeleton task : WorkflowUtils.getTasks(skeleton))
{
List<String> spawnedWorkflows =
task.getDynamicMetadata().getAllMetadata(WorkflowConnectTaskInstance.SPAWNED_WORKFLOWS);
if (spawnedWorkflows != null)
for (String child : spawnedWorkflows)
- this.printTree(weClient, child,
task.getModelId(), indent + " ");
+ this.printTree(weClient, child,
task.getModelId(), indent + " ");
}
}