[jbpm-commits] JBoss JBPM SVN: r6802 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/bpmn/event/timer and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sun Nov 7 05:07:29 EST 2010


Author: rebody
Date: 2010-11-07 05:07:28 -0500 (Sun, 07 Nov 2010)
New Revision: 6802

Added:
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/BoundaryEventTimerNoneInterruptingTest.java
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/boundary_event_timer_none_interrupting.bpmn.xml
Modified:
   jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryTimerEvent.java
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/BoundaryEventTimerInterruptingTest.java
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/boundary_event_timer_interrupting.bpmn.xml
Log:
JBPM-2729 non interrupting boundary timer event

Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryTimerEvent.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryTimerEvent.java	2010-11-07 09:44:19 UTC (rev 6801)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/BoundaryTimerEvent.java	2010-11-07 10:07:28 UTC (rev 6802)
@@ -24,6 +24,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.jbpm.api.Execution;
 import org.jbpm.api.listener.EventListener;
 import org.jbpm.api.listener.EventListenerExecution;
 import org.jbpm.api.model.Transition;
@@ -44,17 +45,25 @@
 
   @SuppressWarnings("unchecked")
   public void execute(ExecutionImpl execution) {
-    ProcessDefinitionImpl processDefinitionImpl = execution.getProcessDefinition();
-    ActivityImpl activityImpl = processDefinitionImpl.getActivity(boundaryTimerEventActivityName);
     if (interrupting) {
       ExecutionImpl parent = execution.destroyScope(execution.getActivity());
-      parent.moveTo(activityImpl);
-      parent.take(activityImpl.getOutgoingTransitions().get(0));
+      this.executeBoundaryEventBranch(parent);
     } else {
-      execution.takeDefaultTransition();
+      ExecutionImpl parent = execution.getParent();
+      ExecutionImpl childExecution = parent.createExecution();
+      childExecution.setState(Execution.STATE_ACTIVE_CONCURRENT);
+      this.executeBoundaryEventBranch(childExecution);
+      this.proceed(execution, this.findOutgoingSequenceFlow(execution, true));
     }
   }
 
+  protected void executeBoundaryEventBranch(ExecutionImpl execution) {
+    ProcessDefinitionImpl processDefinitionImpl = execution.getProcessDefinition();
+    ActivityImpl activityImpl = processDefinitionImpl.getActivity(boundaryTimerEventActivityName);
+    execution.moveTo(activityImpl);
+    execution.take(activityImpl.getOutgoingTransitions().get(0));
+  }
+
   public void notify(EventListenerExecution execution) {
     this.execute((ExecutionImpl) execution);
   }

Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/BoundaryEventTimerInterruptingTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/BoundaryEventTimerInterruptingTest.java	2010-11-07 09:44:19 UTC (rev 6801)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/BoundaryEventTimerInterruptingTest.java	2010-11-07 10:07:28 UTC (rev 6802)
@@ -22,6 +22,7 @@
 package org.jbpm.examples.bpmn.event.timer;
 
 import java.util.Date;
+import java.util.List;
 
 import org.jbpm.api.NewDeployment;
 import org.jbpm.api.ProcessInstance;
@@ -50,7 +51,20 @@
     super.tearDown();
   }
 
