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 --- .../com/c2kernel/lifecycle/ActivitySlotDef.java | 156 +++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java (limited to 'src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java') diff --git a/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java b/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java new file mode 100644 index 0000000..74d8305 --- /dev/null +++ b/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java @@ -0,0 +1,156 @@ +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 */ + @Override + 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 (Vertex element : outV) { + for (Vertex anteVertice : anteVertices) + if (!loop() && element.getID() == anteVertice.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 (KeyValuePair element : k) + act.getProperties().put(element.getKey(), element.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"); + } + + @Override + public WfVertex instantiate() throws ObjectNotFoundException, InvalidDataException { + Activity newActivity = (Activity)getTheActivityDef().instantiate(); + configureInstance(newActivity); + return newActivity; + } +} -- cgit v1.2.3