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

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Jun 19 05:20:36 EDT 2010


Author: alex.guizar at jboss.com
Date: 2010-06-19 05:20:36 -0400 (Sat, 19 Jun 2010)
New Revision: 6426

Modified:
   jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.hibernate.cfg.xml
   jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml
   jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/mysql.hibernate.cfg.xml
   jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/oracle.hibernate.cfg.xml
   jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/postgresql.hibernate.cfg.xml
   jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/sybase.hibernate.cfg.xml
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
   jbpm4/trunk/modules/test-db/pom.xml
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/AssignmentHandlerTest.java
Log:
JBPM-2758: remove extraneous buildProcessEngine call in AssignmentHandlerTest which caused failure in jbpm4-spring job
trim spring hibernate configuration files

Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.hibernate.cfg.xml	2010-06-19 07:26:54 UTC (rev 6425)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.hibernate.cfg.xml	2010-06-19 09:20:36 UTC (rev 6426)
@@ -1,22 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <!DOCTYPE hibernate-configuration PUBLIC
-          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
-          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 
 <hibernate-configuration>
-	<session-factory>
-
-		<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+  <session-factory>
+    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
     <property name="hibernate.format_sql">true</property>
-    <property name="current_session_context_class">thread</property>
-    <!-- property name="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property -->
 
-		<mapping resource="jbpm.repository.hbm.xml" />
-		<mapping resource="jbpm.execution.hbm.xml" />
-		<mapping resource="jbpm.history.hbm.xml" />
-		<mapping resource="jbpm.task.hbm.xml" />
-		<mapping resource="jbpm.identity.hbm.xml" />
-
-	</session-factory>
+    <mapping resource="jbpm.repository.hbm.xml" />
+    <mapping resource="jbpm.execution.hbm.xml" />
+    <mapping resource="jbpm.history.hbm.xml" />
+    <mapping resource="jbpm.task.hbm.xml" />
+    <mapping resource="jbpm.identity.hbm.xml" />
+  </session-factory>
 </hibernate-configuration>

Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml	2010-06-19 07:26:54 UTC (rev 6425)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml	2010-06-19 09:20:36 UTC (rev 6426)
@@ -1,25 +1,20 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <!DOCTYPE hibernate-configuration PUBLIC
-          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
-          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 
 <hibernate-configuration>
-	<session-factory>
-
-		<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
-    <property name="current_session_context_class">thread</property>
-    <!-- property name="hibernate.transaction.factory_class">org.jbpm.pvm.internal.tx.SpringTransactionFactory</property -->
-    <!-- property name="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property -->
+  <session-factory>
+    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
     <property name="hibernate.format_sql">true</property>
 
     <property name="hibernate.hbm2ddl.auto">create-drop</property>
 
-		<mapping resource="jbpm.repository.hbm.xml" />
-		<mapping resource="jbpm.execution.hbm.xml" />
-		<mapping resource="jbpm.history.hbm.xml" />
-		<mapping resource="jbpm.task.hbm.xml" />
-		<mapping resource="jbpm.identity.hbm.xml" />
-
-	</session-factory>
+    <mapping resource="jbpm.repository.hbm.xml" />
+    <mapping resource="jbpm.execution.hbm.xml" />
+    <mapping resource="jbpm.history.hbm.xml" />
+    <mapping resource="jbpm.task.hbm.xml" />
+    <mapping resource="jbpm.identity.hbm.xml" />
+  </session-factory>
 </hibernate-configuration>

Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/mysql.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/mysql.hibernate.cfg.xml	2010-06-19 07:26:54 UTC (rev 6425)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/mysql.hibernate.cfg.xml	2010-06-19 09:20:36 UTC (rev 6426)
@@ -1,22 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <!DOCTYPE hibernate-configuration PUBLIC
-          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
-          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 
 <hibernate-configuration>
-	<session-factory>
-
-		<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
-    <property name="current_session_context_class">thread</property>
-    <!-- property name="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property -->
+  <session-factory>
+    <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
     <property name="hibernate.format_sql">true</property>
 
