summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/lifecycle/LoopDef.java
diff options
context:
space:
mode:
Diffstat (limited to 'source/com/c2kernel/lifecycle/LoopDef.java')
-rwxr-xr-xsource/com/c2kernel/lifecycle/LoopDef.java74
1 files changed, 74 insertions, 0 deletions
diff --git a/source/com/c2kernel/lifecycle/LoopDef.java b/source/com/c2kernel/lifecycle/LoopDef.java
new file mode 100755
index 0000000..bee97c5
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/LoopDef.java
@@ -0,0 +1,74 @@
+package com.c2kernel.lifecycle;
+
+import com.c2kernel.graph.model.Vertex;
+import com.c2kernel.graph.traversal.GraphTraversal;
+import com.c2kernel.lifecycle.instance.Loop;
+import com.c2kernel.lifecycle.instance.WfVertex;
+
+/**
+ * @version $Revision: 1.19 $ $Date: 2005/09/29 10:18:31 $
+ * @author $Author: abranson $
+ */
+
+public class LoopDef extends XOrSplitDef
+{
+ public boolean hasLoop = false;
+ public int isNext = 0;
+
+ /**
+ * @see java.lang.Object#Object()
+ */
+ public LoopDef()
+ {
+ super();
+ }
+
+ /**
+ * @see com.c2kernel.lifecycle.WfVertexDef#loop()
+ */
+ public boolean loop()
+ {
+ return true;
+ }
+
+ /**
+ * @see com.c2kernel.lifecycle.WfVertexDef#verify()
+ */
+ public boolean verify()
+ {
+ if (!super.verify()) return false;
+ Vertex[] nexts = getOutGraphables();
+ Vertex[] anteVertices =
+ GraphTraversal.getTraversal(this.getParent().getChildrenGraphModel(), this, GraphTraversal.kUp, false);
+ int k = 0;
+ int l = 0;
+ Vertex[] brothers = getParent().getChildren();
+ for (int i = 0; i < brothers.length; i++)
+ if (brothers[i] instanceof LoopDef) l++;
+ for (int i = 0; i < nexts.length; i++)
+ for (int j = 0; j < anteVertices.length; j++)
+ if (nexts[i].equals(anteVertices[j]))
+ k++;
+ if (k != 1 && !(l>1))
+ {
+ mErrors.add("bad number of pointing back nexts");
+ return false;
+ }
+// if (nexts.length>2) {
+// mErrors.add("you must only have 2 nexts");
+// return false;
+// }
+ return true;
+ }
+
+ public boolean isLoop() {
+ return true;
+ }
+
+ public WfVertex instantiate() {
+ Loop newLoop = new Loop();
+ configureInstance(newLoop);
+ return newLoop;
+ }
+
+}