JBoss JBPM SVN: r6131 - in jbpm4/trunk/modules: devguide/src/main/docbook/en/modules and 14 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2010-01-26 06:30:19 -0500 (Tue, 26 Jan 2010)
New Revision: 6131
Added:
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_human_performer_user.bpmn.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_human_performer_variable.bpmn.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_potential_owner_group.bpmn.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_potential_owner_user.bpmn.xml
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/nonestartend/none_start_end_event.bpmn.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/terminateend/terminate_end_event.bpmn.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml
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
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/inclusive/inclusive_gateway.bpmn.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/parallel/parallel_gateway.bpmn.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/receive/receive_task_java.bpmn.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/taskform/vacationrequest.bpmn.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/ExclusiveGatewayMergeTest.java
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/ParallelGatewayMergeTest.java
jbpm4/trunk/modules/test-db/src/test/resources/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/simplestProcess.bpmn.xml
Log:
Refactored name/key usage in BPMN2: the id is mapped to the procDef name (ie required) and the name is mapped to the key.
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 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2010-01-26 11:30:19 UTC (rev 6131)
@@ -111,18 +111,14 @@
parse.contextStackPush(processDefinition);
try {
- // process attribues
+ String id = XmlUtil.attribute(processElement, "id", false, parse);
String name = XmlUtil.attribute(processElement, "name", false, parse);
- processDefinition.setName(name);
+
+ processDefinition.setName(id);
- String key = XmlUtil.attribute(processElement, "id", false, parse);
- if (key != null) {
- processDefinition.setKey(key);
+ if (name != null) {
+ processDefinition.setKey(name);
}
-
- if (name == null) {
- processDefinition.setName(key);
- }
Element descriptionElement = XmlUtil.element(processElement, "documentation");
if (descriptionElement != null) {
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 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -219,8 +219,8 @@
The root of an BPMN 2.0 XML process is the <emphasis role="bold">definitions</emphasis>
elements. As the name states, the subelements will contain the actual definitions of
the business process(es). Every <emphasis role="bold">process</emphasis> child
- will be able to have an <emphasis role="bold">id</emphasis> and
- <emphasis role="bold">name</emphasis>. An empty business process in BPMN 2.0
+ will be able to have an <emphasis role="bold">id (required)</emphasis> and
+ <emphasis role="bold">name (optional)</emphasis>. An empty business process in BPMN 2.0
looks as follows. Also note that it is handy to have the BPMN2.xsd on the classpath, to
enable XML completion.
<programlisting>
@@ -232,16 +232,18 @@
expressionLanguage="http://www.w3.org/1999/XPath"
targetNamespace="http://jbpm.org/example/bpmn2">
- <process id="myBusinessProcess" name="My business processs">
+ <process id="My business processs" name="myBusinessProcess">
...
</process>
<definitions>
</programlisting>
- If an id is defined for a process element, it will be used as business key for that
- process (ie. starting a process can be done by calling executionService.startProcessInstanceByKey("myBusinessProcess"),
- otherwise the jBPM engine will create a unique process key (same mechanism as for JPDL).
+ If a name is defined for the process element, it is be used as <emphasis role="bold">key</emphasis>
+ for that process (ie. starting a process can be done by calling executionService.startProcessInstanceByKey("myBusinessProcess").
+ If no name is defined, the id will be used as key. So having only an id defined, will allow
+ to start a process instance using that id. Note that for a key the same rules apply as with
+ JPDL: whitespace and non alpha-numeric characters are replace by an underscore.
</para>
</section>
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/nonestartend/none_start_end_event.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/nonestartend/none_start_end_event.bpmn.xml 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/nonestartend/none_start_end_event.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -8,7 +8,7 @@
targetNamespace="http://jbpm.org/example/bpmn2/none_start_end_event"
xmlns:jbpm="http://jbpm.org/bpmn2">
- <process id="noneStartEndEvent" name="BPMN2 Example none start and end event">
+ <process id="noneStartEndEvent">
<startEvent id="start" />
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/terminateend/terminate_end_event.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/terminateend/terminate_end_event.bpmn.xml 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/terminateend/terminate_end_event.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -8,7 +8,7 @@
targetNamespace="http://jbpm.org/example/bpmn2/terminate_end_event"
xmlns:jbpm="http://jbpm.org/bpmn2">
- <process id="terminateEndEvent" name="BPMN2 Example terminate end event">
+ <process id="terminateEndEvent">
<startEvent id="start" />
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -5,7 +5,7 @@
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/intermediateTimerCatch">
- <process id="intermediateTimerCatch" name="Bpmn 2.0 example intermediate timer catch event">
+ <process id="intermediateTimerCatch">
<startEvent id="theStart" />
Modified: 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 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -8,7 +8,7 @@
targetNamespace="http://jbpm.org/example/bpmn2/exclusive_gateway"
xmlns:jbpm="http://jbpm.org/bpmn2">
- <process id="exclusiveGateway" name="BPMN2 Example exclusive gateway">
+ <process id="exclusiveGateway">
<startEvent id="start" />
Modified: 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 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/exclusive/exclusive_gateway_default_seq_flow.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -8,7 +8,7 @@
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">
+ <process id="exclusiveGatewayDefaultSeqFlow">
<startEvent id="start" />
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/inclusive/inclusive_gateway.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/inclusive/inclusive_gateway.bpmn.xml 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/inclusive/inclusive_gateway.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -8,7 +8,7 @@
targetNamespace="http://jbpm.org/example/bpmn2/inclusive_gatewat"
xmlns:jbpm="http://jbpm.org/bpmn2">
- <process id="inclusiveGateway" name="BPMN2 Example inclusive gateway">
+ <process id="inclusiveGateway">
<startEvent id="start" />
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/parallel/parallel_gateway.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/parallel/parallel_gateway.bpmn.xml 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/gateway/parallel/parallel_gateway.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -5,7 +5,7 @@
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/parallel_gateway">
- <process id="parallelGateway" name="BPMN2 example parallel gateway">
+ <process id="parallelGateway">
<startEvent id="Start" />
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/receive/receive_task_java.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/receive/receive_task_java.bpmn.xml 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/receive/receive_task_java.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -5,7 +5,7 @@
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/receiveTaskJava">
- <process id="receiveTaskJava" name="Bpmn 2.0 example receive task Java">
+ <process id="receiveTaskJava">
<startEvent id="Start" />
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -30,7 +30,7 @@
</bpmn:operation>
</bpmn:interface>
- <bpmn:process id="ServiceTaskJavaProcess" name="BPMN 2.0 example java service task">
+ <bpmn:process id="ServiceTaskJavaProcess">
<bpmn:startEvent id="Start" />
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/taskform/vacationrequest.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/taskform/vacationrequest.bpmn.xml 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/taskform/vacationrequest.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -6,7 +6,7 @@
expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://jbpm.org/example/bpmn2/vacation_request"
xmlns:jbpm="http://jbpm.org/bpmn2">
- <process id="vacationRequestProcess" name="BPMN2 Example process using task forms">
+ <process id="vacationRequestProcess">
<startEvent id="start" />
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_human_performer_user.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_human_performer_user.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_human_performer_user.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -0,0 +1,32 @@
+<?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/human_performer"
+ xmlns:jbpm="http://jbpm.org/bpmn2">
+
+ <resource id="employee" name="employee" />
+
+ <process id="userTaskHumanPerformerUser">
+
+ <startEvent id="start" />
+
+ <sequenceFlow id="flow1" sourceRef="start" targetRef="myTask" />
+
+ <userTask id="myTask" name="My User task">
+ <humanPerformer resourceRef="employee">
+ <resourceAssignmentExpression>
+ <formalExpression>mary</formalExpression>
+ </resourceAssignmentExpression>
+ </humanPerformer>
+ </userTask>
+
+ <sequenceFlow id="flow2" sourceRef="myTask" targetRef="end" />
+
+ <endEvent id="end" name="End" />
+
+
+ </process>
+</definitions>
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_human_performer_variable.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_human_performer_variable.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_human_performer_variable.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -0,0 +1,32 @@
+<?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/human_performer"
+ xmlns:jbpm="http://jbpm.org/bpmn2">
+
+ <resource id="employee" name="employee" />
+
+ <process id="userTaskHumanPerformerVariable">
+
+ <startEvent id="start" />
+
+ <sequenceFlow id="flow1" sourceRef="start" targetRef="myTask" />
+
+ <userTask id="myTask" name="My User task">
+ <humanPerformer resourceRef="employee">
+ <resourceAssignmentExpression>
+ <formalExpression>${user}</formalExpression>
+ </resourceAssignmentExpression>
+ </humanPerformer>
+ </userTask>
+
+ <sequenceFlow id="flow2" sourceRef="myTask" targetRef="end" />
+
+ <endEvent id="end" name="End" />
+
+
+ </process>
+</definitions>
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_potential_owner_group.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_potential_owner_group.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_potential_owner_group.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -0,0 +1,32 @@
+<?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/potential_owner"
+ xmlns:jbpm="http://jbpm.org/bpmn2">
+
+ <resource id="manager" name="manager" />
+
+ <process id="userTaskPotentialOwnerGroup">
+
+ <startEvent id="start" />
+
+ <sequenceFlow id="flow1" sourceRef="start" targetRef="myTask" />
+
+ <userTask id="myTask" name="My User task">
+ <potentialOwner resourceRef="manager" jbpm:type="group">
+ <resourceAssignmentExpression>
+ <formalExpression>management</formalExpression>
+ </resourceAssignmentExpression>
+ </potentialOwner>
+ </userTask>
+
+ <sequenceFlow id="flow2" sourceRef="myTask" targetRef="end" />
+
+ <endEvent id="end" name="End" />
+
+
+ </process>
+</definitions>
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_potential_owner_user.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_potential_owner_user.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/usertask/user_task_potential_owner_user.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -0,0 +1,32 @@
+<?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/potential_owner"
+ xmlns:jbpm="http://jbpm.org/bpmn2">
+
+ <resource id="employee" name="employee" />
+
+ <process id="userTaskPotentialOwnerUser">
+
+ <startEvent id="start" />
+
+ <sequenceFlow id="flow1" sourceRef="start" targetRef="myTask" />
+
+ <userTask id="myTask" name="My User task">
+ <potentialOwner resourceRef="employee" jbpm:type="user">
+ <resourceAssignmentExpression>
+ <formalExpression>peter</formalExpression>
+ </resourceAssignmentExpression>
+ </potentialOwner>
+ </userTask>
+
+ <sequenceFlow id="flow2" sourceRef="myTask" targetRef="end" />
+
+ <endEvent id="end" name="End" />
+
+
+ </process>
+</definitions>
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/ProcessDeployer.java 2010-01-26 11:30:19 UTC (rev 6131)
@@ -137,7 +137,7 @@
for (ProcessDefinition existingProcess: existingProcesses) {
if (!processDefinitionKey.equals(existingProcess.getKey())) {
- deployment.addProblem("invalid key '"+processDefinitionKey+"' in process "+processDefinition.getName()+". Existing process has name '"+processDefinitionName+"' and key '"+processDefinitionKey+"'");
+ deployment.addProblem("invalid key '"+processDefinitionKey+"' in process "+processDefinition.getName()+". Existing process has name '"+processDefinitionName+"' and key '"+existingProcess.getKey()+"'");
}
}
@@ -147,7 +147,7 @@
for (ProcessDefinition existingProcess: existingProcesses) {
if (!processDefinitionName.equals(existingProcess.getName())) {
- deployment.addProblem("invalid name '"+processDefinitionName+"' in process "+processDefinition.getName()+". Existing process has name '"+processDefinitionName+"' and key '"+processDefinitionKey+"'");
+ deployment.addProblem("invalid name '"+processDefinitionName+"' in process "+processDefinition.getName()+". Existing process has name '"+existingProcess.getName()+"' and key '"+processDefinitionKey+"'");
}
}
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/ExclusiveGatewayMergeTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/ExclusiveGatewayMergeTest.java 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/ExclusiveGatewayMergeTest.java 2010-01-26 11:30:19 UTC (rev 6131)
@@ -38,7 +38,7 @@
private static final String TEST_PROCESS =
"<definitions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
- " <process id='testProcess' name='exclusiveMerge' >" +
+ " <process id='exclusiverMerge' >" +
" <startEvent id='theStart' />" +
" <sequenceFlow id='flow1' sourceRef='theStart' targetRef='decision' />" +
" <sequenceFlow id='flow2' sourceRef='theStart' targetRef='decision' />" +
@@ -63,7 +63,7 @@
public void testExclusiveMerge() {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("var", 5);
- executionService.startProcessInstanceByKey("testProcess", vars);
+ executionService.startProcessInstanceByKey("exclusiverMerge", vars);
HistoryActivityInstanceQuery query = historyService.createHistoryActivityInstanceQuery().activityName("decision");
List<HistoryActivityInstance> historyActivities = query.list();
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-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/InclusiveGatewayTest.java 2010-01-26 11:30:19 UTC (rev 6131)
@@ -38,7 +38,7 @@
*/
private static final String SIMPLE_SPLIT =
"<definitions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
- " <process id='simpleInclusiveSplit' name='inclusiveSplit' >" +
+ " <process id='simpleInclusiveSplit' >" +
" <startEvent id='theStart' />" +
" <sequenceFlow id='flow1' sourceRef='theStart' targetRef='inclusiveGateway' />" +
" <inclusiveGateway id='inclusiveGateway' />" +
@@ -67,7 +67,7 @@
*/
private static final String SIMPLE_SPLIT_WITH_DEFAULT =
"<definitions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
- " <process id='simpleInclusiveSplitWithDefault' name='inclusiveSplitWithDefault' >" +
+ " <process id='simpleInclusiveSplitWithDefault' >" +
" <startEvent id='theStart' />" +
" <sequenceFlow id='flow1' sourceRef='theStart' targetRef='inclusiveGateway' />" +
" <inclusiveGateway id='inclusiveGateway' default='flow3' />" +
@@ -97,7 +97,7 @@
*/
private static final String SIMPLE_SPLIT_AND_MERGE =
"<definitions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
- " <process id='simpleSplitAndMerge' name='inclusiveSplitAndMerge' >" +
+ " <process id='simpleSplitAndMerge' >" +
" <startEvent id='theStart' />" +
" <sequenceFlow id='flow1' sourceRef='theStart' targetRef='inclusiveSplit' />" +
" <inclusiveGateway id='inclusiveSplit' default='flow3' />" +
@@ -125,7 +125,7 @@
*/
private static final String NESTED_INCLUSIVE_SPLIT =
"<definitions xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>" +
- " <process id='nestedInclusiveSplit' name='nestedInclusiveSplit' >" +
+ " <process id='nestedInclusiveSplit' >" +
" <startEvent id='theStart' />" +
" <sequenceFlow id='flow1' sourceRef='theStart' targetRef='inclusiveSplit' />" +
// Inclusive Split
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/ParallelGatewayMergeTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/ParallelGatewayMergeTest.java 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/gateway/ParallelGatewayMergeTest.java 2010-01-26 11:30:19 UTC (rev 6131)
@@ -37,7 +37,7 @@
/* Test process with parallel gateway that has 3 incoming and 2 outgoing sequence flow */
private static final String TEST_SIMPLE_MERGE_PROCESS =
"<definitions>" +
- " <process id='simpleMerge' name='parallelMerge' >" +
+ " <process id='simpleMerge'>" +
" <startEvent id='theStart' />" +
" <sequenceFlow id='flow1' sourceRef='theStart' targetRef='parallelGateway' />" +
" <sequenceFlow id='flow2' sourceRef='theStart' targetRef='parallelGateway' />" +
@@ -62,7 +62,7 @@
*/
private static final String TEST_NESTED_MERGE_PROCESS =
"<definitions>" +
- " <process id='nestedMerge' name='parallelNestedMerge' >" +
+ " <process id='nestedMerge'>" +
" <startEvent id='theStart' />" +
" <sequenceFlow id='flow1' sourceRef='theStart' targetRef='outerFork' />" +
" <parallelGateway id='outerFork' />" +
@@ -89,7 +89,7 @@
*/
private static final String TEST_NESTED_MERGE_PROCESS_2 =
"<definitions>" +
- " <process id='nestedMerge2' name='parallelNestedMerge2' >" +
+ " <process id='nestedMerge2' >" +
" <startEvent id='theStart' />" +
" <sequenceFlow id='flow1' sourceRef='theStart' targetRef='outerFork' />" +
" <parallelGateway id='outerFork' />" +
Modified: jbpm4/trunk/modules/test-db/src/test/resources/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/jbpm.hibernate.cfg.xml 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/test-db/src/test/resources/jbpm.hibernate.cfg.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -7,11 +7,23 @@
<hibernate-configuration>
<session-factory>
+ <!-- MySQL
+ <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
+ <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
+ <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jbpm</property>
+ <property name="hibernate.connection.username">jbpm</property>
+ <property name="hibernate.connection.password">jbpm</property>
+ -->
+
+ <!-- HSQLDB -->
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
+
+
+
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<property name="hibernate.format_sql">true</property>
Modified: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/simplestProcess.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/simplestProcess.bpmn.xml 2010-01-26 09:05:57 UTC (rev 6130)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/simplestProcess.bpmn.xml 2010-01-26 11:30:19 UTC (rev 6131)
@@ -7,7 +7,7 @@
expressionLanguage="http://www.w3.org/1999/XPath"
targetNamespace="http://www.jbpm.org/bpmn2/example" >
- <process id="simplestProcess" name="The Simplest Process" processType="executable">
+ <process id="simplestProcess" processType="executable">
<startEvent id="theStart" />
16 years, 2 months
JBoss JBPM SVN: r6130 - jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2010-01-26 04:05:57 -0500 (Tue, 26 Jan 2010)
New Revision: 6130
Modified:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java
Log:
Fix failing TimerTest
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java 2010-01-26 01:41:10 UTC (rev 6129)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java 2010-01-26 09:05:57 UTC (rev 6130)
@@ -33,6 +33,7 @@
import org.jbpm.api.job.Job;
import org.jbpm.api.listener.EventListener;
import org.jbpm.api.listener.EventListenerExecution;
+import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.test.JbpmTestCase;
/**
@@ -252,6 +253,7 @@
Map<String, Object> proc_vars = new HashMap<String, Object>();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_MONTH, 6);
+
proc_vars.put("proc_var", cal);
ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
@@ -263,7 +265,8 @@
jobDate.setTime(job.getDuedate());
// 6 days from now minus 5 days is tomorrow so subtract 5 from the original added 6.
- assertEquals(cal.get(Calendar.DAY_OF_MONTH) -5 , jobDate.get(Calendar.DAY_OF_MONTH));
+ cal.add(Calendar.DAY_OF_MONTH, -5);
+ assertEquals(cal.get(Calendar.DAY_OF_MONTH) , jobDate.get(Calendar.DAY_OF_MONTH));
managementService.executeJob(job.getId());
assertProcessInstanceEnded(processInstance);
16 years, 2 months
JBoss JBPM SVN: r6129 - in jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph: node and 1 other directory.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-01-25 20:41:10 -0500 (Mon, 25 Jan 2010)
New Revision: 6129
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Transition.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/EndState.java
Log:
improve hashCode/equals for GraphElement and Transition
simplify endCompleteProcess check in EndState
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2010-01-25 23:17:12 UTC (rev 6128)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2010-01-26 01:41:10 UTC (rev 6129)
@@ -210,7 +210,8 @@
}
// execute the runtime actions
- List runtimeActions = getRuntimeActionsForEvent(executionContext, eventType);
+ List runtimeActions =
+ getRuntimeActionsForEvent(executionContext, eventType);
executeActions(runtimeActions, executionContext, isPropagated);
// remove the event from the context
@@ -232,9 +233,10 @@
if (!action.acceptsPropagatedEvents() && isPropagated) continue;
if (action.isAsync()) {
- ExecuteActionJob job = createAsyncActionExecutionJob(
- executionContext.getToken(), action);
- MessageService messageService = (MessageService) Services.getCurrentService(Services.SERVICENAME_MESSAGE);
+ ExecuteActionJob job =
+ createAsyncActionExecutionJob(executionContext.getToken(), action);
+ MessageService messageService =
+ executionContext.getJbpmContext().getServices().getMessageService();
messageService.send(job);
}
else {
@@ -263,8 +265,8 @@
// the token needs to be locked. if this is an action
// being executed as the node behaviour or if the token
// is already locked, the token doesn't need to be locked.
- boolean actionMustBeLocked = executionContext.getEvent() != null
- && !token.isLocked();
+ boolean actionMustBeLocked =
+ executionContext.getEvent() != null && !token.isLocked();
try {
// update the execution context
@@ -278,7 +280,8 @@
token.lock(lockOwnerId);
}
- UserCodeInterceptor userCodeInterceptor = UserCodeInterceptorConfig.getUserCodeInterceptor();
+ UserCodeInterceptor userCodeInterceptor =
+ UserCodeInterceptorConfig.getUserCodeInterceptor();
if (userCodeInterceptor != null) {
userCodeInterceptor.executeAction(action, executionContext);
}
@@ -310,8 +313,8 @@
List getRuntimeActionsForEvent(ExecutionContext executionContext,
String eventType) {
List runtimeActionsForEvent = null;
- List runtimeActions = executionContext.getProcessInstance()
- .getRuntimeActions();
+ List runtimeActions =
+ executionContext.getProcessInstance().getRuntimeActions();
if (runtimeActions != null) {
for (Iterator iter = runtimeActions.iterator(); iter.hasNext();) {
RuntimeAction runtimeAction = (RuntimeAction) iter.next();
@@ -463,22 +466,50 @@
if (id != 0 && id == other.getId()) return true;
GraphElement parent = getParent();
- return (name != null ? name.equals(other.getName())
- : other.getName() == null)
- && (parent != null ? parent.equals(other.getParent())
- : other.getParent() == null);
+ GraphElement otherParent = other.getParent();
+
+ boolean result;
+ if (name != null && parent != null) {
+ result = name.equals(other.getName());
+ }
+ else if (parent instanceof NodeCollection
+ && otherParent instanceof NodeCollection) {
+ NodeCollection nodeCollection = (NodeCollection) parent;
+ int index = nodeCollection.getNodes().indexOf(this);
+ assert index != -1 : nodeCollection.getNodes();
+
+ NodeCollection otherNodeCollection = (NodeCollection) otherParent;
+ int otherIndex = otherNodeCollection.getNodes().indexOf(other);
+ result = index == otherIndex;
+ }
+ else {
+ return false;
+ }
+ return result && parent.equals(otherParent);
}
public int hashCode() {
- int result = 580399073 + (name != null ? name.hashCode() : 0);
GraphElement parent = getParent();
- result = 345105097 * result + (parent != null ? parent.hashCode() : 0);
- return result;
+
+ int result = 580399073;
+ if (name != null && parent != null) {
+ result += name.hashCode();
+ }
+ else if (parent instanceof NodeCollection) {
+ NodeCollection nodeCollection = (NodeCollection) parent;
+ int index = nodeCollection.getNodes().indexOf(this);
+ assert index != -1 : nodeCollection.getNodes();
+ result += index;
+ }
+ else {
+ return super.hashCode();
+ }
+ return 345105097 * result + parent.hashCode();
}
public String toString() {
return ClassUtil.getSimpleName(getClass())
- + (name != null ? '(' + name + ')'
+ + (name != null ? '(' + name + ')' : id != 0 ? "(" + id + ')'
: '@' + Integer.toHexString(hashCode()));
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Transition.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Transition.java 2010-01-25 23:17:12 UTC (rev 6128)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/Transition.java 2010-01-26 01:41:10 UTC (rev 6129)
@@ -173,7 +173,7 @@
+ " has no destination");
}
- // optimisation: check if there is a candidate superstate to be entered.
+ // optimisation: check if there is a candidate superstate to be entered
if (destination.getSuperState() != null) {
// collect all the superstates being left
List leavingSuperStates = collectAllSuperStates(destination, from);
@@ -189,7 +189,7 @@
}
void fireSuperStateLeaveEvents(ExecutionContext executionContext) {
- // optimisation: check if there is a candidate superstate to be left.
+ // optimisation: check if there is a candidate superstate to be left
if (executionContext.getTransitionSource().getSuperState() != null) {
// collect all the superstates being left
List leavingSuperStates =
@@ -224,8 +224,7 @@
*/
void fireSuperStateEvents(List superStates, String eventType,
ExecutionContext executionContext) {
- Iterator iter = superStates.iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = superStates.iterator(); iter.hasNext();) {
SuperState leavingSuperState = (SuperState) iter.next();
leavingSuperState.fireEvent(eventType, executionContext);
}
@@ -242,14 +241,14 @@
return (name != null ? name.equals(other.getName())
: other.getName() == null)
- && (from != null ? from.equals(other.getFrom()) : other.getFrom() == null)
- && (to != null ? to.equals(other.getTo()) : other.getTo() == null);
+ && from != null && from.equals(other.getFrom());
}
public int hashCode() {
+ if (from == null) return System.identityHashCode(this);
+
int result = 580399073 + (name != null ? name.hashCode() : 0);
- result = 345105097 * result + (from != null ? from.hashCode() : 0);
- result = 345105097 * result + (to != null ? to.hashCode() : 0);
+ result = 345105097 * result + from.hashCode();
return result;
}
@@ -267,7 +266,6 @@
+ "'cause the from-node of this transition has already another leaving transition with the same name");
}
Map fromLeavingTransitions = from.getLeavingTransitionsMap();
- fromLeavingTransitions.remove(this.name);
fromLeavingTransitions.put(name, this);
}
this.name = name;
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/EndState.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/EndState.java 2010-01-25 23:17:12 UTC (rev 6128)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/node/EndState.java 2010-01-26 01:41:10 UTC (rev 6129)
@@ -33,7 +33,7 @@
private static final long serialVersionUID = 1L;
- String endCompleteProcess = null;
+ String endCompleteProcess;
public EndState() {
}
@@ -57,7 +57,7 @@
}
public void execute(ExecutionContext executionContext) {
- if ((endCompleteProcess != null) && (endCompleteProcess.equalsIgnoreCase("true"))) {
+ if ("true".equalsIgnoreCase(endCompleteProcess)) {
executionContext.getProcessInstance().end();
}
else {
16 years, 2 months
JBoss JBPM SVN: r6128 - in jbpm4/trunk/modules/test-db/src/test: java/org/jbpm/test/task/multiple and 3 other directories.
by do-not-reply@jboss.org
Author: koen.aers(a)jboss.com
Date: 2010-01-25 18:17:12 -0500 (Mon, 25 Jan 2010)
New Revision: 6128
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/multiple/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/multiple/MultipleTasksTest.java
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/task/
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/task/multiple/
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/task/multiple/process.jpdl.xml
Log:
Unit test for JBPM-2607
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/multiple/MultipleTasksTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/multiple/MultipleTasksTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/multiple/MultipleTasksTest.java 2010-01-25 23:17:12 UTC (rev 6128)
@@ -0,0 +1,50 @@
+package org.jbpm.test.task.multiple;
+
+import java.util.List;
+
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+import org.subethamail.wiser.Wiser;
+
+public class MultipleTasksTest extends JbpmTestCase {
+
+ Wiser wiser = new Wiser();
+ String deploymentId;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ deploymentId = repositoryService.createDeployment()
+ .addResourceFromClasspath(
+ "org/jbpm/test/task/multiple/process.jpdl.xml")
+ .deploy();
+ identityService.createUser("johndoe", "John", "Doe", "john@doe");
+ wiser.setPort(2525);
+ wiser.start();
+ }
+
+ protected void tearDown() throws Exception {
+ wiser.stop();
+ repositoryService.deleteDeploymentCascade(deploymentId);
+ identityService.deleteUser("johndoe");
+ super.tearDown();
+ }
+
+ public void testOltWorkflow() {
+ executionService.startProcessInstanceByKey("MultipleTasks");
+
+ List<Task> taskList = taskService.findPersonalTasks("johndoe");
+ assertEquals(1, taskList.size());
+ Task task = taskList.get(0);
+ assertEquals("task1", task.getName());
+ assertEquals("johndoe", task.getAssignee());
+
+ taskService.completeTask(task.getId()); /*This is where it goes wrong...*/
+
+ taskList = taskService.findPersonalTasks("johndoe");
+ assertEquals(1, taskList.size());
+ task = taskList.get(0);
+ assertEquals("task2", task.getName());
+ assertEquals("johndoe", task.getAssignee());
+ }
+
+}
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/multiple/MultipleTasksTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/task/multiple/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/task/multiple/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/task/multiple/process.jpdl.xml 2010-01-25 23:17:12 UTC (rev 6128)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="MultipleTasks" >
+ <start name="start1" >
+ <transition to="task1" />
+ </start>
+ <task name="task1" assignee="johndoe">
+ <transition to="task2" />
+ </task>
+ <task name="task2" assignee="johndoe">
+ <notification/>
+ <transition to="end" />
+ </task>
+ <end name="end" />
+</process>
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/task/multiple/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
16 years, 2 months
JBoss JBPM SVN: r6127 - in jbpm4/trunk: modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer and 15 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2010-01-25 08:47:18 -0500 (Mon, 25 Jan 2010)
New Revision: 6127
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JbpmTestExtensionsImpl.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestExtensions.java
Modified:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java
jbpm4/trunk/pom.xml
Log:
fixing test clock handling
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -45,12 +45,12 @@
@Override
protected void tearDown() throws Exception {
+ Clock.setExplicitTime(null);
super.tearDown();
- Clock.setCurrentTime(null);
}
public void testIntermediateTimerWithDuration() {
- Clock.setCurrentTime(new Date(0));
+ Clock.setExplicitTime(new Date(0));
ProcessInstance processInstance = executionService.startProcessInstanceByKey("intermediateTimerCatch");
Job timerJob = managementService.createJobQuery()
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/BusinessCalendarImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -86,7 +86,7 @@
Date end = null;
long millis = convertToMillis(duration);
end = new Date(date.getTime()-millis);
- if (end.before(Clock.getCurrentTime())) {
+ if (end.before(Clock.getTime())) {
throw new JbpmException("Duedate "+ end+ " in the past");
}
return end;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cal/CronExpression.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -1035,7 +1035,7 @@
//Calendar cl = Calendar.getInstance(getTimeZone());
Calendar cl = Calendar.getInstance();
- cl.setTime(Clock.getCurrentTime());
+ cl.setTime(Clock.getTime());
// move ahead one second, since we're computing the time *after* the
// given time
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -380,7 +380,7 @@
public TaskImpl createTask() {
TaskImpl task = newTask();
- task.setCreateTime(Clock.getCurrentTime());
+ task.setCreateTime(Clock.getTime());
return task;
}
@@ -409,14 +409,14 @@
public JobImpl<?> findFirstAcquirableJob() {
Query query = session.getNamedQuery("findFirstAcquirableJob");
- query.setTimestamp("now", Clock.getCurrentTime());
+ query.setTimestamp("now", Clock.getTime());
query.setMaxResults(1);
return (JobImpl<?>) query.uniqueResult();
}
public List<JobImpl<?>> findExclusiveJobs(Execution processInstance) {
Query query = session.getNamedQuery("findExclusiveJobs");
- query.setTimestamp("now", Clock.getCurrentTime());
+ query.setTimestamp("now", Clock.getTime());
query.setEntity("processInstance", processInstance);
return query.list();
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ActivityEnd.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -54,7 +54,7 @@
}
protected void updateHistoryActivityInstance(HistoryActivityInstanceImpl historyActivityInstance) {
- historyActivityInstance.setEndTime(Clock.getCurrentTime());
+ historyActivityInstance.setEndTime(Clock.getTime());
historyActivityInstance.setTransitionName(transitionName);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/ProcessInstanceEnd.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -38,7 +38,7 @@
Session session = EnvironmentImpl.getFromCurrent(Session.class);
HistoryProcessInstanceImpl historyProcessInstanceImpl = (HistoryProcessInstanceImpl)
session.load(HistoryProcessInstanceImpl.class, execution.getDbid());
- historyProcessInstanceImpl.setEndTime(Clock.getCurrentTime());
+ historyProcessInstanceImpl.setEndTime(Clock.getTime());
historyProcessInstanceImpl.setState(execution.getState());
historyProcessInstanceImpl.setEndActivityName(execution.getActivityName());
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskComplete.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -49,12 +49,12 @@
Long historyActivityInstanceDbId = execution.getHistoryActivityInstanceDbid();
HistoryTaskInstanceImpl historyTaskInstance = (HistoryTaskInstanceImpl)
session.load(HistoryTaskInstanceImpl.class, historyActivityInstanceDbId);
- historyTaskInstance.setEndTime(Clock.getCurrentTime());
+ historyTaskInstance.setEndTime(Clock.getTime());
historyTaskInstance.setTransitionName(outcome);
HistoryTaskImpl historyTask = historyTaskInstance.getHistoryTask();
historyTask.setOutcome(outcome);
- historyTask.setEndTime(Clock.getCurrentTime());
+ historyTask.setEndTime(Clock.getTime());
historyTask.setState(HistoryTask.STATE_COMPLETED);
session.update(historyTaskInstance);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskDelete.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -56,7 +56,7 @@
DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
HistoryTaskImpl historyTask = (HistoryTaskImpl) dbSession.get(HistoryTaskImpl.class, task.getDbid());
historyTask.setState(reason);
- historyTask.setEndTime(Clock.getCurrentTime());
+ historyTask.setEndTime(Clock.getTime());
}
protected Class<? extends HistoryActivityInstanceImpl> getHistoryActivityInstanceClass() {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryAutomaticInstanceImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -38,6 +38,6 @@
public HistoryAutomaticInstanceImpl(HistoryProcessInstance historyProcessInstanceImpl, ExecutionImpl execution) {
super(historyProcessInstanceImpl, execution);
- setEndTime(Clock.getCurrentTime());
+ setEndTime(Clock.getTime());
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -57,7 +57,7 @@
// the default constructor which is used by hibernate
protected HistoryDetailImpl(String dummy) {
this.dbid = DbidGenerator.getDbidGenerator().getNextId();
- this.time = Clock.getCurrentTime();
+ this.time = Clock.getTime();
EnvironmentImpl environment = EnvironmentImpl.getCurrent();
if (environment!=null) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryProcessInstanceImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -78,7 +78,7 @@
this.processInstanceId = processInstance.getId();
this.key = processInstance.getKey();
this.state = "active";
- this.startTime = Clock.getCurrentTime();
+ this.startTime = Clock.getTime();
}
public void setEndTime(Date endTime) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryTaskImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -71,7 +71,7 @@
this.assignee = task.getAssignee();
this.priority = task.getPriority();
this.duedate = task.getDuedate();
- this.createTime = Clock.getCurrentTime();
+ this.createTime = Clock.getTime();
}
public void updated(TaskImpl task) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -125,7 +125,7 @@
if (durationMatcher.matches()) {
// add duration to current date
dueDate = EnvironmentImpl.getFromCurrent(BusinessCalendar.class).add(
- Clock.getCurrentTime(), durationMatcher.group(1));
+ Clock.getTime(), durationMatcher.group(1));
} else {
throw new JbpmException("invalid due date duration: " + dueDateDescription);
}
@@ -168,7 +168,7 @@
// then the repeat action duedate could already have passed
do {
setDueDateDescription(repeat);
- } while (duedate.getTime() <= Clock.getCurrentTime().getTime());
+ } while (duedate.getTime() <= Clock.getTime().getTime());
if (log.isDebugEnabled()) log.debug("rescheduled "+this+" for "+formatDueDate(duedate));
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -308,7 +308,7 @@
if (timer.getDuedate() == null && timerDefinition.getCronExpression() != null) {
try {
timer.setDuedate(new CronExpression(timerDefinition.getCronExpression())
- .getNextValidTimeAfter(Clock.getCurrentTime()));
+ .getNextValidTimeAfter(Clock.getTime()));
} catch (ParseException pe) {
throw new JbpmException("Can't parse cron expression " + timerDefinition.getCronExpression(), pe);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -55,7 +55,7 @@
try {
execution.setPropagation(Propagation.UNSPECIFIED);
- execution.setHistoryActivityStart(Clock.getCurrentTime());
+ execution.setHistoryActivityStart(Clock.getTime());
activityBehaviour.execute(execution);
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JbpmTestExtensionsImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JbpmTestExtensionsImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JbpmTestExtensionsImpl.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -0,0 +1,42 @@
+/*
+ * 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.pvm.internal.test;
+
+import java.util.Date;
+
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.test.JbpmTestExtensions;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JbpmTestExtensionsImpl extends JbpmTestExtensions {
+
+ public Date getExplicitTime() {
+ return Clock.getExplicitTime();
+ }
+
+ public void setExplicitTime(Date explicitTime) {
+ Clock.setExplicitTime(explicitTime);
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/test/JbpmTestExtensionsImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/Clock.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -4,16 +4,20 @@
public abstract class Clock {
- protected static Date currentTime = null;
+ protected static Date explicitTime = null;
- public static Date getCurrentTime() {
- if (currentTime==null) {
+ public static Date getTime() {
+ if (explicitTime==null) {
return new Date();
}
- return currentTime;
+ return explicitTime;
}
- public static void setCurrentTime(Date currentTime) {
- Clock.currentTime = currentTime;
+ public static void setExplicitTime(Date explicitTime) {
+ Clock.explicitTime = explicitTime;
}
+
+ public static Date getExplicitTime() {
+ return explicitTime;
+ }
}
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/BaseJbpmTestCase.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -24,6 +24,7 @@
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
+import org.jbpm.api.JbpmException;
import org.jbpm.internal.log.Jdk14LogFactory;
import org.jbpm.internal.log.Log;
import org.jbpm.internal.log.LogFormatter;
@@ -54,6 +55,7 @@
Jdk14LogFactory.initializeJdk14Logging();
}
+ static protected JbpmTestExtensions jbpmTestExtensions = JbpmTestExtensions.getJbpmTestExtensions();
static protected Log log = Log.getLog(BaseJbpmTestCase.class.getName());
Throwable exception;
@@ -65,6 +67,11 @@
protected void tearDown() throws Exception {
log.debug("=== ending "+getName()+" =============================\n");
+
+ if (jbpmTestExtensions.getExplicitTime()!=null) {
+ jbpmTestExtensions.setExplicitTime(null);
+ throw new JbpmException("This test forgot to unset the explicit time of the clock. use JbpmTestExtensions.getJbpmTestExtensions().setExplicitTime(null);");
+ }
}
public void assertTextPresent(String expected, String value) {
Added: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestExtensions.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestExtensions.java (rev 0)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestExtensions.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -0,0 +1,54 @@
+/*
+ * 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.test;
+
+import java.util.Date;
+
+import org.jbpm.api.JbpmException;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class JbpmTestExtensions {
+
+ protected static JbpmTestExtensions instance = instantiateJbpmTestExtentions();
+
+ protected static JbpmTestExtensions instantiateJbpmTestExtentions() {
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ JbpmTestExtensions newInstance;
+ try {
+ Class<?> implClass = Class.forName("org.jbpm.pvm.internal.test.JbpmTestExtensionsImpl", true, contextClassLoader);
+ newInstance = (JbpmTestExtensions) implClass.newInstance();
+ } catch (Exception e) {
+ throw new JbpmException("couldn't load jbpm test extensions", e);
+ }
+ return newInstance;
+ }
+
+ public static JbpmTestExtensions getJbpmTestExtensions() {
+ return instance;
+ }
+
+ public abstract void setExplicitTime(Date explicitTime);
+ public abstract Date getExplicitTime();
+}
Property changes on: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestExtensions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/custombusinesscalendarcfg/CustomBusinessCalendarCfgTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -39,7 +39,7 @@
@Override
protected void tearDown() throws Exception {
super.tearDown();
- Clock.setCurrentTime(null);
+ Clock.setExplicitTime(null);
}
public void testCustomBusinessCalendarCfg() {
@@ -62,7 +62,7 @@
GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.set(2009, Calendar.JANUARY, 30, 11, 0, 0);
Date clockDate = gregorianCalendar.getTime();
- Clock.setCurrentTime(clockDate);
+ Clock.setExplicitTime(clockDate);
try {
ProcessInstance processInstance = executionService.startProcessInstanceByKey("CustomBusinessCalendarCfg");
@@ -83,7 +83,7 @@
assertEquals(0, gregorianCalendar.get(Calendar.SECOND));
} finally {
- Clock.setCurrentTime(null);
+ Clock.setExplicitTime(null);
}
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/test/intermediatecatch/IntermediateCatchTimerEventTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -126,10 +126,9 @@
"</definitions>";
- @Override
protected void tearDown() throws Exception {
+ Clock.setExplicitTime(null);
super.tearDown();
- Clock.setCurrentTime(null);
}
public void testInvalidProcess() {
@@ -154,7 +153,7 @@
deployBpmn2XmlString(TIMER_CATCH_WITH_TIMECYCLE);
long processStartTime = 5000;
- Clock.setCurrentTime(new Date(processStartTime));
+ Clock.setExplicitTime(new Date(processStartTime));
ProcessInstance pi = executionService.startProcessInstanceByKey("timeCycleProcess");
CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
@@ -183,7 +182,7 @@
public void testCronExpression() {
deployBpmn2XmlString(TIMER_CATCH_WITH_CRON_EXPRESSION);
- Clock.setCurrentTime(getDate(20, Calendar.JANUARY, 2010, 0, 1, 1)); // Start on 61 seconds
+ Clock.setExplicitTime(getDate(20, Calendar.JANUARY, 2010, 0, 1, 1)); // Start on 61 seconds
ProcessInstance pi = executionService.startProcessInstanceByKey("timeDateProcess");
CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
@@ -197,7 +196,7 @@
public void testCronExpression2() {
deployBpmn2XmlString(TIMER_CATCH_WITH_CRON_EXPRESSION_2);
- Clock.setCurrentTime(getDateAtMidnight(21, Calendar.JANUARY, 2010)); // 21/01/2009 is a Thursday
+ Clock.setExplicitTime(getDateAtMidnight(21, Calendar.JANUARY, 2010)); // 21/01/2009 is a Thursday
ProcessInstance pi = executionService.startProcessInstanceByKey("timeDateProcess");
CollectionAssertions.assertContainsSameElements(pi.findActiveActivityNames(), "intermediateTimer");
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/AvgDurationTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -21,11 +21,13 @@
*/
package org.jbpm.test.history;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.Map;
import org.jbpm.api.Execution;
import org.jbpm.api.ProcessDefinition;
-import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.test.JbpmTestCase;
@@ -63,22 +65,35 @@
Long avgDurationOne = avgDurations.get("one");
assertNotNull(avgDurationOne);
- assertTrue("expected avg duration bigger then 40, but was"+avgDurationOne, avgDurationOne>40);
+ assertTrue("expected avg duration bigger then 40, but was "+avgDurationOne, avgDurationOne>40);
Long avgDurationTwo = avgDurations.get("two");
assertNotNull(avgDurationTwo);
- assertTrue("expected avg duration bigger then 10, but was"+avgDurationTwo, avgDurationTwo>10);
+ assertTrue("expected avg duration bigger then 10, but was "+avgDurationTwo, avgDurationTwo>10);
Long avgDurationThree = avgDurations.get("three");
assertNotNull(avgDurationThree);
- assertTrue("expected avg duration bigger then 0, but was"+avgDurationThree, avgDurationThree>=0);
+ assertTrue("expected avg duration bigger then 0, but was "+avgDurationThree, avgDurationThree>=0);
assertEquals(3, avgDurations.size());
}
+ static DateFormat dateFormat = new SimpleDateFormat("ss,SSS");
protected void executeProcess() throws InterruptedException {
Execution execution = executionService.startProcessInstanceByKey("ICL");
- Thread.sleep(50);
+ log.info("waiting 50 millis at "+dateFormat.format(new Date()));
+ try {
+ Thread.sleep(50);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ log.info("done waiting 50 millis at "+dateFormat.format(new Date()));
executionService.signalExecutionById(execution.getId());
- Thread.sleep(20);
+ log.info("waiting 20 millis at "+dateFormat.format(new Date()));
+ try {
+ Thread.sleep(20);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ log.info("done waiting 20 millis at "+dateFormat.format(new Date()));
executionService.signalExecutionById(execution.getId());
executionService.signalExecutionById(execution.getId());
}
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -43,8 +43,8 @@
public class HistoryActivityInstanceQueryTest extends JbpmTestCase {
protected void tearDown() throws Exception {
+ Clock.setExplicitTime(null);
super.tearDown();
- Clock.setCurrentTime(null);
}
public void testSimpleQuery() {
@@ -109,12 +109,12 @@
deployTestProcess();
// start 8 processes (18 activity instances) on simulated time 3000000
- Clock.setCurrentTime(new Date(3000000));
+ Clock.setExplicitTime(new Date(3000000));
generateHistoryForTestProcess();
generateHistoryForTestProcess();
// start another 4 processes (9 activity instances) on simulated time 3005000
- Clock.setCurrentTime(new Date(3005000));
+ Clock.setExplicitTime(new Date(3005000));
generateHistoryForTestProcess();
Date timeStamp = new Date(3003000);
@@ -126,11 +126,11 @@
deployTestProcess();
// start 4 processes (9 activity instances) on simulated time 3000000
- Clock.setCurrentTime(new Date(3000000));
+ Clock.setExplicitTime(new Date(3000000));
generateHistoryForTestProcess();
// start another 8 processes (18 activity instances) on simulated time 3000200
- Clock.setCurrentTime(new Date(3002000));
+ Clock.setExplicitTime(new Date(3002000));
generateHistoryForTestProcess();
generateHistoryForTestProcess();
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -44,10 +44,9 @@
*/
public class HistoryTaskQueryTest extends JbpmTestCase {
- @Override
protected void tearDown() throws Exception {
+ Clock.setExplicitTime(null);
super.tearDown();
- Clock.setCurrentTime(null);
}
public void testOrderByName() {
@@ -139,7 +138,7 @@
" <end name='theEnd' />" +
"</process>";
- Clock.setCurrentTime(new Date(CLOCK_TEST_TIME));
+ Clock.setExplicitTime(new Date(CLOCK_TEST_TIME));
String processXml3 = processXml1.replace("1", "2").replace("Alex", "Tom");
String processXml2 = processXml1.replace("1", "3").replace("Alex", "Joram");
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java 2010-01-25 13:47:18 UTC (rev 6127)
@@ -116,7 +116,7 @@
Calendar now = Calendar.getInstance();
// prevent wrong results in databases lacking millisecond precision
now.set(Calendar.MILLISECOND, 0);
- Clock.setCurrentTime(now.getTime());
+ Clock.setExplicitTime(now.getTime());
String processInstanceId = executionService.startProcessInstanceByKey("Duration").getId();
@@ -130,5 +130,7 @@
// because task.getDuedate() returns java.sql.Timestamp here,
// comparison has to be made in milliseconds
assertEquals(now.getTimeInMillis(), task.getDuedate().getTime());
+
+ Clock.setExplicitTime(null);
}
}
Modified: jbpm4/trunk/pom.xml
===================================================================
--- jbpm4/trunk/pom.xml 2010-01-25 09:27:59 UTC (rev 6126)
+++ jbpm4/trunk/pom.xml 2010-01-25 13:47:18 UTC (rev 6127)
@@ -73,8 +73,6 @@
<stax.api.version>1.0.1</stax.api.version>
<wiser.version>1.2</wiser.version>
<woodstox.version>3.2.6</woodstox.version>
- <!-- Database Driver Versions -->
- <hsqldb.version>1.8.0.7</hsqldb.version>
<mysql.connector.version>5.0.8</mysql.connector.version>
<postgresql.version>8.3-603.jdbc3</postgresql.version>
<jtds.version>1.2.2</jtds.version>
16 years, 2 months
JBoss JBPM SVN: r6126 - jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2010-01-25 04:27:59 -0500 (Mon, 25 Jan 2010)
New Revision: 6126
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java
Log:
Fixing failing BPMN2 tests
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java 2010-01-25 08:56:26 UTC (rev 6125)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java 2010-01-25 09:27:59 UTC (rev 6126)
@@ -52,7 +52,7 @@
String id = XmlUtil.attribute(element, "id");
Element eventDefinition = XmlUtil.element(element);
- if ("timerEventDefinition".equals(eventDefinition.getNodeName())) {
+ if (eventDefinition != null && "timerEventDefinition".equals(eventDefinition.getNodeName())) {
return createTimerStartEvent((BpmnParser) parser, parse, id);
} else if (eventDefinition != null){
parse.addProblem("Invalid eventDefinition type : " + eventDefinition.getNodeName());
16 years, 2 months
JBoss JBPM SVN: r6125 - jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2010-01-25 03:56:26 -0500 (Mon, 25 Jan 2010)
New Revision: 6125
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java
Log:
Work om timer start event
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java 2010-01-25 08:55:30 UTC (rev 6124)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeElementImpl.java 2010-01-25 08:56:26 UTC (rev 6125)
@@ -75,9 +75,20 @@
return timerDefinitions;
}
+ /**
+ * Creates an empty {@link TimerDefinitionImpl} and associates it with this scope element.
+ */
public TimerDefinitionImpl createTimerDefinition() {
TimerDefinitionImpl timerDefinition = new TimerDefinitionImpl();
timerDefinitions.add(timerDefinition);
return timerDefinition;
}
+
+ /**
+ * Associates the given timer definition with this scope element.
+ */
+ public void addTimerDefinition(TimerDefinitionImpl timerDefinition) {
+ timerDefinitions.add(timerDefinition);
+ }
+
}
16 years, 2 months
JBoss JBPM SVN: r6124 - in jbpm4/trunk/modules/bpmn/src/main: java/org/jbpm/bpmn/parser and 1 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2010-01-25 03:55:30 -0500 (Mon, 25 Jan 2010)
New Revision: 6124
Added:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TimerStartEvent.java
Removed:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.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/BpmnParser.java
jbpm4/trunk/modules/bpmn/src/main/resources/jbpm.bpmn.flownodes.xml
Log:
Work om timer start event
Deleted: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -1,55 +0,0 @@
-/*
- * 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.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class EndBinding extends BpmnBinding {
-
- public EndBinding() {
- super("endEvent");
- }
-
- protected EndBinding(String tag) {
- super(tag);
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- EndActivity endActivity = new EndActivity();
-
- Element terminateEventDefinition = XmlUtil.element(element, "terminateEventDefinition");
- if (terminateEventDefinition != null) {
- endActivity.setEndProcessInstance(true);
- } else {
- endActivity.setEndProcessInstance(false); // default is to end execution, not the process instance
- }
-
- return endActivity;
- }
-}
Copied: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java (from rev 6109, jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndBinding.java)
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/EndEventBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -0,0 +1,55 @@
+/*
+ * 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.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EndEventBinding extends BpmnBinding {
+
+ public EndEventBinding() {
+ super("endEvent");
+ }
+
+ protected EndEventBinding(String tag) {
+ super(tag);
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ EndActivity endActivity = new EndActivity();
+
+ Element terminateEventDefinition = XmlUtil.element(element, "terminateEventDefinition");
+ if (terminateEventDefinition != null) {
+ endActivity.setEndProcessInstance(true);
+ } else {
+ endActivity.setEndProcessInstance(false); // default is to end execution, not the process instance
+ }
+
+ return endActivity;
+ }
+}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/IntermediateCatchEventBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -21,13 +21,7 @@
*/
package org.jbpm.bpmn.flownodes;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.jbpm.pvm.internal.cal.CronExpression;
-import org.jbpm.pvm.internal.cal.Duration;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.EventImpl;
import org.jbpm.pvm.internal.model.TimerDefinitionImpl;
@@ -50,7 +44,7 @@
String id = XmlUtil.attribute(element, "id");
Element eventDefinition = XmlUtil.element(element);
if ("timerEventDefinition".equals(eventDefinition.getNodeName())) {
- return createIntermediateTimerCatchEvent(id, eventDefinition, parse);
+ return createIntermediateTimerCatchEvent(id, eventDefinition, (BpmnParser) parser, parse);
} else {
parse.addProblem("Invalid eventDefinition type : " + eventDefinition.getNodeName());
}
@@ -59,65 +53,23 @@
}
protected IntermediateCatchTimerEvent createIntermediateTimerCatchEvent(String catchEventId,
- Element eventDefinitionElement, Parse parse) {
+ Element eventDefinitionElement, BpmnParser parser, Parse parse) {
- Element timeDate = XmlUtil.element(eventDefinitionElement, "timeDate");
- Element timeCycle = XmlUtil.element(eventDefinitionElement, "timeCycle");
-
- if ( (timeDate != null && timeCycle != null)
- || (timeDate == null && timeCycle == null) ) {
- parse.addProblem("Intermediate catch event '" + catchEventId +
- "' requires either a timeDate or a timeCycle definition (but not both)");
- return null;
- }
-
IntermediateCatchTimerEvent intermediateCatchTimerEvent = new IntermediateCatchTimerEvent();
+ TimerDefinitionImpl timerDefinition = parser.parseTimerEventDefinition(eventDefinitionElement, parse, catchEventId);
+
+ // Attach the timerDefinition to the current activity.
+ // That way, the PVM will automatically pcik it up when the execution arrives in the activity.
ActivityImpl activity = parse.contextStackFind(ActivityImpl.class);
+ activity.addTimerDefinition(timerDefinition);
- // Create timerDefinition and attach an associated event to the activty
- TimerDefinitionImpl timerDefinition = activity.createTimerDefinition();
+ // The timer will fire an event on which this class will listen.
String eventName = "INTERMEDIATE_TIMER_" + catchEventId;
timerDefinition.setEventName(eventName);
EventImpl timerEvent = activity.createEvent(eventName);
timerEvent.createEventListenerReference(intermediateCatchTimerEvent);
-
- if (timeDate != null) {
- parseTimeDate(catchEventId, parse, timeDate, timerDefinition);
- }
-
- if (timeCycle != null) {
- parseTimeCycle(catchEventId, parse, timeCycle, timerDefinition);
- }
return intermediateCatchTimerEvent;
}
- private void parseTimeCycle(String catchEventId, Parse parse, Element timeCycle, TimerDefinitionImpl timerDefinition) {
- String cycleExpression = timeCycle.getTextContent();
- if (Duration.isValidExpression(cycleExpression)) {
- timerDefinition.setDueDateDescription(cycleExpression);
- } else if (CronExpression.isValidExpression(cycleExpression)) {
- timerDefinition.setCronExpression(cycleExpression);
- } else {
- parse.addProblem("couldn't parse timeDate duration '"+ cycleExpression
- + "' on intermediate catch timer event " + catchEventId);
- }
- }
-
- protected void parseTimeDate(String catchEventId, Parse parse, Element timeDate, TimerDefinitionImpl timerDefinition) {
- String dueDateTime = timeDate.getTextContent();
- String dueDateTimeFormatText = (String) EnvironmentImpl.getFromCurrent("jbpm.duedatetime.format", false);
- if (dueDateTimeFormatText==null) {
- dueDateTimeFormatText = "dd/MM/yyyy HH:mm:ss";
- }
- SimpleDateFormat dateFormat = new SimpleDateFormat(dueDateTimeFormatText);
- try {
- Date duedatetimeDate = dateFormat.parse(dueDateTime);
- timerDefinition.setDueDate(duedatetimeDate);
- } catch (ParseException e) {
- parse.addProblem("couldn't parse timeDate '"+ dueDateTime
- + "' on intermediate catch timer event " + catchEventId, e);
- }
- }
-
}
Deleted: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -1,55 +0,0 @@
-/*
- * 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.model.BpmnProcessDefinition;
-import org.jbpm.pvm.internal.model.ActivityImpl;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-
-public class StartBinding extends BpmnBinding {
-
- public StartBinding() {
- super("startEvent");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- ActivityImpl startActivity = parse.contextStackFind(ActivityImpl.class);
- BpmnProcessDefinition processDefinition = parse.contextStackFind(BpmnProcessDefinition.class);
-
- if (processDefinition.getInitial()==null) {
- processDefinition.setInitial(startActivity);
-
- } else if (startActivity.getParentActivity()==null) {
- parse.addProblem("multiple start events not yet supported", element);
- }
-
- return new NoneStartEventActivity();
- }
-
- public boolean isNameRequired() {
- return false;
- }
-}
Copied: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java (from rev 6109, jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartBinding.java)
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/StartEventBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -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.bpmn.flownodes;
+
+import org.jbpm.bpmn.model.BpmnProcessDefinition;
+import org.jbpm.bpmn.parser.BpmnParser;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.TimerDefinitionImpl;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+
+
+public class StartEventBinding extends BpmnBinding {
+
+ public StartEventBinding() {
+ super("startEvent");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ ActivityImpl startActivity = parse.contextStackFind(ActivityImpl.class);
+ BpmnProcessDefinition processDefinition = parse.contextStackFind(BpmnProcessDefinition.class);
+
+ if (processDefinition.getInitial()==null) {
+ processDefinition.setInitial(startActivity);
+
+ } else if (startActivity.getParentActivity()==null) {
+ parse.addProblem("multiple start events not yet supported", element);
+ }
+
+ String id = XmlUtil.attribute(element, "id");
+ Element eventDefinition = XmlUtil.element(element);
+ if ("timerEventDefinition".equals(eventDefinition.getNodeName())) {
+ return createTimerStartEvent((BpmnParser) parser, parse, id);
+ } else if (eventDefinition != null){
+ parse.addProblem("Invalid eventDefinition type : " + eventDefinition.getNodeName());
+ }
+
+ return new NoneStartEventActivity(); // default
+ }
+
+ protected TimerStartEvent createTimerStartEvent(BpmnParser parser, Parse parse, String eventId) {
+ TimerStartEvent timerStartEvent = new TimerStartEvent();
+
+ TimerDefinitionImpl timerDefinition = parser.parseTimerEventDefinition(null, parse, eventId);
+
+ // schedule job
+
+ return timerStartEvent;
+ }
+
+}
Modified: 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 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -42,7 +42,7 @@
TaskActivity taskActivity = new TaskActivity();
ScopeElementImpl scopeElement = parse.contextStackFind(ScopeElementImpl.class);
- TaskDefinitionImpl taskDefinition = BpmnParser.parseTaskDefinition(element, parse, scopeElement);
+ TaskDefinitionImpl taskDefinition = ((BpmnParser)parser).parseTaskDefinition(element, parse, scopeElement);
taskActivity.setTaskDefinition(taskDefinition);
taskActivity.setDefault(getDefault());
Added: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TimerStartEvent.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TimerStartEvent.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TimerStartEvent.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -0,0 +1,45 @@
+/*
+ * 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.api.activity.ActivityExecution;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Joram Barrez
+ */
+public class TimerStartEvent extends BpmnActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) {
+
+ }
+
+ public void execute(ExecutionImpl execution) {
+
+ }
+
+
+
+}
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 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -46,7 +46,7 @@
UserTaskActivity taskActivity = new UserTaskActivity();
ScopeElementImpl scopeElement = parse.contextStackFind(ScopeElementImpl.class);
- TaskDefinitionImpl taskDefinition = BpmnParser.parseTaskDefinition(element, parse, scopeElement);
+ TaskDefinitionImpl taskDefinition = ((BpmnParser) parser).parseTaskDefinition(element, parse, scopeElement);
addActivityResources(taskDefinition, taskActivity, element, parse);
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 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2010-01-25 08:55:30 UTC (rev 6124)
@@ -22,7 +22,10 @@
package org.jbpm.bpmn.parser;
import java.net.URL;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.Enumeration;
import java.util.List;
@@ -37,10 +40,14 @@
import org.jbpm.bpmn.model.BpmnProcessDefinition;
import org.jbpm.bpmn.model.SequenceflowCondition;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cal.CronExpression;
+import org.jbpm.pvm.internal.cal.Duration;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.CompositeElementImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.model.ScopeElementImpl;
+import org.jbpm.pvm.internal.model.TimerDefinitionImpl;
import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
@@ -56,6 +63,7 @@
/**
* @author Tom Baeyens
* @author Bernd Ruecker (bernd.ruecker(a)camunda.com)
+ * @author Joram Barrez
*/
public class BpmnParser extends Parser {
@@ -308,53 +316,9 @@
}
public void parseDefinition(Element documentElement, Parse parse) {
parseImports(documentElement, parse);
- ///parseItemDefinitions(documentElement, parse);
- //parseMessages(documentElement, parse);
- // parseInterfaces(documentElement, parse);
- // parseResources(documentElement, parse);
}
- // public static void parseAssignmentAttributes(Element element,
- // AssignableDefinitionImpl assignableDefinition, Parse parse) {
- // Element descriptionElement = XmlUtil.element(element, "description");
- // if (descriptionElement!=null) {
- // String description = XmlUtil.getContentText(descriptionElement);
- // assignableDefinition.setDescription(description);
- // }
- //
- // Element assignmentHandlerElement = XmlUtil.element(element,
- // "assignment-handler");
- // if (assignmentHandlerElement!=null) {
- // ObjectDescriptor objectDescriptor =
- // parseObjectDescriptor(assignmentHandlerElement, parse);
- // assignableDefinition.setAssignmentHandlerDescriptor(objectDescriptor);
- // }
- //
- // String assigneeExpression = XmlUtil.attribute(element, "assignee");
- // assignableDefinition.setAssigneeExpression(assigneeExpression);
- //
- // String assigneeExpressionLanguage = XmlUtil.attribute(element,
- // "assignee-lang");
- // assignableDefinition.setAssigneeExpressionLanguage(assigneeExpressionLanguage);
- //
- // String candidateUsersExpression = XmlUtil.attribute(element,
- // "candidate-users");
- // assignableDefinition.setCandidateUsersExpression(candidateUsersExpression);
- //
- // String candidateUsersExpressionLanguage = XmlUtil.attribute(element,
- // "candidate-users-lang");
- // assignableDefinition.setCandidateUsersExpressionLanguage(candidateUsersExpressionLanguage);
- //
- // String candidateGroupsExpression = XmlUtil.attribute(element,
- // "candidate-groups");
- // assignableDefinition.setCandidateGroupsExpression(candidateGroupsExpression);
- //
- // String candidateGroupsExpressionLanguage = XmlUtil.attribute(element,
- // "candidate-groups-lang");
- // assignableDefinition.setCandidateGroupsExpressionLanguage(candidateGroupsExpressionLanguage);
- // }
-
- public static TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, ScopeElementImpl scopeElement) {
+ public TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, ScopeElementImpl scopeElement) {
TaskDefinitionImpl taskDefinition = new TaskDefinitionImpl();
String taskName = XmlUtil.attribute(element, "name");
@@ -369,9 +333,66 @@
return taskDefinition;
}
+
+ /**
+ * @param timerEventDefinitionElement The XML element that defines the timer definition
+ * @param activity The activity on which the timer definition must be created
+ * @param eventId The id of the event on which the timer is defined
+ */
+ public TimerDefinitionImpl parseTimerEventDefinition(Element timerEventDefinitionElement, Parse parse, String eventId) {
+
+ Element timeDate = XmlUtil.element(timerEventDefinitionElement, "timeDate");
+ Element timeCycle = XmlUtil.element(timerEventDefinitionElement, "timeCycle");
+
+ if ( (timeDate != null && timeCycle != null)
+ || (timeDate == null && timeCycle == null) ) {
+ parse.addProblem("Intermediate catch event '" + eventId +
+ "' requires either a timeDate or a timeCycle definition (but not both)");
+ return null;
+ }
+
+ TimerDefinitionImpl timerDefinition = new TimerDefinitionImpl();
+
+ if (timeDate != null) {
+ parseTimeDate(eventId, parse, timeDate, timerDefinition);
+ }
+
+ if (timeCycle != null) {
+ parseTimeCycle(eventId, parse, timeCycle, timerDefinition);
+ }
+
+ return timerDefinition;
+ }
+
+ protected void parseTimeCycle(String catchEventId, Parse parse, Element timeCycle, TimerDefinitionImpl timerDefinition) {
+ String cycleExpression = timeCycle.getTextContent();
+ if (Duration.isValidExpression(cycleExpression)) {
+ timerDefinition.setDueDateDescription(cycleExpression);
+ } else if (CronExpression.isValidExpression(cycleExpression)) {
+ timerDefinition.setCronExpression(cycleExpression);
+ } else {
+ parse.addProblem("couldn't parse timeDate duration '"+ cycleExpression
+ + "' on intermediate catch timer event " + catchEventId);
+ }
+ }
+ protected void parseTimeDate(String catchEventId, Parse parse, Element timeDate, TimerDefinitionImpl timerDefinition) {
+ String dueDateTime = timeDate.getTextContent();
+ String dueDateTimeFormatText = (String) EnvironmentImpl.getFromCurrent("jbpm.duedatetime.format", false);
+ if (dueDateTimeFormatText==null) {
+ dueDateTimeFormatText = "dd/MM/yyyy HH:mm:ss";
+ }
+ SimpleDateFormat dateFormat = new SimpleDateFormat(dueDateTimeFormatText);
+ try {
+ Date duedatetimeDate = dateFormat.parse(dueDateTime);
+ timerDefinition.setDueDate(duedatetimeDate);
+ } catch (ParseException e) {
+ parse.addProblem("couldn't parse timeDate '"+ dueDateTime
+ + "' on intermediate catch timer event " + catchEventId, e);
+ }
+ }
- private void parseResources(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
+ public void parseResources(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
for (Element resourceElement : XmlUtil.elements(documentElement, "resource")) {
@@ -395,7 +416,7 @@
}
- private void parseInterfaces(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
+ public void parseInterfaces(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
for (Element interfaceElement : XmlUtil.elements(documentElement, "interface")) {
for (Element operationElement : XmlUtil.elements(interfaceElement, "operation")) {
@@ -405,14 +426,14 @@
}
}
- private void parseMessages(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
+ public void parseMessages(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
for (Element messageElement : XmlUtil.elements(documentElement, "message")) {
processDefinition.getMessages().put(XmlUtil.attribute(messageElement, "id"), messageElement);
}
}
- private void parseItemDefinitions(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
+ public void parseItemDefinitions(Element documentElement, Parse parse, BpmnProcessDefinition processDefinition) {
for (Element itemDefinitionElement : XmlUtil.elements(documentElement, "itemDefinition")) {
processDefinition.getItemDefinitions().put(XmlUtil.attribute(itemDefinitionElement, "id"), itemDefinitionElement);
@@ -420,7 +441,7 @@
}
- private void parseImports(Element documentElement, Parse parse) {
+ public void parseImports(Element documentElement, Parse parse) {
}
Modified: jbpm4/trunk/modules/bpmn/src/main/resources/jbpm.bpmn.flownodes.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/resources/jbpm.bpmn.flownodes.xml 2010-01-23 03:37:00 UTC (rev 6123)
+++ jbpm4/trunk/modules/bpmn/src/main/resources/jbpm.bpmn.flownodes.xml 2010-01-25 08:55:30 UTC (rev 6124)
@@ -1,8 +1,8 @@
<activities>
<!-- Start / end events -->
- <activity binding="org.jbpm.bpmn.flownodes.StartBinding" />
- <activity binding="org.jbpm.bpmn.flownodes.EndBinding" />
+ <activity binding="org.jbpm.bpmn.flownodes.StartEventBinding" />
+ <activity binding="org.jbpm.bpmn.flownodes.EndEventBinding" />
<!-- Events -->
<activity binding="org.jbpm.bpmn.flownodes.IntermediateCatchEventBinding" />
16 years, 2 months
JBoss JBPM SVN: r6123 - in jbpm4/trunk/modules: examples/src/test/resources/org/jbpm and 9 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-01-22 22:37:00 -0500 (Fri, 22 Jan 2010)
New Revision: 6123
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java
Removed:
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/usertask/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cache/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/cfg/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/subprocess/
Modified:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/timer/event/TimerEventTest.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java
Log:
JBPM-2560: factor out due date calculation, test task due date
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/timer/event/TimerEventTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/timer/event/TimerEventTest.java 2010-01-22 11:51:41 UTC (rev 6122)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/timer/event/TimerEventTest.java 2010-01-23 03:37:00 UTC (rev 6123)
@@ -22,7 +22,7 @@
package org.jbpm.examples.timer.event;
import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -30,7 +30,6 @@
import org.jbpm.api.job.Job;
import org.jbpm.test.JbpmTestCase;
-
/**
* @author Tom Baeyens
*/
@@ -63,8 +62,7 @@
processInstance = executionService.findProcessInstanceById(processInstance.getId());
- Set<String> expectedActivityNames = new HashSet<String>();
- expectedActivityNames.add("guardedWait");
+ Set<String> expectedActivityNames = Collections.singleton("guardedWait");
assertEquals(expectedActivityNames, processInstance.findActiveActivityNames());
assertEquals(Boolean.TRUE, executionService.getVariable(processInstance.getId(), "escalation"));
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2010-01-22 11:51:41 UTC (rev 6122)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2010-01-23 03:37:00 UTC (rev 6123)
@@ -21,19 +21,19 @@
*/
package org.jbpm.jpdl.internal.activity;
-import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.model.Transition;
-import org.jbpm.pvm.internal.cal.BusinessCalendar;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.events.TaskActivityStart;
+import org.jbpm.pvm.internal.job.TimerImpl;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.task.ParticipationImpl;
import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
@@ -42,9 +42,9 @@
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
-
/**
* @author Tom Baeyens
+ * @author Alejandro Guizar
*/
public class TaskActivity extends JpdlExternalActivity {
@@ -71,14 +71,21 @@
task.setName(execution.getActivityName());
}
- task.setDescription(taskDefinition.getDescription());
+ String description = taskDefinition.getDescription();
+ if (description != null) {
+ if (description.contains("#{")) {
+ Object result = ScriptManager.getScriptManager().evaluateExpression(description, null);
+ description = result instanceof String ? (String) result : result.toString();
+ }
+ task.setDescription(description);
+ }
task.setPriority(taskDefinition.getPriority());
task.setFormResourceName(taskDefinition.getFormResourceName());
// calculate the due date of the task based on the due date duration
- if (taskDefinition.getDueDateDuration() != null) {
- BusinessCalendar businessCalendar = EnvironmentImpl.getFromCurrent(BusinessCalendar.class);
- task.setDuedate(businessCalendar.add(task.getCreateTime(), taskDefinition.getDueDateDuration()));
+ String dueDateDescription = taskDefinition.getDueDateDescription();
+ if (dueDateDescription != null) {
+ task.setDuedate(TimerImpl.calculateDueDate(dueDateDescription));
}
// save task so that TaskDbSession.findTaskByExecution works for assign event listeners
@@ -147,7 +154,6 @@
if (transition==null) { // no unnamed transition found
if (signalName == null) {
-
// null was explicitely given as outcome
throw new JbpmException("No unnamed transitions were found for the task '" + getTaskDefinition().getName() + "'");
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-22 11:51:41 UTC (rev 6122)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2010-01-23 03:37:00 UTC (rev 6123)
@@ -528,7 +528,7 @@
taskDefinition.setFormResourceName(form);
String duedate = XmlUtil.attribute(element, "duedate");
- taskDefinition.setDueDateDuration(duedate);
+ taskDefinition.setDueDateDescription(duedate);
Integer priority = XmlUtil.attributeInteger(element, "priority", false, parse);
if (priority != null) {
Modified: jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java 2010-01-22 11:51:41 UTC (rev 6122)
+++ jbpm4/trunk/modules/jpdl/src/test/java/org/jbpm/jpdl/parsing/TaskParsingTest.java 2010-01-23 03:37:00 UTC (rev 6123)
@@ -9,19 +9,16 @@
public class TaskParsingTest extends JpdlParseTestCase {
- public static final String PROCESS = "<process name='Test Task Parsing'>"
- + " <start>"
- + " <transition to='t1' />"
- + " </start>"
- + " <task name='t1' duedate='1 day' priority='3' form='aForm'>"
- + " <description>first task</description>"
- + " <transition to='end' />"
- + " </task>"
- + " <end name='end' />"
- + "</process>";
-
public void testTaskParse() {
- ClientProcessDefinition definition = parse(PROCESS);
+ ClientProcessDefinition definition = parse(
+ "<process name='task parse'>" +
+ " <start>" +
+ " <transition to='t1' />" +
+ " </start>" +
+ " <task name='t1' duedate='1 day' priority='3' form='aForm'>" +
+ " <description>first task</description>" +
+ " </task>" +
+ "</process>");
Activity activity = definition.findActivity("t1");
assert activity instanceof ActivityImpl : activity.getClass();
@@ -37,7 +34,6 @@
assertEquals("first task", taskDefinition.getDescription());
assertEquals(3, taskDefinition.getPriority());
assertEquals("aForm", taskDefinition.getFormResourceName());
- assertEquals("1 day", taskDefinition.getDueDateDuration());
+ assertEquals("1 day", taskDefinition.getDueDateDescription());
}
-
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2010-01-22 11:51:41 UTC (rev 6122)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2010-01-23 03:37:00 UTC (rev 6123)
@@ -21,9 +21,12 @@
*/
package org.jbpm.pvm.internal.job;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.jbpm.api.JbpmException;
import org.jbpm.api.cmd.Environment;
@@ -41,11 +44,9 @@
import org.jbpm.pvm.internal.tx.Transaction;
import org.jbpm.pvm.internal.util.Clock;
-/** a runtime timer instance.
+/**
+ * a runtime timer instance.
*
- * <p>Timers can be
- * </p>
- *
* @author Tom Baeyens
* @author Pascal Verdage
* @author Alejandro Guizar
@@ -56,7 +57,11 @@
private static final long serialVersionUID = 1L;
private static final Log log = Log.getLog(TimerImpl.class.getName());
- private final static String dateFormat = "yyyy-MM-dd HH:mm:ss,SSS";
+ private final static String dateFormat = "yyyy-MM-dd HH:mm:ss";
+ private static final Pattern dateDurationPattern = Pattern.compile("\\s*(#\\{.+\\})\\s*"
+ + "(?:(\\+|-)\\s*(\\d+\\s+(?:business\\s+)?\\w+))?\\s*");
+ private static final Pattern durationPattern = Pattern.compile("\\s*(\\d+\\s+(?:business\\s+)?"
+ + "\\w+)\\s*");
protected String signalName;
protected String eventName;
@@ -73,60 +78,59 @@
timerSession.schedule(this);
}
- public void setDueDateDescription(String dueDateDescription) {
- if (dueDateDescription != null) {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
+ public void setDueDateDescription(String dueDateDescription) {
+ if (dueDateDescription != null) {
+ duedate = calculateDueDate(dueDateDescription);
+ }
+ }
- Date baseDate;
- String durationString = null;
- char durationSeparator = '+'; // needs to be initialized
-
- if (dueDateDescription.startsWith("#")) {
-
- String baseDateEL = dueDateDescription.substring(0, dueDateDescription.indexOf("}") + 1);
- Object result = scriptManager.evaluateExpression(baseDateEL, null);
+ public static Date calculateDueDate(String dueDateDescription) {
+ Date dueDate;
+ // is due date description in date_expression +|- fixed_duration format?
+ Matcher dateDurationMatcher = dateDurationPattern.matcher(dueDateDescription);
+ if (dateDurationMatcher.matches()) {
+ // evaluate date expression
+ String dateExpression = dateDurationMatcher.group(1);
+ Object result = ScriptManager.getScriptManager().evaluateExpression(dateExpression, null);
+ // convert result to Date
+ if (result instanceof Date) {
+ dueDate = (Date) result;
+ } else if (result instanceof Calendar) {
+ Calendar calendar = (Calendar) result;
+ dueDate = calendar.getTime();
+ } else if (result instanceof String) {
+ try {
+ // TODO use a locale-sensitive date format?
+ dueDate = new SimpleDateFormat(dateFormat).parse((String) result);
+ } catch (ParseException e) {
+ throw new JbpmException("invalid base date: " + result, e);
+ }
+ } else {
+ throw new JbpmException("invalid base date: " + result);
+ }
- if (result instanceof Date) {
- baseDate = (Date)result;
- }
- else if (result instanceof Calendar) {
- baseDate = ((Calendar)result).getTime();
- } else {
- throw new JbpmException("Invalid basedate type: " + baseDateEL + " is of type " + result.getClass().getName()
- + ". Only Date and Calendar are supported");
- }
-
- int endOfELIndex = dueDateDescription.indexOf("}");
- if (endOfELIndex < (dueDateDescription.length() - 1)) {
- durationSeparator = dueDateDescription.substring(endOfELIndex + 1).trim().charAt(0);
- if (durationSeparator != '+' && durationSeparator != '-') {
- throw new JbpmException("Invalid duedate, + or - missing after EL");
- }
- durationString = dueDateDescription.substring(endOfELIndex + 1).substring(2).trim();
- log.debug("durationString: " + durationString);
- }
-
- } else {
-
- baseDate = Clock.getCurrentTime();
- durationString = dueDateDescription;
-
- }
-
- if (durationString == null || durationString.length() == 0) {
- duedate = baseDate;
- } else {
- if (durationString.contains("business") && durationSeparator == '-') {
- throw new JbpmException("Invalid duedate, subtraction ('-') not supported if duedate contains 'business'");
- }
- BusinessCalendar businessCalendar = EnvironmentImpl.getFromCurrent(BusinessCalendar.class);
- if (durationSeparator == '+') {
- duedate = businessCalendar.add(baseDate, durationString);
- } else {
- duedate = businessCalendar.subtract(baseDate, durationString);
- }
- }
- }
+ // fixed duration is optional
+ String operationString = dateDurationMatcher.group(2);
+ if (operationString != null) {
+ char operation = operationString.charAt(0);
+ String duration = dateDurationMatcher.group(3);
+ // add duration to base date
+ BusinessCalendar businessCalendar = EnvironmentImpl.getFromCurrent(BusinessCalendar.class);
+ dueDate = operation == '+' ? businessCalendar.add(dueDate, duration)
+ : businessCalendar.subtract(dueDate, duration);
+ }
+ } else {
+ // is due date description in fixed_duration format?
+ Matcher durationMatcher = durationPattern.matcher(dueDateDescription);
+ if (durationMatcher.matches()) {
+ // add duration to current date
+ dueDate = EnvironmentImpl.getFromCurrent(BusinessCalendar.class).add(
+ Clock.getCurrentTime(), durationMatcher.group(1));
+ } else {
+ throw new JbpmException("invalid due date duration: " + dueDateDescription);
+ }
+ }
+ return dueDate;
}
public Boolean execute(Environment environment) throws Exception {
@@ -190,16 +194,14 @@
StringBuilder text = new StringBuilder();
text.append("timer[");
text.append(dbid);
- if (duedate!=null) {
- text.append("|");
- text.append(formatDueDate(duedate));
+ if (duedate != null) {
+ text.append('|').append(formatDueDate(duedate));
}
- if (signalName!=null) {
- text.append("|");
- text.append(signalName);
+ if (signalName != null) {
+ text.append('|').append(signalName);
}
- if (eventName!=null) {
- text.append("|");
+ if (eventName != null) {
+ text.append('|');
text.append(eventName);
}
text.append("]");
@@ -207,7 +209,7 @@
}
public static String formatDueDate(Date date) {
- return new SimpleDateFormat(dateFormat).format(date);
+ return new SimpleDateFormat(dateFormat).format(date);
}
public String getSignalName() {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java 2010-01-22 11:51:41 UTC (rev 6122)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java 2010-01-23 03:37:00 UTC (rev 6123)
@@ -34,7 +34,7 @@
private static final long serialVersionUID = 1L;
- protected String dueDateDuration;
+ protected String dueDateDescription;
protected String formResourceName;
protected List<TaskDefinitionImpl> subTaskDefinitions = new ArrayList<TaskDefinitionImpl>();
protected int priority = Priority.NORMAL;
@@ -58,11 +58,11 @@
public void setSwimlaneDefinition(SwimlaneDefinitionImpl swimlaneDefinition) {
this.swimlaneDefinition = swimlaneDefinition;
}
- public String getDueDateDuration() {
- return dueDateDuration;
+ public String getDueDateDescription() {
+ return dueDateDescription;
}
- public void setDueDateDuration(String dueDateDuration) {
- this.dueDateDuration = dueDateDuration;
+ public void setDueDateDescription(String dueDateDescription) {
+ this.dueDateDescription = dueDateDescription;
}
public String getFormResourceName() {
return formResourceName;
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java 2010-01-23 03:37:00 UTC (rev 6123)
@@ -0,0 +1,134 @@
+/*
+ * 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.test.task;
+
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.task.Task;
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * Exercises for various ways to define the deadline of a task.
+ *
+ * @see <a href="https://jira.jboss.org/jira/browse/JBPM-2560">JBPM-2560</a>
+ * @author Alejandro Guizar
+ */
+public class TaskDueDateTest extends JbpmTestCase {
+
+ public void testBaseDate() {
+ deployJpdlXmlString(
+ "<process name='BaseDate'>" +
+ " <start><transition to='t'/></start>" +
+ " <task name='t' duedate='#{tomorrow}'/>" +
+ "</process>");
+
+ Calendar tomorrow = Calendar.getInstance();
+ tomorrow.add(Calendar.DATE, 1);
+ Map<String, ? > variables = Collections.singletonMap("tomorrow", tomorrow);
+ String processInstanceId = executionService.startProcessInstanceByKey("BaseDate", variables)
+ .getId();
+
+ List<Task> taskList = taskService.createTaskQuery()
+ .processInstanceId(processInstanceId)
+ .list();
+ assertEquals(1, taskList.size());
+
+ Task task = taskList.get(0);
+ assertEquals(tomorrow.getTime(), task.getDuedate());
+ }
+
+ public void testBaseDatePlusDuration() {
+ deployJpdlXmlString(
+ "<process name='BaseDatePlusDuration'>" +
+ " <start><transition to='t'/></start>" +
+ " <task name='t' duedate='#{tomorrow} + 1 hour'/>" +
+ "</process>");
+
+ Calendar tomorrow = Calendar.getInstance();
+ tomorrow.add(Calendar.DATE, 1);
+ Map<String, ? > variables = Collections.singletonMap("tomorrow", tomorrow);
+ String processInstanceId = executionService.startProcessInstanceByKey(
+ "BaseDatePlusDuration", variables).getId();
+
+ List<Task> taskList = taskService.createTaskQuery()
+ .processInstanceId(processInstanceId)
+ .list();
+ assertEquals(1, taskList.size());
+
+ Task task = taskList.get(0);
+ tomorrow.add(Calendar.HOUR, 1);
+ assertEquals(tomorrow.getTime(), task.getDuedate());
+ }
+
+ public void testBaseDateMinusDuration() {
+ deployJpdlXmlString(
+ "<process name='BaseDateMinusDuration'>" +
+ " <start><transition to='t'/></start>" +
+ " <task name='t' duedate='#{tomorrow} - 1 hour'/>" +
+ "</process>");
+
+ Calendar tomorrow = Calendar.getInstance();
+ tomorrow.add(Calendar.DATE, 1);
+ Map<String, ? > variables = Collections.singletonMap("tomorrow", tomorrow);
+ String processInstanceId = executionService.startProcessInstanceByKey(
+ "BaseDateMinusDuration", variables).getId();
+
+ List<Task> taskList = taskService.createTaskQuery()
+ .processInstanceId(processInstanceId)
+ .list();
+ assertEquals(1, taskList.size());
+
+ Task task = taskList.get(0);
+ tomorrow.add(Calendar.HOUR, -1);
+ assertEquals(tomorrow.getTime(), task.getDuedate());
+ }
+
+ public void testDuration() {
+ deployJpdlXmlString(
+ "<process name='Duration'>" +
+ " <start><transition to='t'/></start>" +
+ " <task name='t' duedate='1 hour'/>" +
+ "</process>");
+
+ Calendar now = Calendar.getInstance();
+ // prevent wrong results in databases lacking millisecond precision
+ now.set(Calendar.MILLISECOND, 0);
+ Clock.setCurrentTime(now.getTime());
+
+ String processInstanceId = executionService.startProcessInstanceByKey("Duration").getId();
+
+ List<Task> taskList = taskService.createTaskQuery()
+ .processInstanceId(processInstanceId)
+ .list();
+ assertEquals(1, taskList.size());
+
+ Task task = taskList.get(0);
+ now.add(Calendar.HOUR, 1);
+ // because task.getDuedate() returns java.sql.Timestamp here,
+ // comparison has to be made in milliseconds
+ assertEquals(now.getTimeInMillis(), task.getDuedate().getTime());
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskDueDateTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java 2010-01-22 11:51:41 UTC (rev 6122)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java 2010-01-23 03:37:00 UTC (rev 6123)
@@ -22,7 +22,6 @@
package org.jbpm.test.timer;
import java.util.Calendar;
-import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -36,7 +35,6 @@
import org.jbpm.api.listener.EventListenerExecution;
import org.jbpm.test.JbpmTestCase;
-
/**
* @author Tom Baeyens
* @author Ronald Van Kuijk
@@ -198,117 +196,116 @@
}
public void testTimerELCalendarAdd() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <transition to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <transition to='b' />" +
- " <transition name='timeout' to='escalate'>" +
- " <timer duedate='#{proc_var} + 5 days' />" +
- " </transition>" +
- " </state>" +
- " <state name='b' />" +
- " <end name='escalate' />" +
- "</process>"
- );
-
- Map<String, Object> proc_vars = new HashMap<String, Object>();
- Calendar cal = Calendar.getInstance();
- cal.add(Calendar.DAY_OF_MONTH, 6);
- proc_vars.put("proc_var", cal);
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
-
- Job job = managementService.createJobQuery()
- .processInstanceId(processInstance.getId())
- .uniqueResult();
-
- Calendar jobDate = Calendar.getInstance();
- jobDate.setTime(job.getDuedate());
-
- cal.add(Calendar.DAY_OF_MONTH, 5);
- assertEquals(cal.get(Calendar.DAY_OF_MONTH), jobDate.get(Calendar.DAY_OF_MONTH));
-
- managementService.executeJob(job.getId());
- assertProcessInstanceEnded(processInstance);
- }
-
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " <transition name='timeout' to='escalate'>" +
+ " <timer duedate='#{proc_var} + 5 days' />" +
+ " </transition>" +
+ " </state>" +
+ " <state name='b' />" +
+ " <end name='escalate' />" +
+ "</process>"
+ );
+
+ Map<String, Object> proc_vars = new HashMap<String, Object>();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_MONTH, 6);
+ proc_vars.put("proc_var", cal);
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ Calendar jobDate = Calendar.getInstance();
+ jobDate.setTime(job.getDuedate());
+
+ cal.add(Calendar.DAY_OF_MONTH, 5);
+ assertEquals(cal.get(Calendar.DAY_OF_MONTH), jobDate.get(Calendar.DAY_OF_MONTH));
+
+ managementService.executeJob(job.getId());
+ assertProcessInstanceEnded(processInstance);
+ }
+
public void testTimerELCalendarSubtract() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <transition to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <transition to='b' />" +
- " <transition name='timeout' to='escalate'>" +
- " <timer duedate='#{proc_var} - 5 days' />" +
- " </transition>" +
- " </state>" +
- " <state name='b' />" +
- " <end name='escalate' />" +
- "</process>"
- );
-
- Map<String, Object> proc_vars = new HashMap<String, Object>();
- Calendar cal = Calendar.getInstance();
- cal.add(Calendar.DAY_OF_MONTH, 6);
- proc_vars.put("proc_var", cal);
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
-
- Job job = managementService.createJobQuery()
- .processInstanceId(processInstance.getId())
- .uniqueResult();
-
- Calendar jobDate = Calendar.getInstance();
- jobDate.setTime(job.getDuedate());
-
- // 6 days from now minus 5 days is tomorrow so subtract 5 from the original added 6.
- assertEquals(cal.get(Calendar.DAY_OF_MONTH) -5 , jobDate.get(Calendar.DAY_OF_MONTH));
-
- managementService.executeJob(job.getId());
- assertProcessInstanceEnded(processInstance);
- }
-
-
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " <transition name='timeout' to='escalate'>" +
+ " <timer duedate='#{proc_var} - 5 days' />" +
+ " </transition>" +
+ " </state>" +
+ " <state name='b' />" +
+ " <end name='escalate' />" +
+ "</process>"
+ );
+
+ Map<String, Object> proc_vars = new HashMap<String, Object>();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_MONTH, 6);
+ proc_vars.put("proc_var", cal);
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ Calendar jobDate = Calendar.getInstance();
+ jobDate.setTime(job.getDuedate());
+
+ // 6 days from now minus 5 days is tomorrow so subtract 5 from the original added 6.
+ assertEquals(cal.get(Calendar.DAY_OF_MONTH) -5 , jobDate.get(Calendar.DAY_OF_MONTH));
+
+ managementService.executeJob(job.getId());
+ assertProcessInstanceEnded(processInstance);
+ }
+
public void testTimerELCalendarAddBusiness() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <transition to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <transition to='b' />" +
- " <transition name='timeout' to='escalate'>" +
- " <timer duedate='#{proc_var} + 5 business days' />" +
- " </transition>" +
- " </state>" +
- " <state name='b' />" +
- " <end name='escalate' />" +
- "</process>"
- );
-
- Map<String, Object> proc_vars = new HashMap<String, Object>();
- Calendar cal = Calendar.getInstance();
- cal.set(2010, 01, 12, 12, 00, 00); // 12 feb 2010 noon
- proc_vars.put("proc_var", cal);
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
-
- Job job = managementService.createJobQuery()
- .processInstanceId(processInstance.getId())
- .uniqueResult();
-
- Calendar jobDate = Calendar.getInstance();
- jobDate.setTime(job.getDuedate());
-
- // 12 feb is friday, 5 businessdays further is friday 19th
- assertEquals(19 , jobDate.get(Calendar.DAY_OF_MONTH));
-
- managementService.executeJob(job.getId());
- assertProcessInstanceEnded(processInstance);
- }
-
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " <transition name='timeout' to='escalate'>" +
+ " <timer duedate='#{proc_var} + 5 business days' />" +
+ " </transition>" +
+ " </state>" +
+ " <state name='b' />" +
+ " <end name='escalate' />" +
+ "</process>"
+ );
+
+ Map<String, Object> proc_vars = new HashMap<String, Object>();
+ Calendar cal = Calendar.getInstance();
+ cal.set(2010, 01, 12, 12, 00, 00); // 12 feb 2010 noon
+ proc_vars.put("proc_var", cal);
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ Calendar jobDate = Calendar.getInstance();
+ jobDate.setTime(job.getDuedate());
+
+ // 12 feb is friday, 5 businessdays further is friday 19th
+ assertEquals(19 , jobDate.get(Calendar.DAY_OF_MONTH));
+
+ managementService.executeJob(job.getId());
+ assertProcessInstanceEnded(processInstance);
+ }
+
public void testTimerELFail() {
deployJpdlXmlString(
"<process name='Insurance claim' key='ICL'>" +
@@ -329,65 +326,65 @@
Map<String, Object> proc_vars = new HashMap<String, Object>();
proc_vars.put("proc_var", new Long(0));
try {
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
+ executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
fail("Should not happen, exception expected");
} catch (Exception e) {}
}
public void testTimerELSubtractBusinessFail() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <transition to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <transition to='b' />" +
- " <transition name='timeout' to='escalate'>" +
- " <timer duedate='#{proc_var} - 6 business days' />" +
- " </transition>" +
- " </state>" +
- " <state name='b' />" +
- " <end name='escalate' />" +
- "</process>"
- );
-
- Map<String, Object> proc_vars = new HashMap<String, Object>();
- Calendar cal = Calendar.getInstance();
- cal.set(2010, 01, 12, 12, 00, 00); // 12 feb 2010 noon
- proc_vars.put("proc_var", cal);
- try {
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
- fail("Should not happen, exception expected");
- } catch (Exception e) {}
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " <transition name='timeout' to='escalate'>" +
+ " <timer duedate='#{proc_var} - 6 business days' />" +
+ " </transition>" +
+ " </state>" +
+ " <state name='b' />" +
+ " <end name='escalate' />" +
+ "</process>"
+ );
+
+ Map<String, Object> proc_vars = new HashMap<String, Object>();
+ Calendar cal = Calendar.getInstance();
+ cal.set(2010, 01, 12, 12, 00, 00); // 12 feb 2010 noon
+ proc_vars.put("proc_var", cal);
+ try {
+ executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
+ fail("Should not happen, exception expected");
+ } catch (Exception e) {}
}
public void testTimerELSubtractPastFail() {
- deployJpdlXmlString(
- "<process name='Insurance claim' key='ICL'>" +
- " <start>" +
- " <transition to='a' />" +
- " </start>" +
- " <state name='a'>" +
- " <transition to='b' />" +
- " <transition name='timeout' to='escalate'>" +
- " <timer duedate='#{proc_var} - 3 days' />" +
- " </transition>" +
- " </state>" +
- " <state name='b' />" +
- " <end name='escalate' />" +
- "</process>"
- );
-
- Map<String, Object> proc_vars = new HashMap<String, Object>();
- Calendar cal = Calendar.getInstance();
- cal.add(Calendar.DAY_OF_MONTH, 2);
- proc_vars.put("proc_var", cal);
- try {
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
- fail("Should not happen, exception expected");
- } catch (Exception e) {}
-}
-
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " <transition name='timeout' to='escalate'>" +
+ " <timer duedate='#{proc_var} - 3 days' />" +
+ " </transition>" +
+ " </state>" +
+ " <state name='b' />" +
+ " <end name='escalate' />" +
+ "</process>"
+ );
+
+ Map<String, Object> proc_vars = new HashMap<String, Object>();
+ Calendar cal = Calendar.getInstance();
+ cal.add(Calendar.DAY_OF_MONTH, 2);
+ proc_vars.put("proc_var", cal);
+ try {
+ executionService.startProcessInstanceByKey("ICL", proc_vars, "82436");
+ fail("Should not happen, exception expected");
+ } catch (Exception e) {}
+ }
+
public void testTimerTimeoutCustom() {
deployJpdlXmlString(TEST_PROCESS_CUSTOM);
@@ -412,7 +409,6 @@
assertProcessInstanceActive(processInstance);
executionService.signalExecutionById(processInstance.getExecution("a").getId());
assertActivityActive(processInstance.getId(), "b");
-
}
public void testTimerSignalCustom() {
16 years, 2 months
JBoss JBPM SVN: r6122 - projects/businesslink.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2010-01-22 06:51:41 -0500 (Fri, 22 Jan 2010)
New Revision: 6122
Modified:
projects/businesslink/
Log:
adding persistence
Property changes on: projects/businesslink
___________________________________________________________________
Name: svn:ignore
+ .settings
target
16 years, 2 months