-		<mapping resource="jbpm.repository.hbm.xml" />
-		<mapping resource="jbpm.execution.hbm.xml" />
-		<mapping resource="jbpm.history.hbm.xml" />
-		<mapping resource="jbpm.task.hbm.xml" />
-		<mapping resource="jbpm.identity.hbm.xml" />
-
-	</session-factory>
+    <mapping resource="jbpm.repository.hbm.xml" />
+    <mapping resource="jbpm.execution.hbm.xml" />
+    <mapping resource="jbpm.history.hbm.xml" />
+    <mapping resource="jbpm.task.hbm.xml" />
+    <mapping resource="jbpm.identity.hbm.xml" />
+  </session-factory>
 </hibernate-configuration>

Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/oracle.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/oracle.hibernate.cfg.xml	2010-06-19 07:26:54 UTC (rev 6425)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/oracle.hibernate.cfg.xml	2010-06-19 09:20:36 UTC (rev 6426)
@@ -1,15 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <!DOCTYPE hibernate-configuration PUBLIC
-          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
-          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 
 <hibernate-configuration>
-	<session-factory>
-
+  <session-factory>
     <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
-    <property name="current_session_context_class">thread</property>
-    <!-- property name="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property -->
     <property name="hibernate.format_sql">true</property>
 
     <mapping resource="jbpm.repository.hbm.xml" />
@@ -17,6 +14,5 @@
     <mapping resource="jbpm.history.hbm.xml" />
     <mapping resource="jbpm.task.hbm.xml" />
     <mapping resource="jbpm.identity.hbm.xml" />
-
-	</session-factory>
+  </session-factory>
 </hibernate-configuration>

Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/postgresql.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/postgresql.hibernate.cfg.xml	2010-06-19 07:26:54 UTC (rev 6425)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/postgresql.hibernate.cfg.xml	2010-06-19 09:20:36 UTC (rev 6426)
@@ -1,22 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <!DOCTYPE hibernate-configuration PUBLIC
-          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
-          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 
 <hibernate-configuration>
-	<session-factory>
-
-		<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
-    <property name="current_session_context_class">thread</property>
-    <!-- property name="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property -->
+  <session-factory>
+    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
     <property name="hibernate.format_sql">true</property>
 
-		<mapping resource="jbpm.repository.hbm.xml" />
-		<mapping resource="jbpm.execution.hbm.xml" />
-		<mapping resource="jbpm.history.hbm.xml" />
-		<mapping resource="jbpm.task.hbm.xml" />
-		<mapping resource="jbpm.identity.hbm.xml" />
-
-	</session-factory>
+    <mapping resource="jbpm.repository.hbm.xml" />
+    <mapping resource="jbpm.execution.hbm.xml" />
+    <mapping resource="jbpm.history.hbm.xml" />
+    <mapping resource="jbpm.task.hbm.xml" />
+    <mapping resource="jbpm.identity.hbm.xml" />
+  </session-factory>
 </hibernate-configuration>

Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/sybase.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/sybase.hibernate.cfg.xml	2010-06-19 07:26:54 UTC (rev 6425)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/sybase.hibernate.cfg.xml	2010-06-19 09:20:36 UTC (rev 6426)
@@ -1,22 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>
 
 <!DOCTYPE hibernate-configuration PUBLIC
-          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
-          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
 
 <hibernate-configuration>
-	<session-factory>
-
-		<property name="hibernate.dialect">org.hibernate.dialect.SybaseDialect</property>
-    <property name="current_session_context_class">thread</property>
-    <!-- property name="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property -->
+  <session-factory>
+    <property name="hibernate.dialect">org.hibernate.dialect.SybaseDialect</property>
     <property name="hibernate.format_sql">true</property>
 
-		<mapping resource="jbpm.repository.hbm.xml" />
-		<mapping resource="jbpm.execution.hbm.xml" />
-		<mapping resource="jbpm.history.hbm.xml" />
-		<mapping resource="jbpm.task.hbm.xml" />
-		<mapping resource="jbpm.identity.hbm.xml" />
-
-	</session-factory>
+    <mapping resource="jbpm.repository.hbm.xml" />
+    <mapping resource="jbpm.execution.hbm.xml" />
+    <mapping resource="jbpm.history.hbm.xml" />
+    <mapping resource="jbpm.task.hbm.xml" />
+    <mapping resource="jbpm.identity.hbm.xml" />
+  </session-factory>
 </hibernate-configuration>

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java	2010-06-19 07:26:54 UTC (rev 6425)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/PropertyImpl.java	2010-06-19 09:20:36 UTC (rev 6426)
@@ -25,7 +25,7 @@
 import java.util.List;
 
 import org.hibernate.Session;
