[jbpm-commits] JBoss JBPM SVN: r6421 - in jbpm4/trunk/modules: test-db/src/test/java/org/jbpm/test/activity/foreach and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jun 17 13:15:23 EDT 2010


Author: swiderski.maciej
Date: 2010-06-17 13:15:22 -0400 (Thu, 17 Jun 2010)
New Revision: 6421

Modified:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/foreach/ForEachTest.java
Log:
JBPM-2414: fix for left tasks after execution is ended. while ending execution task attached to it will be skipped if not yet completed

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2010-06-16 23:45:19 UTC (rev 6420)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2010-06-17 17:15:22 UTC (rev 6421)
@@ -74,6 +74,7 @@
 import org.jbpm.pvm.internal.task.AssignableDefinitionImpl;
 import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
 import org.jbpm.pvm.internal.task.SwimlaneImpl;
+import org.jbpm.pvm.internal.task.TaskImpl;
 import org.jbpm.pvm.internal.type.Variable;
 import org.jbpm.pvm.internal.util.EqualsUtil;
 import org.jbpm.pvm.internal.util.Priority;
@@ -362,10 +363,19 @@
     this.propagation = Propagation.EXPLICIT;
     
     DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class, false);
+    
+    
 
     if (parent!=null) {
       parent.removeExecution(this);
       if (dbSession!=null) {
+        
+        // make sure task attached to this execution are completed or skipped
+        TaskImpl task = dbSession.findTaskByExecution(this);
+        if (task != null && !task.isCompleted()) {
+          task.skip(null);
+        }
+        
         dbSession.delete(this);
       }
     }

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/foreach/ForEachTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/foreach/ForEachTest.java	2010-06-16 23:45:19 UTC (rev 6420)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/foreach/ForEachTest.java	2010-06-17 17:15:22 UTC (rev 6421)
@@ -31,6 +31,7 @@
 import org.jbpm.api.JbpmException;
 import org.jbpm.api.ProcessInstance;
 import org.jbpm.api.history.HistoryProcessInstance;
+import org.jbpm.api.history.HistoryTask;
 import org.jbpm.api.task.Task;
 import org.jbpm.test.JbpmTestCase;
 
@@ -384,4 +385,54 @@
       // expected result
     }
   }
+  
+  public void testForEachJoinMultiplicityLeftTask() {
+    deployJpdlXmlString(""
+      + "<process name='ForEachJoinMultiplicity' xmlns='http://jbpm.org/jpdl/4.4'>"
+      + "   <start g='179,17,32,29' name='start1'>"
+      + "      <transition g='-43,-18' name='to foreach1' to='foreach1'/>"
+      + "   </start>"
+      + "   <foreach g='185,95,49,50' name='foreach1' var='assign' in='#{actors}'>"
+      + "      <transition name='left' to='task1' g='-44,-18'/>"
+      + "   </foreach>"
+      + "   <task name='task1' g='90,177,73,44' assignee='#{assign}'>"
+      + "      <transition name='to state' to='join2' g='-43,-18'/>"
+      + "   </task>"
+      + "   <join name='join2' g='192,511,57,44' multiplicity='#{actors.size()-1}'>"
+      + "      <transition name='to Big car' to='Big car' g='-42,-18'/>"
+      + "   </join>"
+      + "   <state name='Big car' > "
+      + "   <transition name='to end1' to='end1' g='-43,-18'/>"
+!
       + "   </state> "
+      + "   <end g='193,606,38,33' name='end1'/>"
+      + "</process>");
+
+    Map<String, ?> variables = Collections.singletonMap("actors", Arrays.asList("alex", "mike"));
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("ForEachJoinMultiplicity", variables);
+
+    Task taskAlex = taskService.createTaskQuery().assignee("alex").uniqueResult();
+    assertEquals("task1", taskAlex.getActivityName());
+    taskService.completeTask(taskAlex.getId());
+
+    Task taskMike = taskService.createTaskQuery().assignee("mike").uniqueResult();
+    assertNull(taskMike);
+    
+    processInstance = executionService.findProcessInstanceById(processInstance.getId());
+    
+    executionService.signalExecutionById(processInstance.getId());
+
+    HistoryProcessInstance history = historyService.createHistoryProcessInstanceQuery()
+      .processInstanceId(processInstance.getId())
+      .uniqueResult();
+    assertEquals(ProcessIns!
 tance.STATE_ENDED, history.getState());
+    assertEquals("end!
 1", hist
ory.getEndActivityName());
+    
+    List<HistoryTask> historyTasks = historyService.createHistoryTaskQuery().assignee("alex").list();
+    assertEquals(1, historyTasks.size());
+    assertEquals(HistoryTask.STATE_COMPLETED, historyTasks.get(0).getState());
+    
+    historyTasks = historyService.createHistoryTaskQuery().assignee("mike").list();
+    assertEquals(1, historyTasks.size());
+    assertEquals(HistoryTask.STATE_OBSOLETE, historyTasks.get(0).getState());
+  }
 }


More information about the jbpm-commits mailing list