summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/lifecycle/instance/Workflow.java
diff options
context:
space:
mode:
Diffstat (limited to 'source/com/c2kernel/lifecycle/instance/Workflow.java')
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/Workflow.java198
1 files changed, 198 insertions, 0 deletions
diff --git a/source/com/c2kernel/lifecycle/instance/Workflow.java b/source/com/c2kernel/lifecycle/instance/Workflow.java
new file mode 100755
index 0000000..a7066d8
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/Workflow.java
@@ -0,0 +1,198 @@
+package com.c2kernel.lifecycle.instance;
+import java.awt.Point;
+import java.util.ArrayList;
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.common.ObjectAlreadyExistsException;
+import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.graph.model.GraphPoint;
+import com.c2kernel.graph.model.TypeNameAndConstructionInfo;
+import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer;
+import com.c2kernel.lifecycle.instance.stateMachine.Transitions;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.persistency.ClusterStorage;
+import com.c2kernel.scripting.ScriptingEngineException;
+import com.c2kernel.utils.Language;
+import com.c2kernel.utils.Logger;
+/**
+ * @version $Revision: 1.64 $ $Date: 2005/09/30 07:09:48 $
+ * @author $Author: abranson $
+ */
+public class Workflow extends CompositeActivity implements C2KLocalObject
+{
+ /** TypeNameAndConstructionInfo[] variables added by Steve */
+ private final TypeNameAndConstructionInfo[] mVertexTypeNameAndConstructionInfo =
+ {
+ new TypeNameAndConstructionInfo(Language.translate("AND Split"), "AndSplit"),
+ new TypeNameAndConstructionInfo(Language.translate("OR Split"), "OrSplit"),
+ new TypeNameAndConstructionInfo(Language.translate("XOR Split"), "XOrSplit"),
+ new TypeNameAndConstructionInfo(Language.translate("Join"), "Join"),
+ new TypeNameAndConstructionInfo(Language.translate("Loop"), "LoopSplit"),
+ new TypeNameAndConstructionInfo(Language.translate("Atomic"), "Atomic"),
+ new TypeNameAndConstructionInfo(Language.translate("Composite"), "Composite")
+ };
+ private final TypeNameAndConstructionInfo[] mEdgeTypeNameAndConstructionInfo =
+ {
+ new TypeNameAndConstructionInfo(Language.translate("Next Edge"), "Next")
+ };
+ /**
+ * @see java.lang.Object#Object()
+ */
+ public Workflow()
+ {
+ getProperties().put("ItemSystemKey", null);
+ }
+
+ public Workflow(CompositeActivity domain) {
+ this();
+ domain.setName("domain");
+ initChild(domain, true, new Point(150, 100));
+ PredefinedStepContainer act = new PredefinedStepContainer();
+ addChild(act, new GraphPoint(300, 100));
+ }
+
+ /**
+ * Method getVertexTypeNameAndConstructionInfo.
+ *
+ * @return TypeNameAndConstructionInfo[]
+ */
+ /** getVertexTypeNameAndConstructionInfo() added by Steve */
+ public TypeNameAndConstructionInfo[] getVertexTypeNameAndConstructionInfo()
+ {
+ return mVertexTypeNameAndConstructionInfo;
+ }
+ /**
+ * Method getEdgeTypeNameAndConstructionInfo.
+ *
+ * @return TypeNameAndConstructionInfo[]
+ */
+ /** getVertexTypeNameAndConstructionInfo() added by Steve */
+ public TypeNameAndConstructionInfo[] getEdgeTypeNameAndConstructionInfo()
+ {
+ return mEdgeTypeNameAndConstructionInfo;
+ }
+ /**
+ * Method requestAction.
+ *
+ * @param agentInfo
+ * @param stepPath
+ * @param transitionID
+ * @param reguestData
+ * @throws ObjectNotFoundException
+ * @throws AccessRightsException
+ * @throws InvalidTransitionException
+ * @throws InvalidDataException
+ */
+ //requestData is xmlstring
+ public void requestAction(AgentPath agent, String stepPath, int transitionID, String requestData)
+ throws ObjectNotFoundException, AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectAlreadyExistsException
+ {
+ Logger.msg(3, "Action: " + Transitions.getTransitionName(transitionID) + " " + stepPath + " by " + agent.getAgentName());
+ if (search(stepPath) != null)
+ ((Activity) search(stepPath)).request(agent, transitionID, requestData);
+ else
+ throw new ObjectNotFoundException(stepPath + " not found", "");
+ }
+
+ /**
+ * @see com.c2kernel.graph.model.GraphableVertex#getPath()
+ */
+ public String getPath()
+ {
+ return "workflow";
+ }
+ /**
+ * @see com.c2kernel.graph.model.Vertex#getName()
+ */
+ public String getName()
+ {
+ return "workflow";
+ }
+ /**
+ * @see com.c2kernel.lifecycle.instance.Activity#getType()
+ */
+ public String getType()
+ {
+ return "workflow";
+ }
+ /**
+ * @see com.c2kernel.graph.model.Vertex#setName(java.lang.String)
+ */
+ public void setName(String name)
+ {
+ }
+ /**
+ * @see com.c2kernel.lifecycle.instance.WfVertex#verify()
+ */
+ public boolean verify()
+ {
+ for (int i = 0; i < getChildren().length; i++)
+ {
+ if (!((WfVertex) getChildren()[i]).verify())
+ {
+ mErrors.add("error in children");
+ return false;
+ }
+ }
+ return true;
+ }
+ /**
+ * @see com.c2kernel.lifecycle.instance.Activity#getWf()
+ */
+ public Workflow getWf()
+ {
+ return this;
+ }
+ /**
+ * Method initialise.
+ *
+ * @param systemKey
+ */
+ public void initialise(int systemKey, AgentPath agent)
+ {
+ this.getProperties().put("ItemSystemKey", new Integer(systemKey));
+ try
+ {
+ runfirst(agent);
+ }
+ catch (ScriptingEngineException ex)
+ {
+ Logger.error(ex);
+ }
+ }
+ /**
+ * Method calculateJobs.
+ *
+ * @param type
+ * @return JobList
+ */
+ /**
+ * if type = 0 only domain steps will be queried if type = 1 only predefined steps will be queried else both will be queried
+ */
+ public ArrayList calculateJobs(AgentPath agent, int type)
+ {
+ ArrayList jobs = new ArrayList();
+ if (type != 1)
+ jobs.addAll(((CompositeActivity) search("workflow/domain")).calculateJobs(agent, true));
+ if (type != 0)
+ jobs.addAll(((CompositeActivity) search("workflow/predefined")).calculateJobs(agent, true));
+ return jobs;
+ }
+ /**
+ * @see com.c2kernel.lifecycle.instance.CompositeActivity#hasGoodNumberOfActivity()
+ */
+ public boolean hasGoodNumberOfActivity()
+ {
+ return true;
+ }
+ /**
+ * @see com.c2kernel.entity.C2KLocalObject#getClusterType()
+ */
+ public String getClusterType()
+ {
+ return ClusterStorage.LIFECYCLE;
+ }
+
+}