-import org.hibernate.criterion.Restrictions;
+
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.history.model.HistoryActivityInstanceImpl;
 import org.jbpm.pvm.internal.history.model.HistoryDetailImpl;
@@ -45,7 +45,6 @@
 import org.jbpm.pvm.internal.task.TaskImpl;
 import org.jbpm.pvm.internal.type.Variable;
 
-
 /** jbpm installation properties.
  * 
  * currently there are 2 use cases for these properties:
@@ -181,9 +180,7 @@
   }
 
   protected static PropertyImpl getProperty(Session session, String key) {
-    return (PropertyImpl) session.createCriteria(PropertyImpl.class)
-        .add(Restrictions.eq("key", key))
-        .uniqueResult();
+    return (PropertyImpl) session.get(PropertyImpl.class, key);
   }
 
   public static void setDbVersionTo41(Session session) {

Modified: jbpm4/trunk/modules/test-db/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-db/pom.xml	2010-06-19 07:26:54 UTC (rev 6425)
+++ jbpm4/trunk/modules/test-db/pom.xml	2010-06-19 09:20:36 UTC (rev 6426)
@@ -195,7 +195,6 @@
             <artifactId>maven-surefire-plugin</artifactId>
             <configuration>
               <failIfNoTests>false</failIfNoTests>
-              <trimStackTrace>false</trimStackTrace>
               <redirectTestOutputToFile>true</redirectTestOutputToFile>
               <excludes>
                 <exclude>org/jbpm/test/reporting/SQLStmtTest.java</exclude>

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/AssignmentHandlerTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/AssignmentHandlerTest.java	2010-06-19 07:26:54 UTC (rev 6425)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/AssignmentHandlerTest.java	2010-06-19 09:20:36 UTC (rev 6426)
@@ -1,163 +1,111 @@
 package org.jbpm.test.task;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
-import org.jbpm.api.Configuration;
-import org.jbpm.api.ProcessEngine;
 import org.jbpm.api.ProcessInstance;
-import org.jbpm.api.TaskService;
 import org.jbpm.api.model.OpenExecution;
 import org.jbpm.api.task.Assignable;
 import org.jbpm.api.task.AssignmentHandler;
 import org.jbpm.api.task.Participation;
 import org.jbpm.api.task.Task;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
 import org.jbpm.test.JbpmTestCase;
 
 public class AssignmentHandlerTest extends JbpmTestCase {
 
-    /** Deployment id. */
-    String deploymentId;
+  String deploymentId;
 
