[jbpm-commits] JBoss JBPM SVN: r5974 - in jbpm4/trunk/modules: bpmn/src/main/java/org/jbpm/bpmn/flownodes and 8 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Dec 16 18:34:59 EST 2009
Author: jbarrez
Date: 2009-12-16 18:34:58 -0500 (Wed, 16 Dec 2009)
New Revision: 5974
Added:
jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.exclusive.gateway.png
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/gateway/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/gateway/exclusive/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/gateway/exclusive/ExclusiveGatewayTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/gateway/exclusive/ExclusiveGatewayWithDefaultSequenceFlowTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/exclusive/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway.bpmn.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway_default_seq_flow.bpmn.xml
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstance.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayActivity.java
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
Log:
JBPM-2661: BPMN 2.0 exclusive gateway
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstance.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstance.java 2009-12-16 20:46:03 UTC (rev 5973)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryProcessInstance.java 2009-12-16 23:34:58 UTC (rev 5974)
@@ -69,4 +69,8 @@
/** duration of the process instance in milliseconds or null
* if the process instance has not yet ended */
Long getDuration();
+
+ /** Returns the name of the end state that was reached when the process was ended.
+ */
+ String getEndActivityName();
}
\ No newline at end of file
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java 2009-12-16 20:46:03 UTC (rev 5973)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BpmnActivity.java 2009-12-16 23:34:58 UTC (rev 5974)
@@ -58,7 +58,9 @@
* Code copied basically from jPDL fork.
*/
protected void proceed(ExecutionImpl execution, List<Transition> transitions) {
- log.debug("Proceeding");
+ if (log.isDebugEnabled()) {
+ log.debug("Proceeding from execution " + execution.getActivityName());
+ }
Activity activity = execution.getActivity();
@@ -115,7 +117,9 @@
forkingTransitions.add(transition);
}
}
- log.debug(forkingTransitions.size() + " out of " + outgoingTransitions.size() + " selected for " + activity.getName());
+ if (log.isDebugEnabled()) {
+ log.debug(forkingTransitions.size() + " out of " + outgoingTransitions.size() + " selected for " + activity.getName());
+ }
return forkingTransitions;
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayActivity.java 2009-12-16 20:46:03 UTC (rev 5973)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ExclusiveGatewayActivity.java 2009-12-16 23:34:58 UTC (rev 5974)
@@ -27,8 +27,6 @@
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.bpmn.parser.BindingsParser;
import org.jbpm.internal.log.Log;
-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;
@@ -63,11 +61,19 @@
}
} else if (numTransitions > 2) {
transitions = transitions.subList(0, 0);
- log.info("More than one outgoing sequenceFlow conditions evaluated to true for " + execution.getActivity() + ", taking the first one ("
- + transitions.get(0).getName() + ")");
+ if (log.isInfoEnabled()) {
+ log.info("More than one outgoing sequenceFlow conditions evaluated to true for "
+ + execution.getActivity() + ", taking the first one ("
+ + transitions.get(0).getName() + ")");
+ }
}
-
- // 1 condition evaluated to true...
+
+ // We are now sure we have only one transition as result
+ Transition resultingTransition = transitions.get(0);
+ if (resultingTransition.getName() != null) {
+ execution.historyDecision(resultingTransition.getName());
+ }
+
proceed(execution, transitions);
}
Added: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.exclusive.gateway.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.exclusive.gateway.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-16 20:46:03 UTC (rev 5973)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-16 23:34:58 UTC (rev 5974)
@@ -138,7 +138,7 @@
<section id="gettingStartedWithBpmn2" >
- <title>Getting started with BPMN 2.0</title>
+ <title>Getting started</title>
<para>
@@ -178,127 +178,134 @@
</itemizedlist>
</para>
- <section id="bpmn2Config">
+ </section>
- <title>Configuration</title>
+ <section id="bpmn2Config">
+
+ <title>Configuration</title>
- <para>
- Enabling BPMN 2.0 in your application is extremely simple: just add the following line
- to the <emphasis role="bold">jbpm.cfg.xml</emphasis> file.
- <programlisting>
+ <para>
+ Enabling BPMN 2.0 in your application is extremely simple: just add the following line
+ to the <emphasis role="bold">jbpm.cfg.xml</emphasis> file.
+ <programlisting>
<import resource="jbpm.bpmn.cfg.xml" />
- </programlisting>
- This import will enable BPMN 2.0 process deployment by installing a BPMN 2.0 deployer
- in the Process Engine. Do note that a Process Engine can cope with both JPDL and BPMN 2.0
- processes. This means that in your application, some processes can be JPDL and others
- can be BPMN 2.0.
- </para>
+ </programlisting>
+ This import will enable BPMN 2.0 process deployment by installing a BPMN 2.0 deployer
+ in the Process Engine. Do note that a Process Engine can cope with both JPDL and BPMN 2.0
+ processes. This means that in your application, some processes can be JPDL and others
+ can be BPMN 2.0.
+ </para>
- <para>
- <emphasis role="bold">Process definitions are distinguished by the process engine
- based on the extension of the definition file. For BPMN 2.0, use the *.bpmn.xml extension
- (where JPDL is having the *.jpdl.xml extension).</emphasis>
- </para>
+ <para>
+ <emphasis role="bold">Process definitions are distinguished by the process engine
+ based on the extension of the definition file. For BPMN 2.0, use the *.bpmn.xml extension
+ (where JPDL is having the *.jpdl.xml extension).</emphasis>
+ </para>
- </section>
+ </section>
- <section id="bpmn2Examples">
+ <section id="bpmn2Examples">
- <title>Examples</title>
+ <title>Examples</title>
- <para>
- The examples that are shipped with the distribution also contain examples for every
- construct that is discussed in the following sections. Look for example BPMN 2.0
- processes and test cases in the <emphasis role="bold">org.jbpm.examples.bpmn.* package
- </emphasis>.
- </para>
+ <para>
+ The examples that are shipped with the distribution also contain examples for every
+ construct that is discussed in the following sections. Look for example BPMN 2.0
+ processes and test cases in the <emphasis role="bold">org.jbpm.examples.bpmn.* package
+ </emphasis>.
+ </para>
- <para>
- See the userguide, chapter 2 (Installation), for a walktough on how to import the examples.
- Look for the section <emphasis role="bold">'Importing the Examples'</emphasis>.
- </para>
+ <para>
+ See the userguide, chapter 2 (Installation), for a walktough on how to import the examples.
+ Look for the section <emphasis role="bold">'Importing the Examples'</emphasis>.
+ </para>
- </section>
+ </section>
- <section id="basicConstructs">
+ <section id="basicConstructs">
- <title>Basic constructs</title>
+ <title>Basic constructs</title>
- <section id="basicConstructsEvents">
+ <section id="basicConstructsEvents">
- <title>Events</title>
+ <title>Events</title>
- <para>
- Together with activitites and gateways, events are used in practically every business process.
- Events allow process modelers to describe business processes in a very natural way, such as
- <emphasis role="italic">'This process starts when I receive a customer order'</emphasis>,
- <emphasis role="italic">'If the task is not finished in 2 days, terminate the process'</emphasis>
- or <emphasis role="italic">'When I receive a cancel e-mail when the process is running,
- handle the e-mail using this sub-process'</emphasis>. Notice that typical businesses
- always work in a very event-driven way. People are not hard-coded sequential creatures,
- but they tend to react on things that happen in their environment (ie. events).
- In the BPMN specification, a great number of event types are described, to cover the
- range of possible things that might occur in context of a business.
- </para>
+ <para>
+ Together with activitites and gateways, events are used in practically every business process.
+ Events allow process modelers to describe business processes in a very natural way, such as
+ <emphasis role="italic">'This process starts when I receive a customer order'</emphasis>,
+ <emphasis role="italic">'If the task is not finished in 2 days, terminate the process'</emphasis>
+ or <emphasis role="italic">'When I receive a cancel e-mail when the process is running,
+ handle the e-mail using this sub-process'</emphasis>. Notice that typical businesses
+ always work in a very event-driven way. People are not hard-coded sequential creatures,
+ but they tend to react on things that happen in their environment (ie. events).
+ In the BPMN specification, a great number of event types are described, to cover the
+ range of possible things that might occur in context of a business.
+ </para>
+
+ </section>
- <section id="noneStartEvent">
+ <section id="noneStartEvent">
- <title>None start event</title>
+ <title>Event: None start event</title>
- <para>
- A start event indicates the start of process (or a subprocess). Graphically, it is visualized
- as a circle with (possibly) a small icon inside. The icon specifies the actual type of event
- that will trigger the process instance creation.
- </para>
+ <para>
+ A start event indicates the start of process (or a subprocess). Graphically, it is visualized
+ as a circle with (possibly) a small icon inside. The icon specifies the actual type of event
+ that will trigger the process instance creation.
+ </para>
- <para>
- The 'none start event' is drawn as a circle without an icon inside, which means that the
- trigger is unknown or unspecified. The start activity of JPDL basically has the same
- semantics. Process instances whose process definition has a 'none start event' are
- created using the typical API calls on the <emphasis role="bold">executionService</emphasis>.
- </para>
-
- <para>
- A none start event is defined as follows. An id is required, a name is optional.
- <programlisting>
+ <para>
+ The 'none start event' is drawn as a circle without an icon inside, which means that the
+ trigger is unknown or unspecified. The start activity of JPDL basically has the same
+ semantics. Process instances whose process definition has a 'none start event' are
+ created using the typical API calls on the <emphasis role="bold">executionService</emphasis>.
+ </para>
+
+ <para>
+ A none start event is defined as follows. An id is required, a name is optional.
+ <programlisting>
<startEvent id="start" name="myStart" />
- </programlisting>
- </para>
+ </programlisting>
+ </para>
- </section>
-
- <section id="noneEndEvent">
-
- <title>None end event</title>
-
- <para>
- An end event indicates the end of an execution path in a process instance. Graphically,
- it is visualized as a circle with a thick border with (possibly) a small icon inside.
- The icon specifies the type of signal that is thrown when the end is reached.
- </para>
+ </section>
+
+ <section id="noneEndEvent">
+
+ <title>Event: None end event</title>
+
+ <para>
+ An end event indicates the end of an execution path in a process
+ instance. Graphically,
+ it is visualized as a circle with a thick border with (possibly) a
+ small icon inside.
+ The icon specifies the type of signal that is thrown when the end is
+ reached.
+ </para>
- <para>
- The 'none end event' is drawn as a circle with thick border with no icon inside,
- which means that no signal is thrown when the execution reaches the event.
- The end activity in JPDL has the same semantics as the none end event.
- </para>
+ <para>
+ The 'none end event' is drawn as a circle with thick border with no icon inside,
+ which means that no signal is thrown when the execution reaches the event.
+ The end activity in JPDL has the same semantics as the none end event.
+ </para>
- <para>
- A none end event is defined as follows. An id is required, a name is optional.
- <programlisting>
+ <para>
+ A none end event is defined as follows. An id is required, a name is optional.
+ <programlisting>
<endEvent id="end" name="myEnd" />
- </programlisting>
- </para>
+ </programlisting>
+ </para>
- <para>
- The following example shows a process with only a none start and end event:
- <mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.none.start.end.event.png"/></imageobject></mediaobject>
- </para>
+ <para>
+ The following example shows a process with only a none start and end event:
+ <mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.none.start.end.event.png"/></imageobject></mediaobject>
+ </para>
- <para>
- The corresponding executable XML for this process looks like this (omitting the
- <emphasis role="italic">definitions</emphasis> root element for clarity)
- <programlisting>
+ <para>
+ The corresponding executable XML for this process looks like this (omitting the
+ <emphasis role="italic">definitions</emphasis> root element for clarity)
+ <programlisting>
<process id="noneStartEndEvent" name="BPMN2 Example none start and end event">
<startEvent id="start" />
@@ -309,56 +316,158 @@
<endEvent id="end" name="End" />
</process>
- </programlisting>
- </para>
+ </programlisting>
+ </para>
- <para>
- A process instances can now be created by calling the
- <emphasis role="bold">startProcessInstanceXXX</emphasis> operations.
- <programlisting>
+ <para>
+ A process instances can now be created by calling the
+ <emphasis role="bold">startProcessInstanceXXX</emphasis> operations.
+ <programlisting>
ProcessInstance processInstance = executionService.startProcessInstanceByKey("noneStartEndEvent");
- </programlisting>
- </para>
+ </programlisting>
+ </para>
- </section>
+ </section>
- <section id="terminateEndEvent">
+ <section id="terminateEndEvent">
- <title>Terminate end event</title>
+ <title>Event: Terminate end event</title>
- <para>
- The difference between a 'terminate' and a <link linkend="noneEndEvent">'none' end event</link>
- lies in the fact how a path of execution is treated (or a 'token' in BPMN 2.0 terminology).
- The 'terminate' end event will end the complete process instance, whereas the 'none'
- end event will only end the current path of execution. They both don't throw anything
- when the end event is reached.
- </para>
+ <para>
+ The difference between a 'terminate' and a <link linkend="noneEndEvent">'none' end event</link>
+ lies in the fact how a path of execution is treated (or a 'token' in BPMN 2.0 terminology).
+ The 'terminate' end event will end the complete process instance, whereas the 'none'
+ end event will only end the current path of execution. They both don't throw anything
+ when the end event is reached.
+ </para>
- <para>
- A terminate end event is defined as follows. An id is required, a name is optional.
- <programlisting>
+ <para>
+ A terminate end event is defined as follows. An id is required, a name is optional.
+ <programlisting>
<endEvent id="terminateEnd" name="myTerminateEnd">
<terminateEventDefinition/>
</endEvent>
- </programlisting>
- </para>
+ </programlisting>
+ </para>
- <para>
- A terminate end event is depicted as a typical end event (circle with thick border),
- with a full circle as icon inside. In the following example, completing the 'task1'
- will end the process instance, while completing the 'task2' will only end the path
- of execution which enters the end event.
- <mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.terminate.end.event.example.png"/></imageobject></mediaobject>
- See the examples shipped with the jBPM distribution for the unit test and XML counterpart
- of this business process.
- </para>
+ <para>
+ A terminate end event is depicted as a typical end event (circle with thick border),
+ with a full circle as icon inside. In the following example, completing the 'task1'
+ will end the process instance, while completing the 'task2' will only end the path
+ of execution which enters the end event.
+ <mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.terminate.end.event.example.png"/></imageobject></mediaobject>
+ See the examples shipped with the jBPM distribution for the unit test and XML counterpart
+ of this business process.
+ </para>
- </section>
+ </section>
+
+ <section id="gateway">
+
+ <title>Gateways</title>
+
+ <para>
+ A gateway in BPMN is used to control the flow through the process. More specifically,
+ when a token (the BPMN 2.0 conceptual notion of an execution) arrives in a gateway, they can be merged
+ or split depending on the gateway type.
+ </para>
- </section> <!-- End of basic events section -->
+ <para>
+ Gateways are depicted as a diamond shape, with an icon inside specifying the type
+ (exclusive, inclusive, etc.).
+ </para>
- </section> <!-- End of basic constructs section -->
+ </section>
+
+ <section id="exclusiveGateway">
+
+ <title>Gateway: Exclusive Gateway</title>
+
+ <para>
+ An exclusive gateway represents an <emphasis role="bold">exclusive decision</emphasis>
+ in the process. Exactly one outgoing sequence flow will be taken, depending on the conditions
+ defined on the sequence flows.
+ </para>
+
+ <para>
+ The corresponding JPDL construct with the same semantics is the
+ <emphasis role="bold"><decision></emphasis> activity. The full technical name of the
+ exclusive gateway is the <emphasis role="bold">'exclusive data-based gateway'</emphasis>,
+ but it is also often called the <emphasis role="bold">XOR Gateway</emphasis>.
+ The XOR gateway is depicted as a diamond with a plus icon inside. An empty diamond
+ without a gateway also signifies an exclusive gateway.
+ </para>
+
+ <para>
+ The following diagram shows the usage of an exclusive gateway: depending on the value of the
+ amount variable, one of the three outgoing sequence flows out of the exclusive gateway
+ is chosen.
+ <mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.exclusive.gateway.png"/></imageobject></mediaobject>
+ The corresponding executable XML of this process looks as follows.
+ Note that the conditions are defined on the sequence flows. The exclusive gateway will select
+ the single sequence flow for which its condition evaluates to true. If multiple conditions
+ evaluate to true, the first one encountered will be taken (a log message will indicate
+ this situation).
+ <programlisting>
+ <process id="exclusiveGateway" name="BPMN2 Example exclusive gateway">
+
+ <startEvent id="start" />
+
+ <sequenceFlow id="flow1" name="fromStartToExclusiveGateway"
+ sourceRef="start" targetRef="decideBasedOnAmountGateway" />
+
+ <exclusiveGateway id="decideBasedOnAmountGateway" name="decideBasedOnAmount" />
+
+ <sequenceFlow id="flow2" name="fromGatewayToEndNotEnough"
+ sourceRef="decideBasedOnAmountGateway" targetRef="endNotEnough">
+ <conditionExpression xsi:type="tFormalExpression">${amount < 100}</conditionExpression>
+ </sequenceFlow>
+
+ <sequenceFlow id="flow3" name="fromGatewayToEnEnough"
+ sourceRef="decideBasedOnAmountGateway" targetRef="endEnough">
+ <conditionExpression xsi:type="tFormalExpression">${amount <= 500 && amount >= 100}</conditionExpression>
+ </sequenceFlow>
+
+ <sequenceFlow id="flow4" name="fromGatewayToMoreThanEnough"
+ sourceRef="decideBasedOnAmountGateway" targetRef="endMoreThanEnough">
+ <conditionExpression xsi:type="tFormalExpression">${amount > 500}</conditionExpression>
+ </sequenceFlow>
+
+ <endEvent id="endNotEnough" name="not enough" />
+
+ <endEvent id="endEnough" name="enough" />
+
+ <endEvent id="endMoreThanEnough" name="more than enough" />
+
+ </process>
+ </programlisting>
+ This process needs a variable such that the expression can be evauluated at runtime.
+ Variables can be provided when starting the process instance (similar to JPDL):
+ <programlisting>
+Map<String, Object> vars = new HashMap<String, Object>();
+vars.put("amount", amount);
+ProcessInstance processInstance = executionService.startProcessInstanceByKey("exclusiveGateway", vars);
+ </programlisting>
+ </para>
+
+ <para>
+ The exclusive gateway requires that all outgoing sequence flows have conditions defined
+ on them. An exception to this rule is the default sequence flow, as defined above.
+ The exclusive gateway also has a shortcut attribute to define such a default sequence flow.
+ Use the <emphasis role="bold">default attribute</emphasis> to reference an existing
+ <emphasis role="bold">id of a sequence flow</emphasis>. This sequence flow will be taken
+ when the conditions on the other outgoing sequence flows all evaluate to false.
+ <programlisting>
+<exclusiveGateway id="decision" name="decideBasedOnAmountAndBankType" default="myFlow"/>
+
+<sequenceFlow id="myFlow" name="fromGatewayToStandard"
+ sourceRef="decision" targetRef="standard">
+</sequenceFlow>
+ </programlisting>
+ </para>
+
+ </section>
- </section> <!-- End of Bpmn 2.0 execution section -->
+ </section> <!-- End of basic constructs section -->
</chapter>
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/gateway/exclusive/ExclusiveGatewayTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/gateway/exclusive/ExclusiveGatewayTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/gateway/exclusive/ExclusiveGatewayTest.java 2009-12-16 23:34:58 UTC (rev 5974)
@@ -0,0 +1,72 @@
+/*
+ * 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.examples.bpmn.gateway.exclusive;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ *
+ * @author Joram Barrez
+ */
+public class ExclusiveGatewayTest extends JbpmTestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ NewDeployment deployment = repositoryService.createDeployment();
+ deployment.addResourceFromClasspath("org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway.bpmn.xml");
+ registerDeployment(deployment.deploy());
+ }
+
+ public void testWithAmountLowerThan100() {
+ startAndVerifyProcess(44, "endNotEnough");
+ }
+
+ public void testWithAmountBetween100And500() {
+ startAndVerifyProcess(124, "endEnough");
+ }
+
+ public void testWithAmountMoreThan500() {
+ startAndVerifyProcess(1000, "endMoreThanEnough");
+ }
+
+ private void startAndVerifyProcess(int amount, String endId) {
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("amount", amount);
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("exclusiveGateway", vars);
+ assertProcessInstanceEnded(processInstance);
+
+ HistoryProcessInstance historyProcessInstance =
+ historyService.createHistoryProcessInstanceQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+ assertEquals(endId, historyProcessInstance.getEndActivityName());
+ }
+
+}
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/gateway/exclusive/ExclusiveGatewayWithDefaultSequenceFlowTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/gateway/exclusive/ExclusiveGatewayWithDefaultSequenceFlowTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/gateway/exclusive/ExclusiveGatewayWithDefaultSequenceFlowTest.java 2009-12-16 23:34:58 UTC (rev 5974)
@@ -0,0 +1,74 @@
+/*
+ * 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.examples.bpmn.gateway.exclusive;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ *
+ * @author Joram Barrez
+ */
+public class ExclusiveGatewayWithDefaultSequenceFlowTest extends JbpmTestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ NewDeployment deployment = repositoryService.createDeployment();
+ deployment.addResourceFromClasspath("org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway_default_seq_flow.bpmn.xml");
+ registerDeployment(deployment.deploy());
+ }
+
+ public void testWithLargeDeposit() {
+ startAndVerifyProcess(9999, "localBank", "largeDeposit");
+ }
+
+ public void testWithForeignBankt() {
+ startAndVerifyProcess(9999, "foreign", "foreignBank");
+ }
+
+ public void testDefaultSequenceFlow() {
+ startAndVerifyProcess(1, "local", "standard");
+ }
+
+ private void startAndVerifyProcess(int amount, String bankType, String endId) {
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("amount", amount);
+ vars.put("bankType", bankType);
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("exclusiveGatewayDefaultSeqFlow", vars);
+ assertProcessInstanceEnded(processInstance);
+
+ HistoryProcessInstance historyProcessInstance =
+ historyService.createHistoryProcessInstanceQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+ assertEquals(endId, historyProcessInstance.getEndActivityName());
+ }
+
+
+}
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway.bpmn.xml 2009-12-16 23:34:58 UTC (rev 5974)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
+ xmlns="http://schema.omg.org/spec/BPMN/2.0"
+ typeLanguage="http://www.w3.org/2001/XMLSchema"
+ expressionLanguage="http://www.w3.org/1999/XPath"
+ targetNamespace="http://jbpm.org/example/bpmn2/exclusive_gateway"
+ xmlns:jbpm="http://jbpm.org/bpmn2">
+
+ <process id="exclusiveGateway" name="BPMN2 Example exclusive gateway">
+
+ <startEvent id="start" />
+
+ <sequenceFlow id="flow1" name="fromStartToExclusiveGateway"
+ sourceRef="start" targetRef="decideBasedOnAmountGateway" />
+
+ <exclusiveGateway id="decideBasedOnAmountGateway" name="decideBasedOnAmount" />
+
+ <sequenceFlow id="flow2" name="fromGatewayToEndNotEnough"
+ sourceRef="decideBasedOnAmountGateway" targetRef="endNotEnough">
+ <conditionExpression xsi:type="tFormalExpression">${amount < 100}</conditionExpression>
+ </sequenceFlow>
+
+ <sequenceFlow id="flow3" name="fromGatewayToEnEnough"
+ sourceRef="decideBasedOnAmountGateway" targetRef="endEnough">
+ <conditionExpression xsi:type="tFormalExpression">${amount <= 500 && amount >= 100}</conditionExpression>
+ </sequenceFlow>
+
+ <sequenceFlow id="flow4" name="fromGatewayToMoreThanEnough"
+ sourceRef="decideBasedOnAmountGateway" targetRef="endMoreThanEnough">
+ <conditionExpression xsi:type="tFormalExpression">${amount > 500}</conditionExpression>
+ </sequenceFlow>
+
+ <endEvent id="endNotEnough" name="not enough" />
+
+ <endEvent id="endEnough" name="enough" />
+
+ <endEvent id="endMoreThanEnough" name="more than enough" />
+
+ </process>
+
+</definitions>
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway_default_seq_flow.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway_default_seq_flow.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway_default_seq_flow.bpmn.xml 2009-12-16 23:34:58 UTC (rev 5974)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
+ xmlns="http://schema.omg.org/spec/BPMN/2.0"
+ typeLanguage="http://www.w3.org/2001/XMLSchema"
+ expressionLanguage="http://www.w3.org/1999/XPath"
+ targetNamespace="http://jbpm.org/example/bpmn2/exclusive_gateway"
+ xmlns:jbpm="http://jbpm.org/bpmn2">
+
+ <process id="exclusiveGatewayDefaultSeqFlow" name="BPMN2 Example exclusive gateway with a default sequence flow">
+
+ <startEvent id="start" />
+
+ <sequenceFlow id="flow1" name="fromStartToExclusiveGateway"
+ sourceRef="start" targetRef="decision" />
+
+ <exclusiveGateway id="decision" name="decideBasedOnAmountAndBankType" default="flow2"/>
+
+ <sequenceFlow id="flow2" name="fromGatewayToStandard"
+ sourceRef="decision" targetRef="standard">
+ </sequenceFlow>
+
+ <sequenceFlow id="flow3" name="fromGatewayToEnEnough"
+ sourceRef="decision" targetRef="largeDeposit">
+ <conditionExpression xsi:type="tFormalExpression">${amount >= 500 && bankType != 'foreign'}</conditionExpression>
+ </sequenceFlow>
+
+ <sequenceFlow id="flow4" name="fromGatewayToMoreThanEnough"
+ sourceRef="decision" targetRef="foreignBank">
+ <conditionExpression xsi:type="tFormalExpression">${bankType == 'foreign'}</conditionExpression>
+ </sequenceFlow>
+
+ <endEvent id="standard" name="standard end" />
+
+ <endEvent id="largeDeposit" name="large deposit" />
+
+ <endEvent id="foreignBank" name="foreign bank" />
+
+ </process>
+
+</definitions>
More information about the jbpm-commits
mailing list