From b086f57f56bf0eb9dab9cf321a0f69aaaae84347 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Wed, 30 May 2012 08:37:45 +0200 Subject: Initial Maven Conversion --- .../lifecycle/instance/CompositeActivity.java | 458 --------------------- 1 file changed, 458 deletions(-) delete mode 100644 source/com/c2kernel/lifecycle/instance/CompositeActivity.java (limited to 'source/com/c2kernel/lifecycle/instance/CompositeActivity.java') diff --git a/source/com/c2kernel/lifecycle/instance/CompositeActivity.java b/source/com/c2kernel/lifecycle/instance/CompositeActivity.java deleted file mode 100644 index c080a37..0000000 --- a/source/com/c2kernel/lifecycle/instance/CompositeActivity.java +++ /dev/null @@ -1,458 +0,0 @@ -package com.c2kernel.lifecycle.instance; - -import java.awt.Point; -import java.util.ArrayList; -import java.util.Vector; - -import com.c2kernel.common.AccessRightsException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.InvalidTransitionException; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.entity.agent.Job; -import com.c2kernel.graph.model.GraphModel; -import com.c2kernel.graph.model.GraphPoint; -import com.c2kernel.graph.model.GraphableVertex; -import com.c2kernel.lifecycle.instance.gui.model.WfVertexOutlineCreator; -import com.c2kernel.lifecycle.instance.stateMachine.StateMachine; -import com.c2kernel.lifecycle.instance.stateMachine.States; -import com.c2kernel.lifecycle.instance.stateMachine.Transitions; -import com.c2kernel.lookup.AgentPath; -import com.c2kernel.scripting.ScriptingEngineException; -import com.c2kernel.utils.Logger; - -/** - * @version $Revision: 1.86 $ $Date: 2005/10/05 07:39:37 $ - * @author $Author: abranson $ - */ -public class CompositeActivity extends Activity -{ - /** - * @see java.lang.Object#Object() - */ - /* - * -------------------------------------------- - * ----------------CONSTRUCTOR----------------- - * -------------------------------------------- - */ - public CompositeActivity() - { - super(); - setChildrenGraphModel(new GraphModel(new WfVertexOutlineCreator())); - setIsComposite(true); - } - - /** - * @see com.c2kernel.lifecycle.instance.WfVertex#verify() - */ - /* - * -------------------------------------------- --------------Other - * Functions--------------- -------------------------------------------- - */ - /** launch the verification of the subprocess() */ - @Override - public boolean verify() - { - boolean err = super.verify(); - GraphableVertex[] vChildren = getChildren(); - for (int i = 0; i < vChildren.length; i++) - { - if (!((WfVertex) vChildren[i]).verify()) - { - mErrors.add("error in children"); - return false; - } - } - return err; - } - - /** - * Method initChild. - * - * @param act - * @param first - * @param point - */ - /** - * Create an initialize a Activity attached to the current activity - * - * @param first : - * if true, the activity Waiting will be one of the first - * launched by the parent activity - */ - public void initChild(Activity act, boolean first, Point point) - { - this.addChild(act, new GraphPoint(point.x, point.y)); - if (first) - { - getChildrenGraphModel().setStartVertexId(act.getID()); - Logger.msg(5, "com.c2kernel.lifecycle.CompositeActivity :: " + getID() + " is first"); - } - } - - /** - * Method newChild. - * - * @param Name - * @param Type - * @param point - * @return WfVertex - */ - public WfVertex newExistingChild(Activity child, String Name, Point point) - { - child.setName(Name); - addChild(child, new GraphPoint(point.x, point.y)); - return child; - } - - /** - * Method newChild. - * - * @param Name - * @param Type - * @param point - * @return WfVertex - */ - public WfVertex newChild(String Name, String Type, Point point) - { - WfVertex v = newChild(Type, point); - v.setName(Name); - return v; - } - - /** - * Method newChild. - * - * @param vertexTypeId - * @param point - * @return WfVertex - */ - public WfVertex newChild(String vertexTypeId, Point point) - { - WfVertex wfVertex = null; - if (vertexTypeId.equals("Atomic")) - { - wfVertex = newAtomChild("False id", false, point); - } else if (vertexTypeId.equals("Composite")) - { - wfVertex = newCompChild("False id", false, point); - } else if (vertexTypeId.endsWith("Split")) - { - if (vertexTypeId.startsWith("Or")) - { - wfVertex = newSplitChild("Or", point); - } else if (vertexTypeId.startsWith("XOr")) - { - wfVertex = newSplitChild("XOr", point); - } else if (vertexTypeId.startsWith("Loop")) - { - wfVertex = newSplitChild("Loop", point); - } else - { - wfVertex = newSplitChild("And", point); - } - } else if (vertexTypeId.equals("Join")) - { - wfVertex = newJoinChild(point); - } else if (vertexTypeId.equals("Route")) - { - wfVertex = newRouteChild(point); - } - return wfVertex; - } - - /** - * Method newCompChild. - * - * @param id - * @param first - * @param point - * @return CompositeActivity Create an initialize a composite Activity - * attached to the current activity - */ - public CompositeActivity newCompChild(String id, boolean first, Point point) - { - CompositeActivity act = new CompositeActivity(); - initChild(act, first, point); - act.setName(id); - return act; - } - - /** - * Method newAtomChild. - * - * @param id - * @param first - * @param point - * @return Activity Create an initialize an Atomic Activity attached to the - * current activity - * - */ - public Activity newAtomChild(String id, boolean first, Point point) - { - Activity act = new Activity(); - initChild(act, first, point); - act.setName(id); - return act; - } - - /** - * Method newSplitChild. - * - * @param Type - * @param point - * @return Split - */ - public Split newSplitChild(String Type, Point point) - { - Split split; - if (Type.equals("Or")) - { - split = new OrSplit(); - } else if (Type.equals("XOr")) - { - split = new XOrSplit(); - } else if (Type.equals("Loop")) - { - split = new Loop(); - } else - { - split = new AndSplit(); - } - addChild(split, new GraphPoint(point.x, point.y)); - return split; - } - - /** - * Method newJoinChild. - * - * @param point - * @return Join - */ - public Join newJoinChild(Point point) - { - Join join = new Join(); - join.getProperties().put("Type", "Join"); - addChild(join, new GraphPoint(point.x, point.y)); - return join; - } - - public Join newRouteChild(Point point) - { - Join join = new Join(); - join.getProperties().put("Type", "Route"); - addChild(join, new GraphPoint(point.x, point.y)); - return join; - } - - /** - * Method search. - * - * @param ids - * @return WfVertex - */ - WfVertex search(int ids) - { - for (int i = 0; i < getChildren().length; i++) - { - WfVertex ver = (WfVertex) getChildren()[i]; - if (ver instanceof Split) - { - if (ver.getID() == ids) - { - return ver; - } - } - if (ver instanceof Join) - { - if (ver.getID() == ids) - { - return ver; - } - } - } - return null; - } - - /** - * @see com.c2kernel.lifecycle.instance.WfVertex#run() - */ - @Override - public void run(AgentPath agent) throws ScriptingEngineException - { - super.run(agent); - if (getChildrenGraphModel().getStartVertex() != null && getMachine().getCurrentState() != States.FINISHED && ((Boolean) getProperties().get(StateMachine.AUTOSTART)).booleanValue()) - { - WfVertex first = (WfVertex) getChildrenGraphModel().getStartVertex(); - first.run(agent); - } - } - - @Override - public void runNext(AgentPath agent) throws ScriptingEngineException - { - if (getMachine().state != States.FINISHED) - getMachine().traverse(Transitions.COMPLETE); - super.runNext(agent); - } - - /** - * @see com.c2kernel.lifecycle.instance.Activity#query(com.c2kernel.common.AgentInfo, - * java.lang.String, boolean) - */ - @Override - public Activity[] query(AgentPath agent, int stateID, boolean filter) - { - Vector steps = new Vector(); - Activity[] returnArray = null; - for (int i = 0; i < getChildren().length; i++) - { - if (getChildren()[i] instanceof Activity) - steps.addElement(((Activity) getChildren()[i]).query(agent, stateID, filter)); - } - int j = 0; - for (int i = 0; i < steps.size(); i++) - j += steps.elementAt(i).length; - Activity[] tmp = super.query(agent, stateID, filter); - if (tmp.length == 1) - { - returnArray = new Activity[j + 1]; - returnArray[j] = tmp[0]; - } else - returnArray = new Activity[j]; - j = 0; - for (int i = 0; i < steps.size(); i++) - { - Activity[] stepArray = steps.elementAt(i); - for (Activity element : stepArray) - returnArray[j++] = element; - } - return returnArray; - } - - /** - * @see com.c2kernel.lifecycle.instance.Activity#calculateJobs() - */ - @Override - public ArrayList calculateJobs(AgentPath agent, boolean recurse) - { - ArrayList jobs = new ArrayList(); - boolean childActive = false; - if (recurse) - for (int i = 0; i < getChildren().length; i++) - if (getChildren()[i] instanceof Activity) - { - Activity child = (Activity) getChildren()[i]; - jobs.addAll(child.calculateJobs(agent, recurse)); - childActive |= child.active; - } - if (!childActive) - jobs.addAll(super.calculateJobs(agent, recurse)); - return jobs; - } - - @Override - public ArrayList calculateAllJobs(AgentPath agent, boolean recurse) - { - ArrayList jobs = new ArrayList(); - if (recurse) - for (int i = 0; i < getChildren().length; i++) - if (getChildren()[i] instanceof Activity) - { - Activity child = (Activity) getChildren()[i]; - jobs.addAll(child.calculateAllJobs(agent, recurse)); - } - jobs.addAll(super.calculateAllJobs(agent, recurse)); - return jobs; - } - - /** - * Method addNext. - * - * @param origin - * @param terminus - * @return Next - */ - public Next addNext(WfVertex origin, WfVertex terminus) - { - return new Next(origin, terminus); - } - - /** - * Method addNext. - * - * @param originID - * @param terminusID - * @return Next - */ - public Next addNext(int originID, int terminusID) - { - Next n = new Next(); - n.setParent(this); - getChildrenGraphModel().addEdgeAndCreateId(n, originID, terminusID); - return n; - } - - /** - * Method hasGoodNumberOfActivity. - * - * @return boolean - */ - public boolean hasGoodNumberOfActivity() - { - int endingAct = 0; - for (int i = 0; i < getChildren().length; i++) - { - WfVertex vertex = (WfVertex) getChildren()[i]; - if (getChildrenGraphModel().getOutEdges(vertex).length == 0) - endingAct++; - } - if (endingAct > 1) - return false; - return true; - } - - /** - * @see com.c2kernel.lifecycle.instance.Activity#getType() - */ - @Override - public String getType() - { - if (getName().equals("domain")) - return "domain"; - return super.getType(); - } - - /** - * - */ - @Override - public void reinit(int idLoop) - { - super.reinit(idLoop); - if (getChildrenGraphModel().getStartVertex() != null && getMachine().getCurrentState() != States.FINISHED) - ((WfVertex) getChildrenGraphModel().getStartVertex()).reinit(idLoop); - } - - @Override - public void request(AgentPath agent, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectAlreadyExistsException - { - if (getChildrenGraphModel().getStartVertex() != null && getMachine().getCurrentState() != States.FINISHED && transitionID == Transitions.START) - try - { - ((WfVertex) getChildrenGraphModel().getStartVertex()).run(agent); - } catch (ScriptingEngineException e) - { - Logger.error(e); - } - super.request(agent, transitionID, requestData); - } - public void refreshJobs() - { - GraphableVertex[] children = getChildren(); - for (GraphableVertex element : children) - if (element instanceof CompositeActivity) - ((CompositeActivity) element).refreshJobs(); - else if (element instanceof Activity) - ((Activity) element).pushJobsToAgents(); - } -} \ No newline at end of file -- cgit v1.2.3