[jbpm-commits] JBoss JBPM SVN: r3690 - in jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt: exe and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Jan 20 19:32:02 EST 2009


Author: alex.guizar at jboss.com
Date: 2009-01-20 19:32:02 -0500 (Tue, 20 Jan 2009)
New Revision: 3690

Modified:
   jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/def/Swimlane.java
   jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java
   jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/Assignable.java
   jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java
   jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java
   jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java
Log:
JBPM-1975 generalize task management package

Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/def/Swimlane.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/def/Swimlane.java	2009-01-21 00:28:18 UTC (rev 3689)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/def/Swimlane.java	2009-01-21 00:32:02 UTC (rev 3690)
@@ -40,7 +40,7 @@
   protected String pooledActorsExpression = null;
   protected Delegation assignmentDelegation = null;
   protected TaskMgmtDefinition taskMgmtDefinition = null;
-  protected Set tasks = null;
+  protected Set<Task> tasks = null;
   
   public Swimlane() {
   }
@@ -60,12 +60,12 @@
   // tasks ////////////////////////////////////////////////////////////////////
 
   public void addTask( Task task ) {
-    if (tasks==null) tasks = new HashSet();
+    if (tasks==null) tasks = new HashSet<Task>();
     tasks.add(task);
     task.setSwimlane(this);
   }
 