-    /**
-     * Set up.
-     * @throws Exception exception
-     */
-    protected void setUp() throws Exception {
-        super.setUp();
+  protected void setUp() throws Exception {
+    super.setUp();
 
-        // XML definition
-        StringBuilder jpdl = new StringBuilder();
-        jpdl.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-        jpdl.append("<process key=\"testProcess\" name=\"Test Process\" xmlns=\"http://jbpm.org/4.3/jpdl\">");
-        jpdl.append("  <start g=\"67,236,48,48\" name=\"start1\">");
-        jpdl.append("    <transition g=\"-43,-18\" name=\"to fork1\" to=\"fork1\"/>");
-        jpdl.append("  </start>");
-        jpdl.append("  <task g=\"255,144,92,52\" name=\"task1\" candidate-groups=\"firstGroup\">");
-        jpdl.append("    <assignment-handler class=\"org.jbpm.test.task.AssignmentHandlerTest$AutoAssignment\"/>");
-        jpdl.append("    <transition g=\"-41,-18\" name=\"to join1\" to=\"join1\"/>");
-        jpdl.append("  </task>");
-        jpdl.append("  <task g=\"258,334,92,52\" name=\"task2\" candidate-groups=\"secondGroup\">");
-        jpdl.append("    <assignment-handler class=\"org.jbpm.test.task.AssignmentHandlerTest$AutoAssignment\"/>");
-        jpdl.append("    <transition g=\"-41,-18\" name=\"to join1\" to=\"join1\"/>");
-        jpdl.append("  </task>");
-        jpdl.append("  <task g=\"515,228,92,52\" name=\"task3\" candidate-groups=\"thirdGroup\">");
-        jpdl.append("    <assignment-handler class=\"org.jbpm.test.task.AssignmentHandlerTest$AutoAssignment\"/>");
-        jpdl.append("    <transition g=\"-42,-18\" name=\"to end1\" to=\"end1\"/>");
-        jpdl.append("  </task>");
-        jpdl.append("  <end g=\"676,232,48,48\" name=\"end1\"/>");
-        jpdl.append("  <fork g=\"172,236,48,48\" name=\"fork1\">");
-        jpdl.append("    <transition g=\"-44,-18\" name=\"to task1\" to=\"task1\"/>");
-        jpdl.append("    <transition g=\"-44,-18\" name=\"to task2\" to=\"task2\"/>");
-        jpdl.append("  </fork>");
-        jpdl.append("  <join g=\"385,233,48,48\" name=\"join1\">");
-        jpdl.append("    <transition g=\"-44,-18\" name=\"to task3\" to=\"task3\"/>");
-        jpdl.append("  </join>");
-        jpdl.append("</process>");
+    // XML definition
+    String jpdl = "<?xml version=\"1.0\"?>"
+      + "<process key=\"testProcess\" name=\"Test Process\" xmlns=\"http://jbpm.org/4.3/jpdl\">"
+      + "  <start g=\"67,236,48,48\" name=\"start1\">"
+      + "    <transition g=\"-43,-18\" name=\"to fork1\" to=\"fork1\"/>" + "  </start>"
+      + "  <task g=\"255,144,92,52\" name=\"task1\" candidate-groups=\"firstGroup\">"
+      + "    <assignment-handler class=\""
+      + AutoAssignment.class.getName()
+      + "\"/>"
+      + "    <transition g=\"-41,-18\" name=\"to join1\" to=\"join1\"/>"
+      + "  </task>"
+      + "  <task g=\"258,334,92,52\" name=\"task2\" candidate-groups=\"secondGroup\">"
+      + "    <assignment-handler class=\""
+      + AutoAssignment.class.getName()
+      + "\"/>"
+      + "    <transition g=\"-41,-18\" name=\"to join1\" to=\"join1\"/>"
+      + "  </task>"
+      + "  <task g=\"515,228,92,52\" name=\"task3\" candidate-groups=\"thirdGroup\">"
+      + "    <assignment-handler class=\""
+      + AutoAssignment.class.getName()
+      + "\"/>"
+      + "    <transition g=\"-42,-18\" name=\"to end1\" to=\"end1\"/>"
+      + "  </task>"
+      + "  <end g=\"676,232,48,48\" name=\"end1\"/>"
+      + "  <fork g=\"172,236,48,48\" name=\"fork1\">"
+      + "    <transition g=\"-44,-18\" name=\"to task1\" to=\"task1\"/>"
+      + "    <transition g=\"-44,-18\" name=\"to task2\" to=\"task2\"/>"
+      + "  </fork>"
+      + "  <join g=\"385,233,48,48\" name=\"join1\">"
+      + "    <transition g=\"-44,-18\" name=\"to task3\" to=\"task3\"/>"
+      + "  </join>"
+      + "</process>";
 
-        // Deploys the process
-        deploymentId = repositoryService.createDeployment()
-                                        .addResourceFromString("testProcess.jpdl.xml", jpdl.toString())
-                                        .deploy();
-    }
+    // Deploys the process
+    deploymentId = repositoryService.createDeployment()
+      .addResourceFromString("testProcess.jpdl.xml", jpdl.toString())
+      .deploy();
+  }
 
-    /**
-     * Tear down.
-     * @throws Exception exception
-     */
-    protected void tearDown() throws Exception {
-        repositoryService.deleteDeploymentCascade(deploymentId);
-        super.tearDown();
-    }
+  protected void tearDown() throws Exception {
+    repositoryService.deleteDeploymentCascade(deploymentId);
+    super.tearDown();
+  }
 
