[jbpm-commits] JBoss JBPM SVN: r6088 - in jbpm4/trunk/modules: bpmn/src/main/java/org/jbpm/bpmn/model and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Jan 18 10:01:34 EST 2010
Author: jbarrez
Date: 2010-01-18 10:01:34 -0500 (Mon, 18 Jan 2010)
New Revision: 6088
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractMergingGatewayActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/InclusiveGatewayActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/model/BpmnProcessDefinition.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/assertion/CollectionAssertions.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/InclusiveGatewayTest.java
Log:
Intermediate commit for JBPM-2738
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractMergingGatewayActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractMergingGatewayActivity.java 2010-01-18 10:56:59 UTC (rev 6087)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractMergingGatewayActivity.java 2010-01-18 15:01:34 UTC (rev 6088)
@@ -75,10 +75,14 @@
} else {
if (LOG.isDebugEnabled()) {
- LOG.debug("Multiple incoming sequence flow found. Executing join logic.");
+ LOG.debug("Multiple incoming sequence flow found. Handling incoming execution.");
}
boolean allExecutionsArrived = handleIncomingExecution(execution);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("All executions arrived at the gateway: " + allExecutionsArrived);
+ }
+
// After executing the join functionality, it could be that all executions have arrived
// at the gateway. In that case, the gateway can be left.
if (allExecutionsArrived) {
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/InclusiveGatewayActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/InclusiveGatewayActivity.java 2010-01-18 10:56:59 UTC (rev 6087)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/InclusiveGatewayActivity.java 2010-01-18 15:01:34 UTC (rev 6088)
@@ -21,19 +21,12 @@
*/
package org.jbpm.bpmn.flownodes;
-import java.util.ArrayList;
import java.util.Collection;
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.bpmn.model.BpmnProcessDefinition;
import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.model.Activity;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.Transition;
@@ -80,10 +73,12 @@
BpmnProcessDefinition processDefinition = (BpmnProcessDefinition) incomingExecution.getProcessDefinition();
for (ExecutionImpl execution : allExecutions) {
- String activityId = execution.getActivityName(); // id is stored in the name attribute
- if (activityId != null && !currentActivityId.equals(activityId)) {
- if (processDefinition.isReachable(activityId, currentActivityId)) {
- return false;
+ if (incomingExecution.getParent().equals(execution.getParent())) {
+ String activityId = execution.getActivityName(); // id is stored in the name attribute
+ if (activityId != null && !currentActivityId.equals(activityId)) {
+ if (processDefinition.isReachable(activityId, currentActivityId)) {
+ return false;
+ }
}
}
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveActivity.java 2010-01-18 10:56:59 UTC (rev 6087)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ReceiveActivity.java 2010-01-18 15:01:34 UTC (rev 6088)
@@ -21,29 +21,41 @@
*/
package org.jbpm.bpmn.flownodes;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
+import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.model.Activity;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.Transition;
+/**
+ * Java version of the Receive activity.
+ *
+ * @author Joram Barrez
+ */
public class ReceiveActivity extends BpmnExternalActivity {
private static final long serialVersionUID = 1L;
+ private static final Log LOG = Log.getLog(ReceiveActivity.class.getName());
+
public void execute(ActivityExecution execution) {
execute((ExecutionImpl)execution);
}
+
public void execute(ExecutionImpl execution) {
execution.historyActivityStart();
-
execution.waitForSignal();
}
public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
signal((ExecutionImpl) execution, signalName, parameters);
}
+
public void signal(ExecutionImpl execution, String signalName, Map<String, ?> parameters) {
Activity activity = execution.getActivity();
@@ -51,23 +63,19 @@
execution.setVariables(parameters);
}
- execution.fire(signalName, activity);
-
- Transition transition = null;
- if ( (signalName==null)
- && (activity.getOutgoingTransitions()!=null)
- && (activity.getOutgoingTransitions().size()==1)
- ) {
- transition = activity.getOutgoingTransitions().get(0);
+ List<Transition> outgoingTransitions = new ArrayList<Transition>();
+ if (signalName != null) {
+ Transition transition = activity.findOutgoingTransition(signalName);
+ if (transition == null) {
+ throw new JbpmException("Cannot find an outgoing transition for " + activity.getName() +
+ " named " + signalName);
+ }
+ outgoingTransitions.add(transition);
+ execution.fire(signalName, activity);
} else {
- transition = activity.findOutgoingTransition(signalName);
+ outgoingTransitions.addAll(findOutgoingSequenceFlow(execution, CONDITIONS_CHECKED));
}
- if (transition!=null) {
- execution.historyActivityEnd(signalName);
- execution.take(transition);
- } else {
- execution.waitForSignal();
- }
+ proceed(execution, outgoingTransitions);
}
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/model/BpmnProcessDefinition.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/model/BpmnProcessDefinition.java 2010-01-18 10:56:59 UTC (rev 6087)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/model/BpmnProcessDefinition.java 2010-01-18 15:01:34 UTC (rev 6088)
@@ -140,10 +140,13 @@
return true;
} else {
alreadyVisited.add(srcActivityId);
- for (String destinationId : sourceToTargetMapping.get(srcActivityId)) {
- if (!alreadyVisited.contains(destinationId)) {
- if (isReachable(destinationId, dstActivityId, alreadyVisited)) {
- return true;
+ Set<String> directReachable = sourceToTargetMapping.get(srcActivityId);
+ if (directReachable != null) {
+ for (String destinationId : sourceToTargetMapping.get(srcActivityId)) {
+ if (!alreadyVisited.contains(destinationId)) {
+ if (isReachable(destinationId, dstActivityId, alreadyVisited)) {
+ return true;
+ }
}
}
}
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2010-01-18 10:56:59 UTC (rev 6087)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2010-01-18 15:01:34 UTC (rev 6088)
@@ -39,6 +39,7 @@
import org.jbpm.api.RepositoryService;
import org.jbpm.api.TaskService;
import org.jbpm.api.task.Task;
+import org.jbpm.test.assertion.CollectionAssertions;
/** base class for persistent jBPM tests.
*
@@ -295,9 +296,8 @@
}
public void assertActivitiesActive(String executionId, String ... activityNames) {
- for (String activityName : activityNames) {
- assertActivityActive(executionId, activityName);
- }
+ CollectionAssertions.assertContainsSameElements(
+ executionService.findExecutionById(executionId).findActiveActivityNames(), activityNames);
}
/** Checks if the given execution is active in one (or more) of the given activities */
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/assertion/CollectionAssertions.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/assertion/CollectionAssertions.java 2010-01-18 10:56:59 UTC (rev 6087)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/assertion/CollectionAssertions.java 2010-01-18 15:01:34 UTC (rev 6088)
@@ -37,6 +37,9 @@
*/
public class CollectionAssertions {
+ // No need to instantiate
+ private CollectionAssertions() {}
+
/**
* Compares the elements of the two given collections.
* The order of elements is not checked.
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/InclusiveGatewayTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/InclusiveGatewayTest.java 2010-01-18 10:56:59 UTC (rev 6087)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/InclusiveGatewayTest.java 2010-01-18 15:01:34 UTC (rev 6088)
@@ -33,6 +33,9 @@
*/
public class InclusiveGatewayTest extends JbpmTestCase {
+ /*
+ * Process with a simple inclusive split: 3 outgoing sequence flow (incl. 1 that always will be taken)
+ */
private static final String SIMPLE_SPLIT =
"<definitions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
" <process id='simpleInclusiveSplit' name='inclusiveSplit' >" +
@@ -87,6 +90,11 @@
" </process>" +
"</definitions>";
+ /*
+ * Simple process testing split and merge behaviour of the inclusive gateway.
+ * The first inclusive gateway has 3 outgoing sequence flow, that are merged later by
+ * a merging sequence flow.
+ */
private static final String SIMPLE_SPLIT_AND_MERGE =
"<definitions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
" <process id='simpleSplitAndMerge' name='inclusiveSplitAndMerge' >" +
@@ -112,6 +120,61 @@
" </process>" +
"</definitions>";
+ private static final String NESTED_INCLUSIVE_SPLIT =
+ "<definitions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
+ " <process id='nestedInclusiveSplit' name='nestedInclusiveSplit' >" +
+ " <startEvent id='theStart' />" +
+ " <sequenceFlow id='flow1' sourceRef='theStart' targetRef='inclusiveSplit' />" +
+ // Inclusive Split
+ " <inclusiveGateway id='inclusiveSplit' />" +
+ " <sequenceFlow id='flow2' sourceRef='inclusiveSplit' targetRef='wait1' >" +
+ " <conditionExpression xsi:type='tFormalExpression'>${var > 5}</conditionExpression>" +
+ " </sequenceFlow>" +
+ " <sequenceFlow id='flow3' sourceRef='inclusiveSplit' targetRef='wait2' />" +
+ " <sequenceFlow id='flow4' sourceRef='inclusiveSplit' targetRef='wait3' >" +
+ " <conditionExpression xsi:type='tFormalExpression'>${var > 10}</conditionExpression>" +
+ " </sequenceFlow>" +
+ // var > 5
+ " <receiveTask id='wait1' />" +
+ " <sequenceFlow id='flow5' sourceRef='wait1' targetRef='wait4' >" +
+ " <conditionExpression xsi:type='tFormalExpression'>${var == 6}</conditionExpression>" +
+ " </sequenceFlow>" +
+ " <sequenceFlow id='flow6a' sourceRef='wait1' targetRef='innerInclusiveSplit' >" +
+ " <conditionExpression xsi:type='tFormalExpression'>${var >= 7}</conditionExpression>" +
+ " </sequenceFlow>" +
+ " <sequenceFlow id='flow6b' sourceRef='wait1' targetRef='innerInclusiveSplit' >" +
+ " <conditionExpression xsi:type='tFormalExpression'>${var >= 9}</conditionExpression>" +
+ " </sequenceFlow>" +
+ // var == 6
+ " <receiveTask id='wait4' />" +
+ " <sequenceFlow id='flow7' sourceRef='wait4' targetRef='inclusiveMerge' />" +
+ // var >= 7 -> nested inclusive split
+ " <inclusiveGateway id='innerInclusiveSplit' default='flow10'/>" +
+ " <sequenceFlow id='flow8' sourceRef='innerInclusiveSplit' targetRef='wait5' >" +
+ " <conditionExpression xsi:type='tFormalExpression'>${var >= 8}</conditionExpression>" +
+ " </sequenceFlow>" +
+ " <sequenceFlow id='flow9' sourceRef='innerInclusiveSplit' targetRef='wait6' >" +
+ " <conditionExpression xsi:type='tFormalExpression'>${var >= 9}</conditionExpression>" +
+ " </sequenceFlow>" +
+ " <sequenceFlow id='flow10' sourceRef='innerInclusiveSplit' targetRef='wait7' />" +
+ " <receiveTask id='wait5' />" +
+ " <sequenceFlow id='flow11' sourceRef='wait5' targetRef='inclusiveMerge' />" +
+ " <receiveTask id='wait6' />" +
+ " <sequenceFlow id='flow12' sourceRef='wait6' targetRef='inclusiveMerge' />" +
+ " <receiveTask id='wait7' />" +
+ " <sequenceFlow id='flow13' sourceRef='wait7' targetRef='inclusiveMerge' />" +
+ // 'always' sequence flow on outer inclusive split
+ " <receiveTask id='wait2' />" +
+ " <sequenceFlow id='flow14' sourceRef='wait2' targetRef='inclusiveMerge' />" +
+ " <receiveTask id='wait3' />" +
+ // var > 10
+ " <sequenceFlow id='flow15' sourceRef='wait3' targetRef='inclusiveMerge' />" +
+ " <inclusiveGateway id='inclusiveMerge' />" +
+ " <sequenceFlow id='flow16' sourceRef='inclusiveMerge' targetRef='theEnd' />" +
+ " <endEvent id='theEnd' />" +
+ " </process>" +
+ "</definitions>";
+
public void testSimpleSplit() {
deployBpmn2XmlString(SIMPLE_SPLIT);
@@ -148,6 +211,29 @@
assertProcessInstanceEnded(pi);
}
+ public void testNestedInclusiveSplit() {
+ deployBpmn2XmlString(NESTED_INCLUSIVE_SPLIT);
+
+ // If var == 6, then the nested inclusive split will not be reached
+ // The inclusive merge will then have to merge two incoming sequence flow
+ /*ProcessInstance pi = startAndVerifySimpleSplitProcess("nestedInclusiveSplit", 6, "wait1", "wait2");
+ pi = executionService.signalExecutionById(pi.findActiveExecutionIn("wait1").getId());
+ assertActivitiesActive(pi.getId(), "wait2", "wait4");
+ pi = executionService.signalExecutionById(pi.findActiveExecutionIn("wait2").getId());
+ pi = executionService.signalExecutionById(pi.findActiveExecutionIn("wait4").getId());
+ assertProcessInstanceEnded(pi);*/
+
+ // If var == 9, the inclusive split will be reached and it will produce 2 outgoing sequence flow.
+ // The inclusive merge will have to merge three incoming sequence flow
+ ProcessInstance pi = startAndVerifySimpleSplitProcess("nestedInclusiveSplit", 9, "wait1", "wait2");
+ /*pi = executionService.signalExecutionById(pi.findActiveExecutionIn("wait1").getId());
+ assertActivitiesActive(pi.getId(), "wait2", "wait5", "wait6");
+ pi = executionService.signalExecutionById(pi.findActiveExecutionIn("wait5").getId());
+ pi = executionService.signalExecutionById(pi.findActiveExecutionIn("wait6").getId());
+ pi = executionService.signalExecutionById(pi.findActiveExecutionIn("wait2").getId());
+ assertProcessInstanceEnded(pi);*/
+ }
+
private ProcessInstance startAndVerifySimpleSplitProcess(String processKey, Integer varValue, String ... expectedActivities) {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("var", varValue);
More information about the jbpm-commits
mailing list