Index: modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
===================================================================
--- modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java (revision 6341)
+++ modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java (working copy)
@@ -38,6 +38,7 @@
import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.internal.session.RepositorySession;
import org.jbpm.pvm.internal.task.SwimlaneImpl;
+import org.jbpm.pvm.internal.session.DbSession;
/**
@@ -155,6 +156,11 @@
} else if (activity.hasOutgoingTransition(subProcessActivityName)) {
transitionName = subProcessActivityName;
}
+
+ DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class, false);
+ if (dbSession!=null) {
+ dbSession.deleteProcessInstance(subProcessInstance.getId(), false);
+ }
} finally {
if (subProcessExecutionContext!=null) {
Index: modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessDeleteTest.java
===================================================================
--- modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessDeleteTest.java (revision 6341)
+++ modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessDeleteTest.java (working copy)
@@ -41,7 +41,7 @@
" " +
""
);
-
+
deployJpdlXmlString(
"" +
" " +
@@ -51,11 +51,15 @@
" " +
" " +
" " +
- ""
+ ""
);
-
+
String pid = executionService.startProcessInstanceByKey("MainProcess").getId();
-
+
+ assertEquals(2, executionService.createProcessInstanceQuery().list().size());
+
executionService.deleteProcessInstance(pid);
+
+ assertEquals(0, executionService.createProcessInstanceQuery().list().size());
}
}
Index: modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessTest.java
===================================================================
--- modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessTest.java (revision 6341)
+++ modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessTest.java (working copy)
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
/**
- *
+ *
*/
package org.jbpm.test.activity.subprocess;
@@ -36,11 +36,11 @@
/**
* Test case for different usages of the subprocess activity.
- *
+ *
* @author Joram Barrez
*/
public class SubProcessTest extends JbpmTestCase {
-
+
private static final String MAIN_PROCESS =
"" +
" " +
@@ -52,10 +52,12 @@
" " +
" " +
" " +
- " " +
+ " " +
+ " " +
+ " " +
" " +
- "";
-
+ "";
+
private static final String SUB_PROCESS =
"" +
" " +
@@ -69,8 +71,8 @@
" " +
" " +
" " +
- "";
-
+ "";
+
private static final String MAIN_PROCESS_NO_WAIT_STATE =
"" +
" " +
@@ -80,16 +82,16 @@
" " +
" " +
" " +
- "";
-
+ "";
+
private static final String SUB_PROCESS_NO_WAIT_STATE =
"" +
" " +
" " +
" " +
" " +
- "";
-
+ "";
+
private static final String MAIN_PROCESS_SUB_EL =
"" +
" " +
@@ -103,36 +105,45 @@
" " +
" " +
" " +
- "";
-
+ "";
+
public void testSubProcessOutcomeToState() {
deployJpdlXmlString(SUB_PROCESS);
deployJpdlXmlString(MAIN_PROCESS);
-
+
ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess");
+
+ assertEquals(2, executionService.createProcessInstanceQuery().list().size());
+
Task task = taskService.findPersonalTasks("johndoe").get(0);
taskService.completeTask(task.getId(), "nok");
+
assertActivityActive(processInstance.getId(), "update");
+
+ processInstance = executionService.signalExecutionById(processInstance.getId());
+
+ assertProcessInstanceEnded(processInstance);
+ assertEquals(0, executionService.createProcessInstanceQuery().list().size());
}
-
+
public void testDynamicSubProcess() {
deployJpdlXmlString(SUB_PROCESS);
deployJpdlXmlString(MAIN_PROCESS_SUB_EL);
-
+
Map vars = new HashMap();
vars.put("dynamic_subprocess", "SubProcessReview");
ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess",vars);
Task task = taskService.findPersonalTasks("johndoe").get(0);
taskService.completeTask(task.getId(), "reject");
- assertProcessInstanceEnded(processInstance);
+ assertProcessInstanceEnded(processInstance);
}
-
+
public void testDynamicSubProcessNotFound() {
String expectedError = "Subprocess 'DOES_NOT_EXIST' could not be found.";
deployJpdlXmlString(SUB_PROCESS);
deployJpdlXmlString(MAIN_PROCESS_SUB_EL);
-
+
Map vars = new HashMap();
vars.put("dynamic_subprocess", "DOES_NOT_EXIST");
try {
@@ -142,12 +153,12 @@
assertEquals(expectedError, je.getMessage());
}
}
-
+
public void testDynamicSubProcessWrongProperty() {
String expectedError = "Subprocess key '#{dynamic_subprocess}' could not be resolved.";
deployJpdlXmlString(SUB_PROCESS);
deployJpdlXmlString(MAIN_PROCESS_SUB_EL);
-
+
Map vars = new HashMap();
vars.put("WRONG_PROPERTY", "VALUE_DOES_NOT_MATTER");
try {
@@ -157,24 +168,24 @@
assertEquals(expectedError, je.getMessage());
}
}
-
+
public void testSubProcessOutcomeToEnd() {
deployJpdlXmlString(SUB_PROCESS);
deployJpdlXmlString(MAIN_PROCESS);
-
+
ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess");
Task task = taskService.findPersonalTasks("johndoe").get(0);
taskService.completeTask(task.getId(), "reject");
- assertProcessInstanceEnded(processInstance);
+ assertProcessInstanceEnded(processInstance);
}
-
+
// Test for JBPM-2651
public void testSubProcessNoWaitStates() {
deployJpdlXmlString(SUB_PROCESS_NO_WAIT_STATE);
deployJpdlXmlString(MAIN_PROCESS_NO_WAIT_STATE);
-
+
executionService.startProcessInstanceByKey("mainProcess");
}
-
+
}