-    /**
-     * Tests the process.
-     */
-    public void testProcess() {
+  /** Tests the process. */
+  public void testProcess() {
+    // Starts a new process instance and gets the instance id
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("testProcess");
+    String pid = processInstance.getId();
 
-        // Starts a new process instance and gets the instance id
-        ProcessInstance processInstance = executionService.startProcessInstanceByKey("testProcess");
-        String pid = processInstance.getId();
+    // Gets the tasks auto-assigned for the first user and completes the task
+    List<Task> taskList = taskService.findPersonalTasks("firstUser");
+    assertEquals(1, taskList.size());
+    Task task = taskList.get(0);
+    taskService.completeTask(task.getId());
 
-        // Gets the tasks auto-assigned for the first user and completes the task
-        List <Task> taskList = taskService.findPersonalTasks("firstUser");
-        assertEquals(1, taskList.size());
-        Task task = taskList.get(0);
-        taskService.completeTask(task.getId());
+    // Gets the tasks auto-assigned for the second user and completes the task
+    taskList = taskService.findPersonalTasks("secondUser");
+    assertEquals(1, taskList.size());
+    task = taskList.get(0);
+    taskService.completeTask(task.getId());
 
-        // Gets the tasks auto-assigned for the second user and completes the task
-        taskList = taskService.findPersonalTasks("secondUser");
-        assertEquals(1, taskList.size());
-        task = taskList.get(0);
-        taskService.completeTask(task.getId());
+    // Gets the tasks auto-assigned for the second user and completes the task
+    taskList = taskService.findPersonalTasks("thirdUser");
+    assertEquals(1, taskList.size());
+    task = taskList.get(0);
+    taskService.completeTask(task.getId());
 
-        // Gets the tasks auto-assigned for the second user and completes the task
-        taskList = taskService.findPersonalTasks("thirdUser");
-        assertEquals(1, taskList.size());
-        task = taskList.get(0);
-        taskService.completeTask(task.getId());
+    // Tries to load the instance and checks if it was finished
+    processInstance = executionService.findProcessInstanceById(pid);
+    assertNull(processInstance);
+  }
 
-        // Tries to load the instance and checks if it was finished
-        processInstance = executionService.findProcessInstanceById(pid);
-        assertNull(processInstance);
-    }
+  /** Auto assignment class. */
+  public static class AutoAssignment implements AssignmentHandler {
 
-    /**
-     * Auto assignment class.
-     */
-    public static class AutoAssignment implements AssignmentHandler {
+    private static final long serialVersionUID = 9063679883107908899L;
 
-        /** Serial version ID. */
-        private static final long serialVersionUID = 9063679883107908899L;
+    /** Auto-claim the task to the default user. */
+    public void assign(Assignable assignable, OpenExecution execution) throws Exception {
+      // retrieve the participations
+      Task task = (Task) assignable;
+      List<Participation> participations = taskService.getTaskParticipations(task.getId());
 
-        /**
-         * Auto-claim the task to the default user.
-         * @param assignable assignable object
-         * @param execution execution object
-         * @throws Exception exception
-         */
-        public void assign(Assignable assignable, OpenExecution execution) throws Exception {
-
-            // Default users (group --> user mapping)
-            Map <String, String> defaultUsers = new HashMap <String, String>();
-            defaultUsers.put("firstGroup", "firstUser");
-            defaultUsers.put("secondGroup", "secondUser");
-            defaultUsers.put("thirdGroup", "thirdUser");
-
-            // Engine and task service
-            TaskService taskService = EnvironmentImpl.getFromCurrent(TaskService.class);
-
-            // Loads the active activities
-            Set <String> activities = execution.findActiveActivityNames();
-
-            // Iterates the activities
-            for (String activity : activities) {
-
-                // Loads the tasks according to the process instance and activity name
-                List <Task> tasks =
-                        taskService.createTaskQuery().activityName(activity).processInstanceId(
-                            execution.getProcessInstance().getId()).list();
-
-                // Iterates the tasks
-                for (Task task : tasks) {
-
-                    // Compares the task name to the activity name
-                    // If the task name matches the activity name, loads the candidate-group and assigns the default user
-                    if (task.getName().equals(activity)) {
-
-                        // Loads the tasks candidate groups (in our process we have just one group)
-                        List <Participation> groups = taskService.getTaskParticipations(task.getId());
-
-                        // If the groups collection is not empty, loads the default user and sets in the task
-                        if (!groups.isEmpty()) {
-                            assignable.setAssignee(defaultUsers.get(groups.get(0).getGroupId()));
-                        }
-                    }
-                }
-            }
-        }
+      // If the participations list is not empty, assign task to default user
+      if (!participations.isEmpty()) {
+        String groupId = participations.get(0).getGroupId();
+        assignable.setAssignee(groupId.substring(0, groupId.indexOf("Group")) + "User");
+      }
     }
+  }
 }



More information about the jbpm-commits mailing list