Author: bfoster
Date: Tue Mar 1 18:27:24 2011
New Revision: 1075968
URL: http://svn.apache.org/viewvc?rev=1075968&view=rev
Log:
- added ability to trace worklfows connected by using the new
WorkflowConnectTaskInstance
---------------------------
Added:
oodt/branches/wengine-branch/wengine/src/main/java/org/apache/oodt/cas/workflow/server/action/TraceWorkflow.java
(with props)
Modified:
oodt/branches/wengine-branch/wengine/src/main/resources/policy/action-beans.xml
oodt/branches/wengine-branch/wengine/src/main/resources/policy/engine-client-cmd-line-beans.xml
Added:
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=1075968&view=auto
==============================================================================
---
oodt/branches/wengine-branch/wengine/src/main/java/org/apache/oodt/cas/workflow/server/action/TraceWorkflow.java
(added)
+++
oodt/branches/wengine-branch/wengine/src/main/java/org/apache/oodt/cas/workflow/server/action/TraceWorkflow.java
Tue Mar 1 18:27:24 2011
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.cas.workflow.server.action;
+
+//JDK imports
+import java.util.Vector;
+
+//OODT imports
+import org.apache.oodt.cas.metadata.Metadata;
+import org.apache.oodt.cas.workflow.engine.WorkflowEngineClient;
+import org.apache.oodt.cas.workflow.exceptions.EngineException;
+import org.apache.oodt.cas.workflow.instance.WorkflowConnectTaskInstance;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ *
+ * <p>
+ * Trace workflows connected to workflow with given InstanceId
+ * <p>
+ */
+public class TraceWorkflow extends WorkflowEngineServerAction {
+
+ private String instanceId;
+ public enum Mode { COMPLETE, RELATIVES, CHILDREN };
+ private Mode mode;
+
+ @Override
+ public void performAction(WorkflowEngineClient weClient) throws
Exception {
+ System.out.println("Workflow Trace [InstanceId='" +
this.instanceId + "']");
+ if (this.mode.equals(Mode.COMPLETE) ||
this.mode.equals(Mode.RELATIVES)) {
+ Vector<String> parents = new Vector<String>();
+ String currentInstanceId = this.instanceId;
+ String parentWorkflowInstanceId = null;
+ do {
+ if (parentWorkflowInstanceId != null) {
+ currentInstanceId =
parentWorkflowInstanceId;
+ parents.add(parentWorkflowInstanceId);
+ }
+ parentWorkflowInstanceId =
weClient.getWorkflowMetadata(currentInstanceId).getMetadata(WorkflowConnectTaskInstance.SPAWNED_BY_WORKFLOW);
+ }while(parentWorkflowInstanceId != null);
+ if (this.mode.equals(Mode.RELATIVES)) {
+ String index = "";
+ for (String parent : parents) {
+ System.out.println(index + " -
InstanceId = '" + parent + " : State = '" +
weClient.getWorkflowState(parent).getName() + "'");
+ index += " ";
+ }
+ this.printTree(weClient, currentInstanceId,
index);
+ }else if (this.mode.equals(Mode.COMPLETE)) {
+ this.printTree(weClient, currentInstanceId, "");
+ }
+ }else if (this.mode.equals(Mode.CHILDREN)){
+ this.printTree(weClient, this.instanceId, "");
+ }
+ }
+
+ private void printTree(WorkflowEngineClient weClient, String
instanceId, String indent) throws EngineException {
+ System.out.println(indent + " - InstanceId = '" + instanceId +
"' : State = '" + weClient.getWorkflowState(instanceId).getName() + "'");
+ Metadata metadata = weClient.getWorkflowMetadata(instanceId);
+ for (String child :
metadata.getAllMetadata(WorkflowConnectTaskInstance.SPAWNED_WORKFLOWS))
+ this.printTree(weClient, child, indent + " ");
+ }
+
+ public void setInstanceId(String instanceId) {
+ this.instanceId = instanceId;
+ }
+
+ public void setMode(String mode) {
+ this.mode = Mode.valueOf(mode);
+ }
+
+}
Propchange:
oodt/branches/wengine-branch/wengine/src/main/java/org/apache/oodt/cas/workflow/server/action/TraceWorkflow.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
oodt/branches/wengine-branch/wengine/src/main/resources/policy/action-beans.xml
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/wengine/src/main/resources/policy/action-beans.xml?rev=1075968&r1=1075967&r2=1075968&view=diff
==============================================================================
---
oodt/branches/wengine-branch/wengine/src/main/resources/policy/action-beans.xml
(original)
+++
oodt/branches/wengine-branch/wengine/src/main/resources/policy/action-beans.xml
Tue Mar 1 18:27:24 2011
@@ -62,6 +62,9 @@
<bean id="DescribeWorkflow" lazy-init="true"
class="org.apache.oodt.cas.workflow.server.action.DescribeWorkflow">
<property name="description" value="Prints out no-recur
processor skeleton descripting info"/>
</bean>
+ <bean id="TraceWorkflow" lazy-init="true"
class="org.apache.oodt.cas.workflow.server.action.TraceWorkflow">
+ <property name="description" value="Trace workflows connected
to workflow with given InstanceId"/>
+ </bean>
<bean id="DeleteWorkflow" lazy-init="true"
class="org.apache.oodt.cas.workflow.server.action.DeleteWorkflow">
<property name="description" value="Deletes Workflow and Task
Instances"/>
</bean>
Modified:
oodt/branches/wengine-branch/wengine/src/main/resources/policy/engine-client-cmd-line-beans.xml
URL:
http://svn.apache.org/viewvc/oodt/branches/wengine-branch/wengine/src/main/resources/policy/engine-client-cmd-line-beans.xml?rev=1075968&r1=1075967&r2=1075968&view=diff
==============================================================================
---
oodt/branches/wengine-branch/wengine/src/main/resources/policy/engine-client-cmd-line-beans.xml
(original)
+++
oodt/branches/wengine-branch/wengine/src/main/resources/policy/engine-client-cmd-line-beans.xml
Tue Mar 1 18:27:24 2011
@@ -156,6 +156,7 @@
<value>DeleteWorkflow</value>
<value>ChangeWorkflowState</value>
<value>ChangeWorkflowPriority</value>
+
<value>TraceWorkflow</value>
</list>
</property>
</bean>
@@ -170,6 +171,7 @@
<bean
class="org.apache.oodt.commons.option.handler.BeanInfo"
p:bean-ref="DeleteWorkflow"/>
<bean
class="org.apache.oodt.commons.option.handler.BeanInfo"
p:bean-ref="ChangeWorkflowState"/>
<bean
class="org.apache.oodt.commons.option.handler.BeanInfo"
p:bean-ref="ChangeWorkflowPriority"/>
+ <bean
class="org.apache.oodt.commons.option.handler.BeanInfo"
p:bean-ref="TraceWorkflow"/>
</list>
</property>
</bean>
@@ -419,6 +421,36 @@
</property>
</bean>
+ <bean id="mode" lazy-init="true"
class="org.apache.oodt.commons.option.CmdLineOption">
+ <property name="shortOption" value="md"/>
+ <property name="longOption" value="mode"/>
+ <property name="description" value="Mode Name"/>
+ <property name="hasArgs" value="true"/>
+ <property name="optionArgName"
value="Complete|Relatives|Children"/>
+ <property name="requiredOptions">
+ <list>
+ <bean
class="org.apache.oodt.commons.option.required.RequiredOption">
+ <property name="optionLongName"
value="action"/>
+ <property name="requireAllValues"
value="false"/>
+ <property name="optionValues">
+ <list>
+
<value>TraceWorkflow</value>
+ </list>
+ </property>
+ </bean>
+ </list>
+ </property>
+ <property name="handler">
+ <bean
class="org.apache.oodt.commons.option.handler.CmdLineOptionBeanHandler">
+ <property name="applyToBeans">
+ <list>
+ <bean
class="org.apache.oodt.commons.option.handler.BeanInfo"
p:bean-ref="TraceWorkflow"/>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+
<bean id="priority" lazy-init="true"
class="org.apache.oodt.commons.option.CmdLineOption">
<property name="shortOption" value="p"/>
<property name="longOption" value="priority"/>