summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2012-05-30 08:37:45 +0200
committerAndrew Branson <andrew.branson@cern.ch>2012-05-30 08:37:45 +0200
commitb086f57f56bf0eb9dab9cf321a0f69aaaae84347 (patch)
tree8e6e26e8b7eed6abad7a17b093bdbb55c5e6b1ba /src/main/java/com/c2kernel/lifecycle/instance/Workflow.java
parent22088ae8d2d5ff390518dbe1c4372325ffb3a647 (diff)
Initial Maven Conversion
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/Workflow.java')
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/Workflow.java208
1 files changed, 208 insertions, 0 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java b/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java
new file mode 100644
index 0000000..1d12ee6
--- /dev/null
+++ b/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java
@@ -0,0 +1,208 @@
+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.entity.agent.Job;
+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()
+ */
+ @Override
+ public String getPath()
+ {
+ return "workflow";
+ }
+ /**
+ * @see com.c2kernel.graph.model.Vertex#getName()
+ */
+ @Override
+ public String getName()
+ {
+ return "workflow";
+ }
+ /**
+ * @see com.c2kernel.lifecycle.instance.Activity#getType()
+ */
+ @Override
+ public String getType()
+ {
+ return "workflow";
+ }
+ /**
+ * @see com.c2kernel.graph.model.Vertex#setName(java.lang.String)
+ */
+ @Override
+ public void setName(String name)
+ {
+ }
+ /**
+ * @see com.c2kernel.lifecycle.instance.WfVertex#verify()
+ */
+ @Override
+ 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()
+ */
+ @Override
+ 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<Job> calculateJobs(AgentPath agent, int type)
+ {
+ ArrayList<Job> jobs = new ArrayList<Job>();
+ 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()
+ */
+ @Override
+ public boolean hasGoodNumberOfActivity()
+ {
+ return true;
+ }
+ /**
+ * @see com.c2kernel.entity.C2KLocalObject#getClusterType()
+ */
+ @Override
+ public String getClusterType()
+ {
+ return ClusterStorage.LIFECYCLE;
+ }
+
+}