-  public void testIntermediateTimerWithDuration() {
+  public void testWithoutTimerEvent() {
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("boundary_event_timer_interrupting");
+
+    Task task = taskService.createTaskQuery().uniqueResult();
+    taskService.completeTask(task.getId());
+    assertProcessInstanceEnded(processInstance);
+
+    List timerJobs = managementService.createJobQuery()
+                                    .processInstanceId(processInstance.getId())
+                                    .list();
+    assertEquals(0, timerJobs.size());
+  }
+
+  public void testTimerEvent() {
     Clock.setExplicitTime(new Date(0));
 
     ProcessInstance processInstance = executionService.startProcessInstanceByKey("boundary_event_timer_interrupting");

Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/BoundaryEventTimerNoneInterruptingTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/BoundaryEventTimerNoneInterruptingTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/BoundaryEventTimerNoneInterruptingTest.java	2010-11-07 10:07:28 UTC (rev 6802)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.bpmn.event.timer;
+
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.api.task.Task;
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ *
+ * @author Huisheng Xu
+ */
+public class BoundaryEventTimerNoneInterruptingTest extends JbpmTestCase {
+
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
+    NewDeployment deployment = repositoryService.createDeployment();
+    deployment.addResourceFromClasspath("org/jbpm/examples/bpmn/event/timer/boundary_event_timer_none_interrupting.bpmn.xml");
+    registerDeployment(deployment.deploy());
+  }
+
+  @Override
+  protected void tearDown() throws Exception {
+    Clock.setExplicitTime(null);
+    super.tearDown();
+  }
+
+  public void testWithoutTimerEvent() {
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("boundary_event_timer_none_interrupting");
+
+    Task task = taskService.createTaskQuery().uniqueResult();
+    taskService.completeTask(task.getId());
+    assertProcessInstanceEnded(processInstance);
+
+    List timerJobs = managementService.createJobQuery()
+                                    .processInstanceId(processInstance.getId())
+                                    .list();
+    assertEquals(0, timerJobs.size());
+  }
+
+  public void testTimerEvent() {
+    Clock.setExplicitTime(new Date(0));
+
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("boundary_event_timer_none_interrupting");
+    Job timerJob = managementService.createJobQuery()
+                                    .processInstanceId(processInstance.getId())
+                                    .uniqueResult();
+    assertEquals(new Date(60 * 60 * 1000).getTime(), timerJob.getDueDate().getTime());
+    managementService.executeJob(timerJob.getId());
+
+    assertProcessInstanceEnded(processInstance);
+  }
+
+}

Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/boundary_event_timer_interrupting.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/boundary_event_timer_interrupting.bpmn.xml	2010-11-07 09:44:19 UTC (rev 6801)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/boundary_event_timer_interrupting.bpmn.xml	2010-11-07 10:07:28 UTC (rev 6802)
@@ -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/terminate_end_event"
+  targetNamespace="http://jbpm.org/example/bpmn2/boundary_event_timer_interrupting"
   xmlns:jbpm="http://jbpm.org/bpmn2">
 
     <process id="boundary_event_timer_interrupting" name="Timer escalation example">

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/boundary_event_timer_none_interrupting.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/boundary_event_timer_none_interrupting.bpmn.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/boundary_event_timer_none_interrupting.bpmn.xml	2010-11-07 10:07:28 UTC (rev 6802)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
+  xmlns="http://schema.omg.org/spec/BPMN/2.0"
+  typeLanguage="http://www.w3.org/2001/XMLSchema"
+  expressionLanguage="http://www.w3.org/1999/XPath"
+  targetNamespace="http://jbpm.org/example/bpmn2/boundary_event_timer_none_interrupting"
+  xmlns:jbpm="http://jbpm.org/bpmn2">
+
+    <process id="boundary_event_timer_none_interrupting" name="Timer escalation example">
+
+        <startEvent id="theStart" />
+
+        <sequenceFlow id="flow1" sourceRef="theStart" targetRef="firstLineSupport" />
+
+        <userTask id="firstLineSupport" name="First line support">
+          <documentation>Fix issue raised by customer</documentation>
+        </userTask>
+
+        <sequenceFlow id="flow2" sourceRef="firstLineSupport" targetRef="normalEnd" />
+
+        <endEvent id="normalEnd" />
+
+        <boundaryEvent id="escalationTimer" cancelActivity="false" attachedToRef="firstLineSupport">
+            <timerEventDefinition>
+                <timeDate xsi:type="tFormalExpression">01/01/1970 09:00:00</timeDate>
+            </timerEventDefinition>
+        </boundaryEvent>
+
+        <sequenceFlow id="flow3" sourceRef="escalationTimer" targetRef="secondLineSupport" />
+
+        <userTask id="secondLineSupport" name="Second line support">
+          <documentation>Escalation: issue was not fixed in time by first level support</documentation>
+        </userTask>
+
+        <sequenceFlow id="flow4" sourceRef="secondLineSupport" targetRef="escalatedEnd" />
+
+        <endEvent id="escalatedEnd" />
+
+    </process>
+
+</definitions>
\ No newline at end of file



More information about the jbpm-commits mailing list