-  public Set getTasks() {
+  public Set<Task> getTasks() {
     return tasks;
   }
 

Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java	2009-01-21 00:28:18 UTC (rev 3689)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java	2009-01-21 00:32:02 UTC (rev 3690)
@@ -22,7 +22,6 @@
 package org.jbpm.taskmgmt.def;
 
 import java.io.Serializable;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
@@ -33,10 +32,8 @@
 import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.graph.exe.Token;
 import org.jbpm.instantiation.Delegation;
-import org.jbpm.instantiation.ProcessClassLoaderFactory;
 import org.jbpm.instantiation.UserCodeInterceptorConfig;
 import org.jbpm.taskmgmt.exe.TaskInstance;
-import org.jbpm.util.ClassLoaderUtil;
 import org.jbpm.util.EqualsUtil;
 
 /**
@@ -62,7 +59,7 @@
   /**
    * maps process variable names (java.lang.String) to VariableAccess objects.
    */
-  List variableAccesses = null;
+  List<VariableAccess> variableAccesses = null;
   
   public TaskController() {
   }
@@ -96,9 +93,7 @@
         ContextInstance contextInstance = processInstance.getContextInstance();
 
         if (variableAccesses != null) {
-          Iterator iter = variableAccesses.iterator();
-          while (iter.hasNext()) {
-            VariableAccess variableAccess = (VariableAccess) iter.next();
+          for (VariableAccess variableAccess : variableAccesses) {
             String mappedName = variableAccess.getMappedName();
             if (variableAccess.isReadable()) {
               String variableName = variableAccess.getVariableName();
@@ -146,9 +141,7 @@
 
         if (variableAccesses != null) {
           String missingTaskVariables = null;
-          Iterator iter = variableAccesses.iterator();
-          while (iter.hasNext()) {
-            VariableAccess variableAccess = (VariableAccess) iter.next();
+          for (VariableAccess variableAccess : variableAccesses) {
             String mappedName = variableAccess.getMappedName();
             // first check if the required variableInstances are present
             if ((variableAccess.isRequired()) && (!taskInstance.hasVariableLocally(mappedName))) {
@@ -166,9 +159,7 @@
             throw new IllegalArgumentException("missing task variables: " + missingTaskVariables);
           }
 
-          iter = variableAccesses.iterator();
-          while (iter.hasNext()) {
-            VariableAccess variableAccess = (VariableAccess) iter.next();
+          for (VariableAccess variableAccess : variableAccesses) {
             String mappedName = variableAccess.getMappedName();
             String variableName = variableAccess.getVariableName();
             if (variableAccess.isWritable()) {
@@ -195,7 +186,7 @@
   
   // getters and setters //////////////////////////////////////////////////////
 
-  public List getVariableAccesses() {
+  public List<VariableAccess> getVariableAccesses() {
     return variableAccesses;
   }
   public Delegation getTaskControllerDelegation() {
@@ -208,7 +199,7 @@
     return id;
   }
 
-  public void setVariableAccesses(List variableAccesses) {
+  public void setVariableAccesses(List<VariableAccess> variableAccesses) {
     this.variableAccesses = variableAccesses;
   }
   

Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/Assignable.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/Assignable.java	2009-01-21 00:28:18 UTC (rev 3689)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/Assignable.java	2009-01-21 00:32:02 UTC (rev 3690)
@@ -42,5 +42,5 @@
    * Use this method to offer the task to a group of users.  Each user in the group
    * can then take the task by calling the {@link #setActorId(String)}.
    */
-  public void setPooledActors(String[] pooledActors);
+  public void setPooledActors(String... pooledActors);
 }

Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java	2009-01-21 00:28:18 UTC (rev 3689)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/PooledActor.java	2009-01-21 00:32:02 UTC (rev 3690)
@@ -23,7 +23,6 @@
 
 import java.io.Serializable;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
 import org.jbpm.util.EqualsUtil;
@@ -35,7 +34,7 @@
   long id = 0;
   int version = 0;
   protected String actorId = null;
-  protected Set taskInstances = null;
+  protected Set<TaskInstance> taskInstances = null;
   protected SwimlaneInstance swimlaneInstance = null;
 
   public static Set<PooledActor> createPool(String[] actorIds, SwimlaneInstance swimlaneInstance, TaskInstance taskInstance) {
@@ -53,13 +52,11 @@
     return pooledActors;
   }
   
-  public static Set extractActorIds(Set poooledActors) {
-    Set extractedActorIds = null;
-    if (poooledActors!=null) {
-      extractedActorIds = new HashSet();
-      Iterator iter = poooledActors.iterator();
-      while (iter.hasNext()) {
-        PooledActor pooledActor = (PooledActor) iter.next();
+  public static Set<String> extractActorIds(Set<PooledActor> pooledActors) {
+    Set<String> extractedActorIds = null;
+    if (pooledActors!=null) {
+      extractedActorIds = new HashSet<String>();
+      for (PooledActor pooledActor : pooledActors) {
         extractedActorIds.add(pooledActor.getActorId());
       }
     }
@@ -74,10 +71,10 @@
   }
   
   public void addTaskInstance(TaskInstance taskInstance) {
-    if (taskInstances==null) taskInstances = new HashSet();
+    if (taskInstances==null) taskInstances = new HashSet<TaskInstance>();
     taskInstances.add(taskInstance);
   }
-  public Set getTaskInstances() {
+  public Set<TaskInstance> getTaskInstances() {
     return taskInstances;
   }
   public void removeTaskInstance(TaskInstance taskInstance) {

Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java	2009-01-21 00:28:18 UTC (rev 3689)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/SwimlaneInstance.java	2009-01-21 00:32:02 UTC (rev 3690)
@@ -21,10 +21,10 @@
  */
 package org.jbpm.taskmgmt.exe;
 
-import java.io.*;
+import java.io.Serializable;
 import java.util.Set;
 
-import org.jbpm.taskmgmt.def.*;
+import org.jbpm.taskmgmt.def.Swimlane;
 import org.jbpm.util.EqualsUtil;
 
 /**
@@ -50,7 +50,7 @@
     this.swimlane = swimlane;
   }
 
-  public void setPooledActors(String[] actorIds) {
+  public void setPooledActors(String... actorIds) {
     this.pooledActors = PooledActor.createPool(actorIds, this, null);
   }
 

Modified: jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java
===================================================================
--- jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java	2009-01-21 00:28:18 UTC (rev 3689)
+++ jbpm3/branches/aguizar/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskInstance.java	2009-01-21 00:32:02 UTC (rev 3690)
@@ -24,7 +24,6 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
@@ -52,11 +51,10 @@
 import org.jbpm.util.EqualsUtil;
 
 /**
- * is one task instance that can be assigned to an actor (read: put in someones task list) and that can trigger the
- * coninuation of execution of the token upon completion.
+ * is one task instance that can be assigned to an actor (read: put in someones task list) and that
+ * can trigger the coninuation of execution of the token upon completion.
  */
-public class TaskInstance extends VariableContainer implements Identifiable, Assignable
-{
+public class TaskInstance extends VariableContainer implements Identifiable, Assignable {
 
   private static final long serialVersionUID = 1L;
 
@@ -81,27 +79,24 @@
   protected TaskMgmtInstance taskMgmtInstance = null;
   protected ProcessInstance processInstance = null;
   protected Set<PooledActor> pooledActors = null;
-  protected List comments = null;
+  protected List<Comment> comments = null;
 
-  protected String previousActorId = null; // not persisted. just extra information for listeners of the assign-event
+  protected String previousActorId = null; // not persisted. just extra information for listeners of
+                                           // the assign-event
 
-  public TaskInstance()
-  {
+  public TaskInstance() {
   }
 
-  public TaskInstance(String taskName)
-  {
+  public TaskInstance(String taskName) {
     this.name = taskName;
   }
 
-  public TaskInstance(String taskName, String actorId)
-  {
+  public TaskInstance(String taskName, String actorId) {
     this.name = taskName;
     this.actorId = actorId;
   }
 
-  public void setTask(Task task)
-  {
+  public void setTask(Task task) {
     this.name = task.getName();
     this.description = task.getDescription();
     this.task = task;
@@ -110,60 +105,52 @@
     this.isSignalling = task.isSignalling();
   }
 
-  void submitVariables()
-  {
+  void submitVariables() {
     TaskController taskController = (task != null ? task.getTaskController() : null);
     // if there is a task controller,
-    if (taskController != null)
-    {
+    if (taskController != null) {
       // the task controller is responsible for copying variables back into the process
       taskController.submitParameters(this);
 
       // if there is no task controller
     }
-    else if ((token != null) && (token.getProcessInstance() != null))
-    {
+    else if ((token != null) && (token.getProcessInstance() != null)) {
       // the default behaviour is that all task-local variables are flushed to the process
-      if (variableInstances != null)
-      {
+      if (variableInstances != null) {
         ContextInstance contextInstance = token.getProcessInstance().getContextInstance();
-        Iterator iter = variableInstances.values().iterator();
-        while (iter.hasNext())
-        {
-          VariableInstance variableInstance = (VariableInstance)iter.next();
-          log.debug("flushing variable '" + variableInstance.getName() + "' from task '" + name + "' to process variables");
-          // This might be optimized, but this was the simplest way to make a clone of the variable instance.
+        for (VariableInstance variableInstance : variableInstances.values()) {
+          log.debug("flushing variable '"
+              + variableInstance.getName()
+              + "' from task '"
+              + name
+              + "' to process variables");
+          // This might be optimized, but this was the simplest way to make a clone of the variable
+          // instance.
           contextInstance.setVariable(variableInstance.getName(), variableInstance.getValue(), token);
         }
       }
     }
   }
 
-  void initializeVariables()
-  {
+  void initializeVariables() {
     TaskController taskController = (task != null ? task.getTaskController() : null);
-    if (taskController != null)
-    {
+    if (taskController != null) {
       taskController.initializeVariables(this);
     }
   }
 
-  public void create()
-  {
+  public void create() {
     create(null);
   }
 
-  public void create(ExecutionContext executionContext)
-  {
-    if (create != null)
-    {
+  public void create(ExecutionContext executionContext) {
+    if (create != null) {
       throw new IllegalStateException("task instance '" + id + "' was already created");
     }
     create = Clock.getCurrentTime();
 
     // if this task instance is associated with a task...
-    if ((task != null) && (executionContext != null))
-    {
+    if ((task != null) && (executionContext != null)) {
       // the TASK_CREATE event is fired
       executionContext.setTaskInstance(this);
       executionContext.setTask(task);
@@ -175,18 +162,15 @@
     // See also: TaskMgmtInstance.createTaskInstance
   }
 
-  public void assign(ExecutionContext executionContext)
-  {
+  public void assign(ExecutionContext executionContext) {
     TaskMgmtInstance taskMgmtInstance = executionContext.getTaskMgmtInstance();
 
     Swimlane swimlane = task.getSwimlane();
     // if this task is in a swimlane
-    if (swimlane != null)
-    {
+    if (swimlane != null) {
 
       // if this is a task assignment for a start-state
-      if (isStartTaskInstance())
-      {
+      if (isStartTaskInstance()) {
         // initialize the swimlane
         swimlaneInstance = new SwimlaneInstance(swimlane);
         taskMgmtInstance.addSwimlaneInstance(swimlaneInstance);
@@ -194,8 +178,7 @@
         swimlaneInstance.setActorId(SecurityHelper.getAuthenticatedActorId());
 
       }
-      else
-      {
+      else {
 
         // lazy initialize the swimlane...
         // get the swimlane instance (if there is any)
@@ -206,32 +189,25 @@
       }
 
     }
-    else
-    { // this task is not in a swimlane
+    else { // this task is not in a swimlane
       taskMgmtInstance.performAssignment(task.getAssignmentDelegation(), task.getActorIdExpression(), task.getPooledActorsExpression(), this, executionContext);
     }
 
     updatePooledActorsReferences(swimlaneInstance);
   }
 
-  public boolean isStartTaskInstance()
-  {
+  public boolean isStartTaskInstance() {
     boolean isStartTaskInstance = false;
-    if ((taskMgmtInstance != null) && (taskMgmtInstance.getTaskMgmtDefinition() != null))
-    {
-      isStartTaskInstance = ((task != null) && (task.equals(taskMgmtInstance.getTaskMgmtDefinition().getStartTask())));
+    if ((taskMgmtInstance != null) && (taskMgmtInstance.getTaskMgmtDefinition() != null)) {
+      isStartTaskInstance = ((task != null) && (task.equals(taskMgmtInstance.getTaskMgmtDefinition()
+          .getStartTask())));
     }
     return isStartTaskInstance;
   }
 
-  void updatePooledActorsReferences(SwimlaneInstance swimlaneInstance)
-  {
-    if (pooledActors != null)
-    {
-      Iterator iter = pooledActors.iterator();
-      while (iter.hasNext())
-      {
-        PooledActor pooledActor = (PooledActor)iter.next();
+  void updatePooledActorsReferences(SwimlaneInstance swimlaneInstance) {
+    if (pooledActors != null) {
+      for (PooledActor pooledActor : pooledActors) {
         pooledActor.setSwimlaneInstance(swimlaneInstance);
         pooledActor.addTaskInstance(this);
       }
@@ -239,35 +215,31 @@
   }
 
   /**
-   * copies the assignment (that includes both the swimlaneActorId and the set of pooledActors) of the given swimlane
-   * into this taskInstance.
+   * copies the assignment (that includes both the swimlaneActorId and the set of pooledActors) of
+   * the given swimlane into this taskInstance.
    */
-  public void copySwimlaneInstanceAssignment(SwimlaneInstance swimlaneInstance)
-  {
+  public void copySwimlaneInstanceAssignment(SwimlaneInstance swimlaneInstance) {
     setSwimlaneInstance(swimlaneInstance);
     setActorId(swimlaneInstance.getActorId());
     setPooledActors(swimlaneInstance.getPooledActors());
   }
 
   /**
-   * gets the pool of actors for this task instance. If this task has a simlaneInstance and no pooled actors, the pooled
-   * actors of the swimlane instance are returned.
+   * gets the pool of actors for this task instance. If this task has a simlaneInstance and no
+   * pooled actors, the pooled actors of the swimlane instance are returned.
    */
-  public Set<PooledActor> getPooledActors()
-  {
-    if ((swimlaneInstance != null) && ((pooledActors == null) || (pooledActors.isEmpty())))
-    {
+  public Set<PooledActor> getPooledActors() {
+    if ((swimlaneInstance != null) && ((pooledActors == null) || (pooledActors.isEmpty()))) {
       return swimlaneInstance.getPooledActors();
     }
     return pooledActors;
   }
 
   /**
-   * (re)assign this task to the given actor. If this task is related to a swimlane instance, that swimlane instance
-   * will be updated as well.
+   * (re)assign this task to the given actor. If this task is related to a swimlane instance, that
+   * swimlane instance will be updated as well.
    */
-  public void setActorId(String actorId)
-  {
+  public void setActorId(String actorId) {
     setActorId(actorId, true);
   }
 
@@ -275,22 +247,20 @@
    * (re)assign this task to the given actor.
    * 
    * @param actorId is reference to the person that is assigned to this task.
-   * @param overwriteSwimlane specifies if the related swimlane should be overwritten with the given swimlaneActorId.
+   * @param overwriteSwimlane specifies if the related swimlane should be overwritten with the given
+   * swimlaneActorId.
    */
-  public void setActorId(String actorId, boolean overwriteSwimlane)
-  {
+  public void setActorId(String actorId, boolean overwriteSwimlane) {
     // do the actual assignment
     this.previousActorId = this.actorId;
     this.actorId = actorId;
-    if ((swimlaneInstance != null) && (overwriteSwimlane))
-    {
+    if ((swimlaneInstance != null) && (overwriteSwimlane)) {
       log.debug("assigning task '" + name + "' to '" + actorId + "'");
       swimlaneInstance.setActorId(actorId);
     }
 
     // fire the event
-    if ((task != null) && (token != null))
-    {
+    if ((task != null) && (token != null)) {
       ExecutionContext executionContext = new ExecutionContext(token);
       executionContext.setTask(task);
       executionContext.setTaskInstance(this);
@@ -302,32 +272,27 @@
     }
 
     // add the log
-    if (token != null)
-    {
+    if (token != null) {
       // log this assignment
       token.addLog(new TaskAssignLog(this, previousActorId, actorId));
     }
   }
 
   /** takes a set of String's as the actorIds */
-  public void setPooledActors(String[] actorIds)
-  {
+  public void setPooledActors(String... actorIds) {
     this.pooledActors = PooledActor.createPool(actorIds, null, this);
   }
 
   /**
    * can optionally be used to indicate that the actor is starting to work on this task instance.
    */
-  public void start()
-  {
-    if (start != null)
-    {
+  public void start() {
+    if (start != null) {
       throw new IllegalStateException("task instance '" + id + "' is already started");
     }
 
     start = Clock.getCurrentTime();
-    if ((task != null) && (token != null))
-    {
+    if ((task != null) && (token != null)) {
       ExecutionContext executionContext = new ExecutionContext(token);
       executionContext.setTask(task);
       executionContext.setTaskInstance(this);
@@ -338,16 +303,14 @@
   /**
    * convenience method that combines a {@link #setActorId(String)} and a {@link #start()}.
    */
-  public void start(String actorId)
-  {
+  public void start(String actorId) {
     start(actorId, true);
   }
 
   /**
    * convenience method that combines a {@link #setActorId(String,boolean)} and a {@link #start()}.
    */
-  public void start(String actorId, boolean overwriteSwimlane)
-  {
+  public void start(String actorId, boolean overwriteSwimlane) {
     setActorId(actorId, overwriteSwimlane);
     start();
   }
@@ -355,101 +318,90 @@
   /**
    * overwrite start date
    */
-  public void setStart(Date date)
-  {
+  public void setStart(Date date) {
     start = null;
   }
 
-  private void markAsCancelled()
-  {
+  private void markAsCancelled() {
     this.isCancelled = true;
     this.isOpen = false;
   }
 
   /**
-   * cancels this task. This task intance will be marked as cancelled and as ended. But cancellation doesn't influence
-   * singalling and continuation of process execution.
+   * cancels this task. This task intance will be marked as cancelled and as ended. But cancellation
+   * doesn't influence singalling and continuation of process execution.
    */
-  public void cancel()
-  {
+  public void cancel() {
     markAsCancelled();
     end();
   }
 
   /**
-   * cancels this task, takes the specified transition. This task intance will be marked as cancelled and as ended. But
-   * cancellation doesn't influence singalling and continuation of process execution.
+   * cancels this task, takes the specified transition. This task intance will be marked as
+   * cancelled and as ended. But cancellation doesn't influence singalling and continuation of
+   * process execution.
    */
-  public void cancel(Transition transition)
-  {
+  public void cancel(Transition transition) {
     markAsCancelled();
     end(transition);
   }
 
   /**
-   * cancels this task, takes the specified transition. This task intance will be marked as cancelled and as ended. But
-   * cancellation doesn't influence singalling and continuation of process execution.
+   * cancels this task, takes the specified transition. This task intance will be marked as
+   * cancelled and as ended. But cancellation doesn't influence singalling and continuation of
+   * process execution.
    */
-  public void cancel(String transitionName)
-  {
+  public void cancel(String transitionName) {
     markAsCancelled();
     end(transitionName);
   }
 
   /**
-   * marks this task as done. If this task is related to a task node this might trigger a signal on the token.
+   * marks this task as done. If this task is related to a task node this might trigger a signal on
+   * the token.
    * 
    * @see #end(Transition)
    */
-  public void end()
-  {
-    end((Transition)null);
+  public void end() {
+    end((Transition) null);
   }
 
   /**
-   * marks this task as done and specifies the name of a transition leaving the task-node for the case that the
-   * completion of this task instances triggers a signal on the token. If this task leads to a signal on the token, the
-   * given transition name will be used in the signal. If this task completion does not trigger execution to move on,
-   * the transitionName is ignored.
+   * marks this task as done and specifies the name of a transition leaving the task-node for the
+   * case that the completion of this task instances triggers a signal on the token. If this task
+   * leads to a signal on the token, the given transition name will be used in the signal. If this
+   * task completion does not trigger execution to move on, the transitionName is ignored.
    */
-  public void end(String transitionName)
-  {
+  public void end(String transitionName) {
     Transition leavingTransition = null;
 
-    if (task != null)
-    {
+    if (task != null) {
       Node node = task.getTaskNode();
-      if (node == null)
-      {
-        node = (Node)task.getParent();
+      if (node == null) {
+        node = (Node) task.getParent();
       }
 
-      if (node != null)
-      {
+      if (node != null) {
         leavingTransition = node.getLeavingTransition(transitionName);
       }
     }
-    if (leavingTransition == null)
-    {
+    if (leavingTransition == null) {
       throw new JbpmException("task node does not have leaving transition '" + transitionName + "'");
     }
     end(leavingTransition);
   }
 
   /**
-   * marks this task as done and specifies a transition leaving the task-node for the case that the completion of this
-   * task instances triggers a signal on the token. If this task leads to a signal on the token, the given transition
-   * name will be used in the signal. If this task completion does not trigger execution to move on, the transition is
-   * ignored.
+   * marks this task as done and specifies a transition leaving the task-node for the case that the
+   * completion of this task instances triggers a signal on the token. If this task leads to a
+   * signal on the token, the given transition name will be used in the signal. If this task
+   * completion does not trigger execution to move on, the transition is ignored.
    */
-  public void end(Transition transition)
-  {
-    if (this.end != null)
-    {
+  public void end(Transition transition) {
+    if (this.end != null) {
       throw new IllegalStateException("task instance '" + id + "' is already ended");
     }
-    if (this.isSuspended)
-    {
+    if (this.isSuspended) {
       throw new JbpmException("task instance '" + id + "' is suspended");
     }
 
@@ -458,8 +410,7 @@
     this.isOpen = false;
 
     // fire the task instance end event
-    if ((task != null) && (token != null))
-    {
+    if ((task != null) && (token != null)) {
       ExecutionContext executionContext = new ExecutionContext(token);
       executionContext.setTask(task);
       executionContext.setTaskInstance(this);
@@ -467,8 +418,7 @@
     }
 
     // log this assignment
-    if (token != null)
-    {
+    if (token != null) {
       token.addLog(new TaskEndLog(this));
     }
 
@@ -476,40 +426,39 @@
     submitVariables();
 
     // verify if the end of this task triggers continuation of execution
-    if (isSignalling)
-    {
+    if (isSignalling) {
       this.isSignalling = false;
 
       if (this.isStartTaskInstance() // ending start tasks always leads to a signal
-          || ((task != null) && (token != null) && (task.getTaskNode() != null) && (task.getTaskNode().completionTriggersSignal(this))))
-      {
+          || ((task != null) && (token != null) && (task.getTaskNode() != null) && (task.getTaskNode().completionTriggersSignal(this)))) {
 
-        if (transition == null)
-        {
-          log.debug("completion of task '" + task.getName() + "' results in taking the default transition");
+        if (transition == null) {
+          log.debug("completion of task '"
+              + task.getName()
+              + "' results in taking the default transition");
           token.signal();
         }
-        else
-        {
-          log.debug("completion of task '" + task.getName() + "' results in taking transition '" + transition + "'");
+        else {
+          log.debug("completion of task '"
+              + task.getName()
+              + "' results in taking transition '"
+              + transition
+              + "'");
           token.signal(transition);
         }
       }
     }
   }
 
-  public boolean hasEnded()
-  {
+  public boolean hasEnded() {
     return (end != null);
   }
 
   /**
    * suspends a process execution.
    */
-  public void suspend()
-  {
-    if (!isOpen)
-    {
+  public void suspend() {
+    if (!isOpen) {
       throw new JbpmException("a task that is not open cannot be suspended: " + toString());
     }
     isSuspended = true;
@@ -518,10 +467,8 @@
   /**
    * resumes a process execution.
    */
-  public void resume()
-  {
-    if (!isOpen)
-    {
+  public void resume() {
+    if (!isOpen) {
       throw new JbpmException("a task that is not open cannot be resumed: " + toString());
     }
     isSuspended = false;
@@ -529,49 +476,40 @@
 
   // comments /////////////////////////////////////////////////////////////////
 
-  public void addComment(String message)
-  {
+  public void addComment(String message) {
     addComment(new Comment(message));
   }
 
-  public void addComment(Comment comment)
-  {
-    if (comment != null)
-    {
-      if (comments == null)
-        comments = new ArrayList();
+  public void addComment(Comment comment) {
+    if (comment != null) {
+      if (comments == null) comments = new ArrayList<Comment>();
       comments.add(comment);
       comment.setTaskInstance(this);
-      if (token != null)
-      {
+      if (token != null) {
         comment.setToken(token);
         token.addComment(comment);
       }
     }
   }
 
-  public List getComments()
-  {
+  public List<Comment> getComments() {
     return comments;
   }
 
   // task form ////////////////////////////////////////////////////////////////
 
-  public boolean isLast()
-  {
+  public boolean isLast() {
     return ((token != null) && (taskMgmtInstance != null) && (!taskMgmtInstance.hasUnfinishedTasks(token)));
   }
 
   /**
-   * is the list of transitions that can be used in the end method and it is null in case this is not the last task
-   * instance.
+   * is the list of transitions that can be used in the end method and it is null in case this is
+   * not the last task instance.
    */
-  public List getAvailableTransitions()
-  {
-    List transitions = null;
-    if ((!isLast()) && (token != null))
-    {
-      transitions = new ArrayList(token.getAvailableTransitions());
+  public List<Transition> getAvailableTransitions() {
+    List<Transition> transitions = null;
+    if ((!isLast()) && (token != null)) {
+      transitions = new ArrayList<Transition>(token.getAvailableTransitions());
     }
     return transitions;
   }
@@ -579,209 +517,168 @@
   // equals ///////////////////////////////////////////////////////////////////
   // hack to support comparing hibernate proxies against the real objects
   // since this always falls back to ==, we don't need to overwrite the hashcode
-  public boolean equals(Object o)
-  {
+  public boolean equals(Object o) {
     return EqualsUtil.equals(this, o);
   }
 
-  public String toString()
-  {
-    return "TaskInstance" + (name != null ? "(" + name + ")" : "@" + Integer.toHexString(hashCode()));
+  public String toString() {
+    return "TaskInstance"
+        + (name != null ? "(" + name + ")" : "@" + Integer.toHexString(hashCode()));
   }
 
   // private //////////////////////////////////////////////////////////////////
 
   /** takes a set of {@link PooledActor}s */
-  public void setPooledActors(Set pooledActors)
-  {
-    if (pooledActors != null)
-    {
-      this.pooledActors = new HashSet(pooledActors);
-      Iterator iter = pooledActors.iterator();
-      while (iter.hasNext())
-      {
-        PooledActor pooledActor = (PooledActor)iter.next();
+  public void setPooledActors(Set<PooledActor> pooledActors) {
+    if (pooledActors != null) {
+      this.pooledActors = new HashSet<PooledActor>(pooledActors);
+      for (PooledActor pooledActor : pooledActors) {
         pooledActor.addTaskInstance(this);
       }
     }
-    else
-    {
+    else {
       this.pooledActors = null;
     }
   }
 
   // protected ////////////////////////////////////////////////////////////////
 
-  protected VariableContainer getParentVariableContainer()
-  {
+  protected VariableContainer getParentVariableContainer() {
     ContextInstance contextInstance = getContextInstance();
     return (contextInstance != null ? contextInstance.getOrCreateTokenVariableMap(token) : null);
   }
 
   // getters and setters //////////////////////////////////////////////////////
 
-  public String getActorId()
-  {
+  public String getActorId() {
     return actorId;
   }
 
-  public Date getDueDate()
-  {
+  public Date getDueDate() {
     return dueDate;
   }
 
-  public void setDueDate(Date dueDate)
-  {
+  public void setDueDate(Date dueDate) {
     this.dueDate = dueDate;
   }
 
-  public Date getEnd()
-  {
+  public Date getEnd() {
     return end;
   }
 
-  public void setEnd(Date end)
-  {
+  public void setEnd(Date end) {
     this.end = end;
   }
 
-  public void setCreate(Date create)
-  {
+  public void setCreate(Date create) {
     this.create = create;
   }
 
-  public long getId()
-  {
+  public long getId() {
     return id;
   }
 
-  public void setId(long id)
-  {
+  public void setId(long id) {
     this.id = id;
   }
 
-  public Date getStart()
-  {
+  public Date getStart() {
     return start;
   }
 
-  public TaskMgmtInstance getTaskMgmtInstance()
-  {
+  public TaskMgmtInstance getTaskMgmtInstance() {
     return taskMgmtInstance;
   }
 
-  public void setTaskMgmtInstance(TaskMgmtInstance taskMgmtInstance)
-  {
+  public void setTaskMgmtInstance(TaskMgmtInstance taskMgmtInstance) {
     this.taskMgmtInstance = taskMgmtInstance;
   }
 
-  public Token getToken()
-  {
+  public Token getToken() {
     return token;
   }
 
-  public void setToken(Token token)
-  {
+  public void setToken(Token token) {
     this.token = token;
   }
 
-  public void setSignalling(boolean isSignalling)
-  {
+  public void setSignalling(boolean isSignalling) {
     this.isSignalling = isSignalling;
   }
 
-  public boolean isSignalling()
-  {
+  public boolean isSignalling() {
     return isSignalling;
   }
 
-  public boolean isCancelled()
-  {
+  public boolean isCancelled() {
     return isCancelled;
   }
 
-  public String getName()
-  {
+  public String getName() {
     return name;
   }
 
-  public void setName(String name)
-  {
+  public void setName(String name) {
     this.name = name;
   }
 
-  public boolean isBlocking()
-  {
+  public boolean isBlocking() {
     return isBlocking;
   }
 
-  public void setBlocking(boolean isBlocking)
-  {
+  public void setBlocking(boolean isBlocking) {
     this.isBlocking = isBlocking;
   }
 
-  public Date getCreate()
-  {
+  public Date getCreate() {
     return create;
   }
 
-  public Task getTask()
-  {
+  public Task getTask() {
     return task;
   }
 
-  public SwimlaneInstance getSwimlaneInstance()
-  {
+  public SwimlaneInstance getSwimlaneInstance() {
     return swimlaneInstance;
   }
 
-  public void setSwimlaneInstance(SwimlaneInstance swimlaneInstance)
-  {
+  public void setSwimlaneInstance(SwimlaneInstance swimlaneInstance) {
     this.swimlaneInstance = swimlaneInstance;
   }
 
-  public String getPreviousActorId()
-  {
+  public String getPreviousActorId() {
     return previousActorId;
   }
 
-  public int getPriority()
-  {
+  public int getPriority() {
     return priority;
   }
 
-  public void setPriority(int priority)
-  {
+  public void setPriority(int priority) {
     this.priority = priority;
   }
 
-  public boolean isOpen()
-  {
+  public boolean isOpen() {
     return isOpen;
   }
 
-  public String getDescription()
-  {
+  public String getDescription() {
     return description;
   }
 
-  public void setDescription(String description)
-  {
+  public void setDescription(String description) {
     this.description = description;
   }
 
-  public boolean isSuspended()
-  {
+  public boolean isSuspended() {
     return isSuspended;
   }
 
-  public ProcessInstance getProcessInstance()
-  {
+  public ProcessInstance getProcessInstance() {
     return processInstance;
   }
 
-  public void setProcessInstance(ProcessInstance processInstance)
-  {
+  public void setProcessInstance(ProcessInstance processInstance) {
     this.processInstance = processInstance;
   }
 




More information about the jbpm-commits mailing list