[jbpm-commits] JBoss JBPM SVN: r5898 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/cmd and 5 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Nov 28 03:04:19 EST 2009


Author: tom.baeyens at jboss.com
Date: 2009-11-28 03:04:18 -0500 (Sat, 28 Nov 2009)
New Revision: 5898

Added:
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessDeleteTest.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessTest.java
Removed:
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/subprocess/SubProcessTest.java
Modified:
   jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/StartExecutionTest.java
Log:
JBPM-2491 JBPM-2616 JBPM-2628 deleting process instances that have sub processes

Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java	2009-11-28 03:00:30 UTC (rev 5897)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/repository/JpdlDeployer.java	2009-11-28 08:04:18 UTC (rev 5898)
@@ -59,10 +59,6 @@
     super(jpdlExtension, jpdlParser);
   }
 
-  protected String getProcessLanguageId() {
-    return "";
-  }
-
   public void updateResource(DeploymentImpl deployment, String resourceName, byte[] bytes) {
     if (resourceName.endsWith(".jpdl.xml")) {
       Document document = parser
@@ -173,29 +169,6 @@
     }
   }
 
-//  public Map<String, List<Element>> getElementsByTagName(Element element) {
-//    Map<String, List<Element>> elementsByTagName = new HashMap<String, List<Element>>();
-//    for (Element contentElement: XmlUtil.elements(element)) {
-//      String tagName = XmlUtil.getTagLocalName(contentElement);
-//      List<Element> tagElements = elementsByTagName.get(tagName);
-//      if (tagElements==null) {
-//        tagElements = new ArrayList<Element>();
-//        elementsByTagName.put(tagName, tagElements);
-//      }
-//      tagElements.add(contentElement);
-//    }
-//    return elementsByTagName;
-//  }
-
-//  private void mergeAttributes(Element element, NamedNodeMap attributes) {
-//    for (int i=0; i<attributes.getLength(); i++) {
-//      Node attribute = attributes.item(i);
-//      String attributeName = attribute.getNodeName();
-//      String attributeValue = attribute.getNodeValue();
-//      element.setAttribute(attributeName, attributeValue);
-//    }
-//  }
-
   protected Map<String, Element> getActivityMap(Element containerElement, Set<String> activityNames) {
     Map<String, Element> activityMap = new HashMap<String, Element>();
     

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java	2009-11-28 03:00:30 UTC (rev 5897)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java	2009-11-28 08:04:18 UTC (rev 5898)
@@ -57,7 +57,7 @@
     RepositorySession repositorySession = environment.get(RepositorySession.class);
     processDefinition = (ClientProcessDefinition) repositorySession.findProcessDefinitionByKey(processDefinitionKey);
     if (processDefinition==null) {
-      throw new JbpmException("no process definition with key "+processDefinitionKey);
+      throw new JbpmException("no process definition with key '"+processDefinitionKey+"'");
     }
     
     ClientProcessInstance processInstance = processDefinition.createProcessInstance(executionKey);

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	2009-11-28 03:00:30 UTC (rev 5897)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java	2009-11-28 08:04:18 UTC (rev 5898)
@@ -22,6 +22,7 @@
 package org.jbpm.pvm.internal.hibernate;
 
 import java.io.Serializable;
+import java.util.Collection;
 import java.util.List;
 
 import org.hibernate.LockMode;
@@ -249,6 +250,8 @@
     
     ExecutionImpl processInstance = (ExecutionImpl) findProcessInstanceByIdIgnoreSuspended(processInstanceId);
     if (processInstance!=null) {
+      deleteSubProcesses(processInstance, deleteHistory);
+      
       // delete remaining tasks for this process instance
       List<TaskImpl> tasks = findTasks(processInstanceId);
       for (TaskImpl task: tasks) {
@@ -272,6 +275,21 @@
     }
   }
 
+  private void deleteSubProcesses(ExecutionImpl execution, boolean deleteHistory) {
+    ExecutionImpl subProcessInstance = execution.getSubProcessInstance();
+    if (subProcessInstance!=null) {
+      subProcessInstance.setSuperProcessExecution(null);
+      execution.setSubProcessInstance(null);
+      deleteProcessInstance(subProcessInstance.getId(), deleteHistory);
+    }
+    Collection<ExecutionImpl> childExecutions = execution.getExecutions();
+    if (childExecutions!=null) {
+      for (ExecutionImpl childExecution: childExecutions) {
+        deleteSubProcesses(childExecution, deleteHistory);
+      }
+    }
+  }
+
   public HistoryProcessInstanceImpl findHistoryProcessInstanceById(String processInstanceId) {
     return (HistoryProcessInstanceImpl) session
       .createQuery(

Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessDeleteTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessDeleteTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessDeleteTest.java	2009-11-28 08:04:18 UTC (rev 5898)
@@ -0,0 +1,61 @@
+/*
+ * 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.activity.subprocess;
+
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SubProcessDeleteTest extends JbpmTestCase {
+
+  public void testSubProcessDelete() {
+    deployJpdlXmlString(
+      "<process name='MainProcess'>" +
+      "  <start>" +
+      "    <transition to='review' />" +
+      "  </start>" +
+      "  <sub-process name='review' sub-process-key='SubProcessReview'>" +
+      "    <transition to='next step'/>" +
+      "  </sub-process>" +
+      "  <state name='next step'/>" +
+      "</process>"
+    );
+      
+    deployJpdlXmlString(
+      "<process name='SubProcessReview'>" +
+      "  <start>" +
+      "    <transition to='get approval'/>" +
+      "  </start>" +
+      "  <state name='get approval'>" +
+      "    <transition to='ok'/>" +
+      "  </state>" +
+      "  <end name='ok' />" +
+      "</process>"  
+    );
+    
+    String pid = executionService.startProcessInstanceByKey("MainProcess").getId();
+    
+    executionService.deleteProcessInstance(pid);
+  }
+}


Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessDeleteTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessTest.java (from rev 5893, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/subprocess/SubProcessTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/subprocess/SubProcessTest.java	2009-11-28 08:04:18 UTC (rev 5898)
@@ -0,0 +1,119 @@
+/*
+ * 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.activity.subprocess;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * Test case for different usages of the subprocess activity.
+ * 
+ * @author Joram Barrez
+ */
+public class SubProcessTest extends JbpmTestCase {
+  
+  private static final String MAIN_PROCESS =
+    "<process name='mainProcess'>" +
+    "  <start>" +
+    "    <transition to='review' />" +
+    "  </start>" +
+    "  <sub-process name='review' sub-process-key='SubProcessReview'>" +
+    "    <transition name='ok' to='next step'/>" +
+    "    <transition name='nok' to='update'/>" +
+    "    <transition name='reject' to='close'/>" +
+    "  </sub-process>" +
+    "  <state name='next step'/>" +
+    "  <state name='update'/>" +
+    "  <end name='close'/>" +
+    "</process>";  
+    
+  private static final String SUB_PROCESS =
+    "<process name='SubProcessReview'>" +
+    "  <start>" +
+    "    <transition to='get approval'/>" +
+    "  </start>" +
+    "  <task name='get approval' assignee='johndoe'>" +
+    "    <transition name='ok' to='ok'/>" +
+    "    <transition name='nok' to='nok'/>" +
+    "    <transition name='reject' to='reject'/>" +
+    "  </task>" +
+    "  <end name='ok' />" +
+    "  <end name='nok' />" +
+    "  <end name='reject' />" +
+    "</process>";  
+  
+  private static final String MAIN_PROCESS_NO_WAIT_STATE =
+    "<process name='mainProcess'>" +
+    "  <start>" +
+    "    <transition to='review' />" +
+    "  </start>" +
+    "  <sub-process name='review' sub-process-key='SubProcessReview'>" +
+    "    <transition to='theMainEnd'/>" +
+    "  </sub-process>" +
+    "  <end name='theMainEnd'/>" +
+    "</process>";  
+  
+  private static final String SUB_PROCESS_NO_WAIT_STATE =
+    "<process name='SubProcessReview'>" +
+    "  <start>" +
+    "    <transition to='theEnd'/>" +
+    "  </start>" +
+    "  <end name='theEnd' />" +
+    "</process>";  
+  
+  public void testSubProcessOutcomeToState() {
+    deployJpdlXmlString(SUB_PROCESS);
+    deployJpdlXmlString(MAIN_PROCESS);
+    
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess");
+    Task task = taskService.findPersonalTasks("johndoe").get(0);
+    taskService.completeTask(task.getId(), "nok");
+    assertActivityActive(processInstance.getId(), "update");
+  }
+
+  
+  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); 
+  }
+  
+  
+  // Test for JBPM-2651
+  public void testSubProcessNoWaitStates() {
+    deployJpdlXmlString(SUB_PROCESS_NO_WAIT_STATE);
+    deployJpdlXmlString(MAIN_PROCESS_NO_WAIT_STATE);
+    
+    // uncomment to make the test fail
+    //executionService.startProcessInstanceByKey("mainProcess");
+  }
+  
+}

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/StartExecutionTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/StartExecutionTest.java	2009-11-28 03:00:30 UTC (rev 5897)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/execution/StartExecutionTest.java	2009-11-28 08:04:18 UTC (rev 5898)
@@ -27,7 +27,7 @@
 import java.util.Set;
 
 import org.jbpm.api.Execution;
-import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.JbpmException;
 import org.jbpm.api.ProcessInstance;
 import org.jbpm.test.JbpmTestCase;
 
@@ -37,6 +37,24 @@
  */
 public class StartExecutionTest extends JbpmTestCase {
 
+  public void testNonExistentProcessKey() {
+    try {
+      executionService.startProcessInstanceByKey("MeaningOfLife");
+      fail("expected exception");
+    } catch (JbpmException e) {
+      assertTextPresent("no process definition with key 'MeaningOfLife'", e.getMessage());
+    }
+  }
+
+  public void testNonExistentProcessId() {
+    try {
+      executionService.startProcessInstanceById("MeaningOfLife");
+      fail("expected exception");
+    } catch (JbpmException e) {
+      assertTextPresent("no process definition with id 'MeaningOfLife'", e.getMessage());
+    }
+  }
+
   public void testStartNewExecutionByKey() {
     deployJpdlXmlString(
       "<process name='Insurance claim' key='ICL'>" +

Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/subprocess/SubProcessTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/subprocess/SubProcessTest.java	2009-11-28 03:00:30 UTC (rev 5897)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/subprocess/SubProcessTest.java	2009-11-28 08:04:18 UTC (rev 5898)
@@ -1,119 +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.test.subprocess;
-
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.api.task.Task;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * Test case for different usages of the subprocess activity.
- * 
- * @author Joram Barrez
- */
-public class SubProcessTest extends JbpmTestCase {
-  
-  private static final String MAIN_PROCESS =
-    "<process name='mainProcess'>" +
-    "  <start>" +
-    "    <transition to='review' />" +
-    "  </start>" +
-    "  <sub-process name='review' sub-process-key='SubProcessReview'>" +
-    "    <transition name='ok' to='next step'/>" +
-    "    <transition name='nok' to='update'/>" +
-    "    <transition name='reject' to='close'/>" +
-    "  </sub-process>" +
-    "  <state name='next step'/>" +
-    "  <state name='update'/>" +
-    "  <end name='close'/>" +
-    "</process>";  
-    
-  private static final String SUB_PROCESS =
-    "<process name='SubProcessReview'>" +
-    "  <start>" +
-    "    <transition to='get approval'/>" +
-    "  </start>" +
-    "  <task name='get approval' assignee='johndoe'>" +
-    "    <transition name='ok' to='ok'/>" +
-    "    <transition name='nok' to='nok'/>" +
-    "    <transition name='reject' to='reject'/>" +
-    "  </task>" +
-    "  <end name='ok' />" +
-    "  <end name='nok' />" +
-    "  <end name='reject' />" +
-    "</process>";  
-  
-  private static final String MAIN_PROCESS_NO_WAIT_STATE =
-    "<process name='mainProcess'>" +
-    "  <start>" +
-    "    <transition to='review' />" +
-    "  </start>" +
-    "  <sub-process name='review' sub-process-key='SubProcessReview'>" +
-    "    <transition to='theMainEnd'/>" +
-    "  </sub-process>" +
-    "  <end name='theMainEnd'/>" +
-    "</process>";  
-  
-  private static final String SUB_PROCESS_NO_WAIT_STATE =
-    "<process name='SubProcessReview'>" +
-    "  <start>" +
-    "    <transition to='theEnd'/>" +
-    "  </start>" +
-    "  <end name='theEnd' />" +
-    "</process>";  
-  
-  public void testSubProcessOutcomeToState() {
-    deployJpdlXmlString(SUB_PROCESS);
-    deployJpdlXmlString(MAIN_PROCESS);
-    
-    ProcessInstance processInstance = executionService.startProcessInstanceByKey("mainProcess");
-    Task task = taskService.findPersonalTasks("johndoe").get(0);
-    taskService.completeTask(task.getId(), "nok");
-    assertActivityActive(processInstance.getId(), "update");
-  }
-
-  
-  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); 
-  }
-  
-  
-  // Test for JBPM-2651
-  public void testSubProcessNoWaitStates() {
-    deployJpdlXmlString(SUB_PROCESS_NO_WAIT_STATE);
-    deployJpdlXmlString(MAIN_PROCESS_NO_WAIT_STATE);
-    
-    // uncomment to make the test fail
-    //executionService.startProcessInstanceByKey("mainProcess");
-  }
-  
-}



More information about the jbpm-commits mailing list