Author: kukeltje
Date: 2009-07-30 05:24:19 -0400 (Thu, 30 Jul 2009)
New Revision: 5385
Added:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
Removed:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualActivity.java
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
Log:
Refactoring of gateways, initial refactoring of tasks and first steps to 'fix' the
broken 'forkingtask' test
Modified: jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml 2009-07-30 09:02:19 UTC
(rev 5384)
+++ jbpm4/trunk/modules/bpmn/src/main/java/jbpm.bpmn.flownodes.xml 2009-07-30 09:24:19 UTC
(rev 5385)
@@ -6,6 +6,6 @@
<activity binding="org.jbpm.bpmn.flownodes.EndBinding" />
<activity binding="org.jbpm.bpmn.flownodes.ParallelGatewayBinding" />
<activity binding="org.jbpm.bpmn.flownodes.ExclusiveGatewayBinding" />
- <activity binding="org.jbpm.bpmn.flownodes.AbstractTaskBinding" />
<activity binding="org.jbpm.bpmn.flownodes.ManualTaskBinding" />
+ <activity binding="org.jbpm.bpmn.flownodes.TaskBinding" />
</activities>
Added:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java
===================================================================
---
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java
(rev 0)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -0,0 +1,57 @@
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
+import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+
+import org.w3c.dom.Element;
+
+public abstract class AbstractGatewayBinding extends BpmnBinding {
+
+ int incomming = 0;
+ int outgoing = 0;
+
+ String gatewayDirection = "unspeficied";
+ boolean valid = true;
+
+ protected static final Log log = Log.getLog(ExclusiveGatewayBinding.class.getName());
+ static ObjectBinding objectBinding = new ObjectBinding();
+ static WireParser wireParser = WireParser.getInstance();
+
+ public AbstractGatewayBinding(String tagName) {
+ super(tagName);
+ }
+
+ public void parse(Element element) {
+ incomming = 0;
+ outgoing = 0;
+ valid = true;
+ if (element.hasAttribute("gatewayDirection")) {
+
+ gatewayDirection = element.getAttribute("gatewayDirection");
+ } else {
+ // unspecified should be the 'xsd' default, so maybe this is not even
+ // needed.
+ gatewayDirection = "unspecified";
+ }
+
+ }
+
+ protected boolean validGatewayDirection(String gatewayDirection, int incomming, int
outgoing, Parse parse, String elementName, Element element) {
+
+ log.debug(gatewayDirection + ": incomming: " + incomming + ",
outgoing: " + outgoing);
+
+ boolean valid = !(("converging".equals(gatewayDirection) &&
(!(incomming > 1) || outgoing != 1))
+ || ("diverging".equals(gatewayDirection) && (incomming != 1
|| !(outgoing > 1)))
+ || ("mixed".equals(gatewayDirection) && (incomming <= 1
|| outgoing <= 1)));
+
+ if (!valid) {
+ parse.addProblem("parallelGateway '" + elementName + "' has
the wrong number of incomming (" + incomming + ") and outgoing (" +
outgoing
+ + ") transitions for gatewayDirection='" + gatewayDirection +
"'", element);
+ }
+ return valid;
+ }
+
+}
\ No newline at end of file
Added:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java
===================================================================
---
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java
(rev 0)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractTaskBinding.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -0,0 +1,10 @@
+package org.jbpm.bpmn.flownodes;
+
+public abstract class AbstractTaskBinding extends BpmnBinding {
+
+
+ public AbstractTaskBinding(String tag) {
+ super(tag);
+ }
+
+}
\ No newline at end of file
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayBinding.java
===================================================================
---
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayBinding.java 2009-07-30
09:02:19 UTC (rev 5384)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayBinding.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -24,10 +24,7 @@
import java.util.Iterator;
import java.util.List;
-import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
-import org.jbpm.pvm.internal.wire.xml.WireParser;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -37,40 +34,20 @@
* @author Ronald van Kuijk (kukeltje)
*
*/
-public class ExclusiveGatewayBinding extends BpmnBinding {
+public class ExclusiveGatewayBinding extends AbstractGatewayBinding {
- private static final Log log = Log.getLog(ExclusiveGatewayBinding.class.getName());
-
- static ObjectBinding objectBinding = new ObjectBinding();
- static WireParser wireParser = WireParser.getInstance();
-
public ExclusiveGatewayBinding() {
super("exclusiveGateway");
}
public Object parse(Element element, Parse parse, Parser parser) {
- String gatewayDirection = "unspeficied";
+ super.parse(element);
+
String default_ = null;
- int incomming = 0;
- int outgoing = 0;
-
boolean defaultExists = false;
- boolean valid = true;
- if (element.hasAttribute("gatewayDirection")) {
- gatewayDirection = element.getAttribute("gatewayDirection");
- } else {
- // unspecified should be the 'xsd' default, so maybe this is not even
- // needed.
- gatewayDirection = "unspecified";
- }
-
- if (element.hasAttribute("default")) {
- default_ = element.getAttribute("default");
- }
-
List<Element> transitionElements = XmlUtil.elements((Element)
element.getParentNode(), "sequenceFlow");
String elementId = element.getAttribute("id");
String elementName = element.getAttribute("name");
@@ -86,27 +63,24 @@
if (transitionElement.getAttribute("id").equals(default_)) {
defaultExists = true;
if (ce != null) {
- // conditionExpression on the default sequenceflow SHALL be ignored according
to the spec
+ // conditionExpression on the default sequenceflow SHALL be ignored
+ // according to the spec
log.debug("Default sequenceFlow for " + elementName + " has
conditionExpressio(s). Ignoring them by removing them from the Document model");
transitionElement.removeChild(ce);
}
} else if (default_ != null && ce == null) {
- parse.addProblem("exclusiveGateway '" + elementName +
"' has default sequenceFlow '" + default_ + "' but " +
transitionElement.getAttribute("id")
- + " does not have a required conditionExpression",
element);
- valid = false; // do not break. Parsing may find other issues;
- }
+ parse.addProblem("exclusiveGateway '" + elementName + "'
has default sequenceFlow '" + default_ + "' but " +
transitionElement.getAttribute("id")
+ + " does not have a required conditionExpression", element);
+ valid = false; // do not break. Parsing may find other issues;
+ }
} else if (transitionElement.getAttribute("targetRef").equals(elementId))
{
incomming++;
}
}
- if (invalidGatewayDirection(gatewayDirection, incomming, outgoing)) {
- parse.addProblem("exclusiveGateway '" +
element.getAttribute("name") + "' has the wrong number of incomming
(" + incomming + ") and outgoing ("
- + outgoing + ") transitions for gatewayDirection='" +
gatewayDirection + "'", element);
+ boolean validGatewayDirection = validGatewayDirection(gatewayDirection, incomming,
outgoing, parse, elementName, element);
+ valid = valid == false ? false : validGatewayDirection;
- valid = false;
- }
-
if (default_ != null && !defaultExists) {
parse.addProblem("exclusiveGateway '" +
element.getAttribute("name") + "' default sequenceFlow '" +
default_
+ "' does not exist or is not related to this node",
element);
@@ -117,19 +91,10 @@
return null;
}
- ExclusiveGatewayActivity decisionConditionActivity = new ExclusiveGatewayActivity();
- decisionConditionActivity.setDefault(default_);
- decisionConditionActivity.setGatewayDirection(gatewayDirection);
+ ExclusiveGatewayActivity exclusiveGatewayActivity = new ExclusiveGatewayActivity();
+ exclusiveGatewayActivity.setDefault(default_);
+ exclusiveGatewayActivity.setGatewayDirection(gatewayDirection);
- return decisionConditionActivity;
+ return exclusiveGatewayActivity;
}
-
- private boolean invalidGatewayDirection(String gatewayDirection, int incomming, int
outgoing) {
-
- log.debug(gatewayDirection + ": incomming: " + incomming + ",
outgoing: " + outgoing);
- return ("converging".equals(gatewayDirection) && (!(incomming >
1) || outgoing != 1))
- || ("diverging".equals(gatewayDirection) && (incomming != 1
|| !(outgoing > 1)))
- || ("mixed".equals(gatewayDirection) && (incomming <= 1
|| outgoing <= 1));
-
- }
}
Deleted:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualActivity.java
===================================================================
---
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualActivity.java 2009-07-30
09:02:19 UTC (rev 5384)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualActivity.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -1,17 +0,0 @@
-package org.jbpm.bpmn.flownodes;
-
-import org.jbpm.api.activity.ActivityExecution;
-
-/**
- * Manual activities in BPMN are ignored by the Process Engine.
- * So this is just a no-op, doing nothing.
- *
- * @author Bernd Ruecker (bernd.ruecker(a)camunda.com)
- */
-public class ManualActivity extends BpmnActivity {
-
- private static final long serialVersionUID = 1L;
-
- public void execute(ActivityExecution execution) {
- }
-}
Copied:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskActivity.java
(from rev 5382,
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualActivity.java)
===================================================================
---
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskActivity.java
(rev 0)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskActivity.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -0,0 +1,17 @@
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.api.activity.ActivityExecution;
+
+/**
+ * Manual activities in BPMN are ignored by the Process Engine.
+ * So this is just a no-op, doing nothing.
+ *
+ * @author Bernd Ruecker (bernd.ruecker(a)camunda.com)
+ */
+public class ManualTaskActivity extends BpmnActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) {
+ }
+}
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskBinding.java
===================================================================
---
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskBinding.java 2009-07-30
09:02:19 UTC (rev 5384)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ManualTaskBinding.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -28,14 +28,14 @@
/**
* @author bernd.ruecker(a)camunda.com
*/
-public class ManualTaskBinding extends BpmnBinding {
+public class ManualTaskBinding extends AbstractTaskBinding {
public ManualTaskBinding() {
super("manualTask");
}
public Object parse(Element element, Parse parse, Parser parser) {
- return new ManualActivity();
+ return new ManualTaskActivity();
}
}
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayActivity.java
===================================================================
---
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayActivity.java 2009-07-30
09:02:19 UTC (rev 5384)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayActivity.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -21,8 +21,19 @@
*/
package org.jbpm.bpmn.flownodes;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.LockMode;
+import org.hibernate.Session;
+import org.jbpm.api.Execution;
+import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.model.Activity;
import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.Transition;
/**
* @author Ronald van Kuijk (kukeltje)
@@ -31,6 +42,10 @@
private static final long serialVersionUID = 1L;
+ int multiplicity = -1;
+ LockMode lockMode = LockMode.UPGRADE;
+
+
//GatewayDirection indicates fork (divergence) or join (convergence). Maybe two
different activities is better
private String gatewayDirection;
@@ -39,8 +54,80 @@
}
public void execute(ExecutionImpl execution) {
+
+ Activity activity = execution.getActivity();
+
+ // if this is a single, non concurrent root
+ if (Execution.STATE_ACTIVE_ROOT.equals(execution.getState())) {
+ // just pass through
+ Transition transition = activity.getDefaultOutgoingTransition();
+ if (transition==null) {
+ throw new JbpmException("join must have an outgoing transition");
+ }
+ execution.take(transition);
+
+ } else if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) {
+
+ // force version increment in the parent execution
+ Session session = Environment.getFromCurrent(Session.class);
+ session.lock(execution.getParent(), lockMode);
- //TODO Implement ;-)
+ execution.setState(Execution.STATE_INACTIVE_JOIN);
+ execution.waitForSignal();
+
+ ExecutionImpl concurrentRoot = execution.getParent();
+ List<ExecutionImpl> joinedExecutions = getJoinedExecutions(concurrentRoot,
activity);
+
+ if (isComplete(joinedExecutions, activity)) {
+ endJoinedExecutions(joinedExecutions);
+
+ ExecutionImpl outgoingExecution = null;
+ if (concurrentRoot.getExecutions().size()==0) {
+ outgoingExecution = concurrentRoot;
+ outgoingExecution.setState(Execution.STATE_ACTIVE_ROOT);
+ } else {
+ outgoingExecution = concurrentRoot.createExecution();
+ outgoingExecution.setState(Execution.STATE_ACTIVE_CONCURRENT);
+ }
+
+ execution.setActivity(activity, outgoingExecution);
+ Transition transition = activity.getDefaultOutgoingTransition();
+ if (transition==null) {
+ throw new JbpmException("join must have an outgoing transition");
+ }
+ outgoingExecution.take(transition);
+ }
+
+ } else {
+ throw new JbpmException("invalid execution state");
+ }
+ }
+
+ protected boolean isComplete(List<ExecutionImpl> joinedExecutions, Activity
activity) {
+ int nbrOfExecutionsToJoin = multiplicity;
+ if (multiplicity==-1) {
+ nbrOfExecutionsToJoin = activity.getIncomingTransitions().size();
+ }
+ return joinedExecutions.size()==nbrOfExecutionsToJoin;
+ }
+
+ protected List<ExecutionImpl> getJoinedExecutions(ExecutionImpl concurrentRoot,
Activity activity) {
+ List<ExecutionImpl> joinedExecutions = new ArrayList<ExecutionImpl>();
+ List concurrentExecutions = (List)concurrentRoot.getExecutions();
+ for (ExecutionImpl concurrentExecution:
(List<ExecutionImpl>)concurrentExecutions) {
+ if ( (Execution.STATE_INACTIVE_JOIN.equals(concurrentExecution.getState()))
+ && (concurrentExecution.getActivity()==activity)
+ ) {
+ joinedExecutions.add(concurrentExecution);
+ }
+ }
+ return joinedExecutions;
+ }
+
+ protected void endJoinedExecutions(List<ExecutionImpl> joinedExecutions) {
+ for (ExecutionImpl joinedExecution: joinedExecutions) {
+ joinedExecution.end();
+ }
}
@@ -51,5 +138,9 @@
public void setGatewayDirection(String gatewayDirection) {
this.gatewayDirection = gatewayDirection;
}
-
+
+ public void setLockMode(LockMode lockMode) {
+ this.lockMode = lockMode;
+ }
+
}
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayBinding.java
===================================================================
---
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayBinding.java 2009-07-30
09:02:19 UTC (rev 5384)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayBinding.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -24,57 +24,35 @@
import java.util.Iterator;
import java.util.List;
-import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
-import org.jbpm.pvm.internal.wire.xml.WireParser;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
+
/**
* @author Tom Baeyens
* @author Ronald van Kuijk (kukeltje)
*
*/
-public class ParallelGatewayBinding extends BpmnBinding {
-
- private static final Log log = Log.getLog(ParallelGatewayBinding.class.getName());
-
- static ObjectBinding objectBinding = new ObjectBinding();
- static WireParser wireParser = WireParser.getInstance();
-
+public class ParallelGatewayBinding extends AbstractGatewayBinding {
+
public ParallelGatewayBinding() {
super("parallelGateway");
}
public Object parse(Element element, Parse parse, Parser parser) {
- String gatewayDirection = "unspeficied";
-
- if (element.hasAttribute("gatewayDirection")) {
- gatewayDirection = element.getAttribute("gatewayDirection");
- } else {
- // unspecified should be the 'xsd' default, so maybe this is not even
- // needed.
- gatewayDirection = "unspecified";
- }
-
-
- int incomming = 0;
- int outgoing = 0;
+ super.parse(element);
- boolean valid = true;
-
List<Element> transitionElements = XmlUtil.elements((Element)
element.getParentNode(), "sequenceFlow");
String elementId = element.getAttribute("id");
String elementName = element.getAttribute("name");
if (gatewayDirection.equals("unspecified") ||
gatewayDirection.equals("mixed")) {
- parse.addProblem("gatewayDirection='"+gatewayDirection+ "'
currently not supported on parallelGateway '" + elementName + "'",
element);
+ parse.addProblem("gatewayDirection='" + gatewayDirection +
"' currently not supported on parallelGateway '" + elementName +
"'", element);
return null;
}
-
for (Iterator<Element> iterator = transitionElements.iterator();
iterator.hasNext();) {
Element transitionElement = iterator.next();
@@ -90,26 +68,13 @@
}
}
- if (invalidGatewayDirection(gatewayDirection, incomming, outgoing)) {
- parse.addProblem("parallelGateway '" + elementName + "' has
the wrong number of incomming (" + incomming + ") and outgoing (" +
outgoing
- + ") transitions for gatewayDirection='" + gatewayDirection +
"'", element);
+ boolean validGatewayDirection = validGatewayDirection(gatewayDirection, incomming,
outgoing, parse, elementName, element);
+ valid = valid == false ? false : validGatewayDirection;
- valid = false;
- }
-
if (!valid) {
return null;
}
return new ParallelGatewayActivity();
}
-
- private boolean invalidGatewayDirection(String gatewayDirection, int incomming, int
outgoing) {
-
- log.debug(gatewayDirection + ": incomming: " + incomming + ",
outgoing: " + outgoing);
- return ("converging".equals(gatewayDirection) && (!(incomming >
1) || outgoing != 1))
- || ("diverging".equals(gatewayDirection) && (incomming != 1
|| !(outgoing > 1)))
- || ("mixed".equals(gatewayDirection) && (incomming <= 1
|| outgoing <= 1));
-
- }
}
Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java
(rev 0)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.api.task.Task;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.history.HistoryEvent;
+import org.jbpm.pvm.internal.history.events.TaskActivityStart;
+import org.jbpm.pvm.internal.model.Activity;
+import org.jbpm.pvm.internal.model.Condition;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.Transition;
+import org.jbpm.pvm.internal.session.DbSession;
+import org.jbpm.pvm.internal.task.ParticipationImpl;
+import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
+import org.jbpm.pvm.internal.task.SwimlaneImpl;
+import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskActivity extends BpmnActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Log log = Log.getLog(TaskActivity.class.getName());
+
+ protected TaskDefinitionImpl taskDefinition;
+
+ public void execute(ActivityExecution execution) {
+ execute((ExecutionImpl)execution);
+ }
+
+ public void execute(ExecutionImpl execution) {
+ Activity activity = execution.getActivity();
+
+ // evaluate the conditions and find the transitions that should be forked
+ List<Transition> forkingTransitions = new ArrayList<Transition>();
+ List<Transition> outgoingTransitions = activity.getOutgoingTransitions();
+ for (Transition transition: outgoingTransitions) {
+ Condition condition = transition.getCondition();
+ if ( (condition==null)
+ || (condition.evaluate(execution))
+ ) {
+ forkingTransitions.add(transition);
+ }
+ }
+
+ // if no outgoing transitions should be forked,
+ if (forkingTransitions.size()==0) {
+ // end this execution
+ execution.end();
+
+ // if there is exactly 1 transition to be taken, just use the incoming execution
+ } else if (forkingTransitions.size()==1) {
+ execution.take(forkingTransitions.get(0));
+
+ // if there are more transitions
+ } else {
+ ExecutionImpl concurrentRoot = null;
+ if (Execution.STATE_ACTIVE_ROOT.equals(execution.getState())) {
+ concurrentRoot = execution;
+ execution.setState(Execution.STATE_INACTIVE_CONCURRENT_ROOT);
+ execution.setActivity(null);
+ } else if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) {
+ concurrentRoot = execution.getParent();
+ }
+
+ for (Transition transition: forkingTransitions) {
+ // launch a concurrent path of execution
+ String childExecutionName = transition.getName();
+ ExecutionImpl concurrentExecution =
concurrentRoot.createExecution(childExecutionName);
+ concurrentExecution.setActivity(activity);
+ concurrentExecution.setState(Execution.STATE_ACTIVE_CONCURRENT);
+ concurrentExecution.take(transition);
+
+ if (concurrentRoot.isEnded()) {
+ break;
+ }
+ }
+ }
+
+
+
+ }
+
+ public TaskDefinitionImpl getTaskDefinition() {
+ return taskDefinition;
+ }
+ public void setTaskDefinition(TaskDefinitionImpl taskDefinition) {
+ this.taskDefinition = taskDefinition;
+ }
+}
\ No newline at end of file
Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java
(rev 0)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jbpm.bpmn.flownodes;
+
+import org.jbpm.bpmn.parser.BpmnParser;
+import org.jbpm.pvm.internal.model.ScopeElementImpl;
+import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author bernd.ruecker(a)camunda.com
+ */
+public class TaskBinding extends AbstractTaskBinding {
+
+ public TaskBinding() {
+ super("task");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+
+ TaskActivity taskActivity = new TaskActivity();
+ ScopeElementImpl scopeElement = parse.findObject(ScopeElementImpl.class);
+ TaskDefinitionImpl taskDefinition = BpmnParser.parseTaskDefinition(element, parse,
scopeElement);
+ taskActivity.setTaskDefinition(taskDefinition);
+
+ return taskActivity;
+ }
+
+}
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java
===================================================================
---
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java 2009-07-30
09:02:19 UTC (rev 5384)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -31,7 +31,7 @@
/**
* @author Tom Baeyens
*/
-public class UserTaskBinding extends BpmnBinding {
+public class UserTaskBinding extends AbstractTaskBinding {
private static final String TAG = "userTask";
@@ -45,7 +45,7 @@
ScopeElementImpl scopeElement = parse.findObject(ScopeElementImpl.class);
TaskDefinitionImpl taskDefinition = BpmnParser.parseTaskDefinition(element, parse,
scopeElement);
taskActivity.setTaskDefinition(taskDefinition);
-
+
return taskActivity;
}
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java
===================================================================
---
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java 2009-07-30
09:02:19 UTC (rev 5384)
+++
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -55,7 +55,8 @@
protected Binding instantiateBinding(Element bindingElement, Parse parse) {
String bindingClassName = XmlUtil.attribute(bindingElement, "binding",
true, parse);
- log.trace("adding bpmn binding "+bindingClassName);
+ log.trace("1adding bpmn binding "+bindingClassName);
+ log.debug("2adding bpmn binding "+bindingClassName);
if (bindingClassName!=null) {
try {
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2009-07-30
09:02:19 UTC (rev 5384)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2009-07-30
09:24:19 UTC (rev 5385)
@@ -31,7 +31,7 @@
import org.jbpm.bpmn.model.BpmnProcessDefinition;
import org.jbpm.internal.log.Log;
//import org.jbpm.jpdl.internal.activity.JpdlBinding;
-import org.jbpm.jpdl.internal.xml.BindingsParser;
+//import org.jbpm.jpdl.internal.xml.BindingsParser;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.CompositeElementImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
@@ -211,8 +211,8 @@
String sourceRef = XmlUtil.attribute(transitionElement, "sourceRef",
true, parse);
String targetRef = XmlUtil.attribute(transitionElement, "targetRef",
true, parse);
- log.trace(transitionId + ": " + sourceRef + " -> " +
targetRef);
- log.trace(" with " + XmlUtil.elements(transitionElement,
"conditionExpression").size() + " conditionExpressions");
+ log.debug(transitionId + ": " + sourceRef + " -> " +
targetRef);
+ log.debug(" with " + XmlUtil.elements(transitionElement,
"conditionExpression").size() + " conditionExpressions");
TransitionImpl transition =
compositeElement.findActivity(sourceRef).createOutgoingTransition();
compositeElement.findActivity(targetRef).addIncomingTransition(transition);