From 254ee6f47eebfc00462c10756a92066e82cc1a96 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 21 Jun 2011 15:46:02 +0200 Subject: Initial commit --- source/com/c2kernel/lifecycle/ActivitySlotDef.java | 155 +++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100755 source/com/c2kernel/lifecycle/ActivitySlotDef.java (limited to 'source/com/c2kernel/lifecycle/ActivitySlotDef.java') diff --git a/source/com/c2kernel/lifecycle/ActivitySlotDef.java b/source/com/c2kernel/lifecycle/ActivitySlotDef.java new file mode 100755 index 0000000..10f6778 --- /dev/null +++ b/source/com/c2kernel/lifecycle/ActivitySlotDef.java @@ -0,0 +1,155 @@ +package com.c2kernel.lifecycle; +import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.graph.model.Vertex; +import com.c2kernel.graph.traversal.GraphTraversal; +import com.c2kernel.lifecycle.instance.Activity; +import com.c2kernel.lifecycle.instance.WfVertex; +import com.c2kernel.utils.KeyValuePair; +import com.c2kernel.utils.LocalObjectLoader; +/** + * @version $Revision: 1.46 $ $Date: 2005/10/05 07:39:36 $ + * @author $Author: abranson $ + */ +public class ActivitySlotDef extends WfVertexDef +{ + private String activityDef; + + /** + * Method setActivityDef. + * + * @param oActivityDef + */ + public void setActivityDef(String oActivityDef) + { + activityDef = oActivityDef; + } + /** + * Method getActivityDef. + * + * @return String + */ + public String getActivityDef() + { + return activityDef; + } + /** + * @see java.lang.Object#Object() + */ + public ActivitySlotDef() + { + getProperties().put("Name", ""); + getProperties().put("Version", "last"); + } + + public ActivityDef getTheActivityDef() throws ObjectNotFoundException, InvalidDataException + { + ActivityDef actDef = LocalObjectLoader.getActDef(getActivityDef(), getActVersion()); + if (actDef instanceof CompositeActivityDef) + mIsComposite = true; + return actDef; + } + /** + * @see com.c2kernel.lifecycle.WfVertexDef#verify() + */ + /** launch the verification of the ActivityDef */ + public boolean verify() + { + mErrors.removeAllElements(); + boolean err = true; + int nbInEdgres = getInEdges().length; + int nbOutEdges = getOutEdges().length; + if (nbInEdgres == 0 && this.getID() != getParent().getChildrenGraphModel().getStartVertexId()) + { + mErrors.add("Unreachable"); + err = false; + } + else if (nbInEdgres > 1) + { + mErrors.add("Bad nb of previous"); + err = false; + } + else if (nbOutEdges > 1) + { + mErrors.add("too many next"); + err = false; + } + else if (nbOutEdges == 0) + { + if (!((CompositeActivityDef) getParent()).hasGoodNumberOfActivity()) + { + mErrors.add("too many endpoints"); + err = false; + } + } + else + { + Vertex[] outV = getOutGraphables(); + Vertex[] anteVertices = GraphTraversal.getTraversal(getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false); + boolean errInLoop = false; + for (int i = 0; i < outV.length; i++) + { + for (int j = 0; j < anteVertices.length; j++) + if (!loop() && outV[i].getID() == anteVertices[j].getID()) + errInLoop = true; + } + if (errInLoop) + { + mErrors.add("Problem in Loop"); + err = false; + } + } + return err; + } + /** + * Method getNextWfVertices. + * + * @return WfVertexDef[] + */ + public WfVertexDef[] getNextWfVertices() + { + return (WfVertexDef[]) getOutGraphables(); + } + /** + * @see com.c2kernel.graph.model.GraphableVertex#isLayoutable() + */ + /** + * @see com.c2kernel.graph.model.GraphableVertex#getIsLayoutable() + */ + public boolean isLayoutable() + { + return true; + } + /** + * Method getInfo. + * + * @return CastorHashMap + */ + public void configureInstance(Activity act) + { + KeyValuePair[] k = getProperties().getKeyValuePairs(); + for (int i = 0; i < k.length; i++) + act.getProperties().put(k[i].getKey(), k[i].getValue()); + act.setCentrePoint(getCentrePoint()); + act.setOutlinePoints(getOutlinePoints()); + act.setInEdgeIds(getInEdgeIds()); + act.setOutEdgeIds(getOutEdgeIds()); + act.setName(getActName()); + act.setID(getID()); + } + + public String getActName() + { + return (String) getProperties().get("Name"); + } + public String getActVersion() + { + return (String) getProperties().get("Version"); + } + + public WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException { + Activity newActivity = (Activity)getTheActivityDef().instantiate(); + configureInstance(newActivity); + return newActivity; + } +} -- cgit v1.2.3