diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-03-06 16:27:08 +0100 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-03-06 16:27:08 +0100 |
| commit | 4fb2c8d2a573b2078a3ced1c6142de3a20cfa660 (patch) | |
| tree | 3f00fa045af1be98ff6183d94b08879c672a50d2 | |
| parent | bad46b9c4ac8226de56da5367bc7c1bd9797218c (diff) | |
Fixes #166
Also allows multiple errors in each node, and composites collect the
errors of their children.
| -rw-r--r-- | src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java | 47 | ||||
| -rw-r--r-- | src/main/java/com/c2kernel/lifecycle/WfVertexDef.java | 12 |
2 files changed, 40 insertions, 19 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java b/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java index 514dc72..85c942f 100644 --- a/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java +++ b/src/main/java/com/c2kernel/lifecycle/ActivitySlotDef.java @@ -65,17 +65,17 @@ public class ActivitySlotDef extends WfVertexDef mErrors.add("Unreachable");
err = false;
}
- else if (nbInEdgres > 1)
+ if (nbInEdgres > 1)
{
mErrors.add("Bad nb of previous");
err = false;
}
- else if (nbOutEdges > 1)
+ if (nbOutEdges > 1)
{
mErrors.add("too many next");
err = false;
}
- else if (nbOutEdges == 0)
+ if (nbOutEdges == 0)
{
if (!((CompositeActivityDef) getParent()).hasGoodNumberOfActivity())
{
@@ -83,22 +83,35 @@ public class ActivitySlotDef extends WfVertexDef 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;
+
+ Vertex[] allSiblings = getParent().getChildGraphModel().getVertices();
+ String thisName = (String)getProperties().get("Name");
+ if (thisName == null || thisName.length()==0) mErrors.add("Slot name is empty");
+ else for (Vertex v : allSiblings) {
+ if (v instanceof ActivitySlotDef && v.getID()!=getID()) {
+ ActivitySlotDef otherSlot = (ActivitySlotDef)v;
+ String otherName = (String)otherSlot.getProperties().get("Name");
+ if (otherName != null && otherName.equals(thisName)) {
+ mErrors.add("Duplicate slot name");
+ err = false;
+ }
}
}
+
+ // Loop check
+ 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;
}
/**
diff --git a/src/main/java/com/c2kernel/lifecycle/WfVertexDef.java b/src/main/java/com/c2kernel/lifecycle/WfVertexDef.java index 6a46bee..b2bd306 100644 --- a/src/main/java/com/c2kernel/lifecycle/WfVertexDef.java +++ b/src/main/java/com/c2kernel/lifecycle/WfVertexDef.java @@ -59,8 +59,16 @@ public abstract class WfVertexDef extends GraphableVertex {
if (mErrors.size() == 0)
return "No error";
- else
- return mErrors.elementAt(0);
+ else if (mErrors.size() == 1)
+ return mErrors.elementAt(0);
+ else {
+ StringBuffer errorBuffer = new StringBuffer();
+ for (String error : mErrors) {
+ if (errorBuffer.length() > 0) errorBuffer.append("\n");
+ errorBuffer.append(error);
+ }
+ return errorBuffer.toString();
+ }
}
/**
|
