5 Replies Latest reply on Jun 7, 2006 3:32 PM by kukeltje

    Task assignment problem

    yschluchter

      Hi,

      I have the following problem in my process.

      task_1 is assigned to a pool of actors (swimlane containing user_1 and user_2)

      When the user_1 starts the task_1, the task instance is assigned to him (call to setAdctorId method)

      Once user_1 completed the task_1, the transition goes to task_2.

      Once the task_2 is completed (by anybody), the transition goes bask to task_1.

      Normally, the new task instance of task_1 should be assigned to the pool of actors user_1 and user_2.

      But jBPM assignes it automatically to user_1.

      Is it a normal behavior or is it a bug?

      Thanks for your help!

        • 1. Re: Task assignment problem
          kukeltje

          normal behaviour afaik (maybe it is not always should change, but that is another thing)

          Once a swimlane has an actor assigned in it, it will always use the same assigned actor. The assignementhandler will not be called again.

          Maybe the an attribute on the swimlane like 'evaluate' with the possible values of 'initial', 'always', 'once a day' would be an addition.

          • 2. Re: Task assignment problem
            yschluchter

            Hi,

            Thanks for your quick answer! :)

            To get the right behavior (calling everytime the assignment handler), I changed my task like this:

            Before, the task was assigned to a swimlane which was calling the assignment handler.

            Now, the task is directly linked to the handler. I don't have any swimlane anymore.

            ...and it works perfectly!

            Thanks for your help!

            • 3. Re: Task assignment problem
              kukeltje

              The biggest chance you will have on a quick answer from me is posting it between 07:00 and 08:00 CET, or between 22:00 and 0:00 CET.

              Now back to your response That is what I did to, but personally I like to have this functionality WITH using swimlanes

              • 4. Re: Task assignment problem
                hannes

                 

                "kukeltje" wrote:
                Once a swimlane has an actor assigned in it, it will always use the same assigned actor. The assignementhandler will not be called again.


                I am running in the same problem: i need to run the AssignmentHandler once more. So i firstly wrote an action:
                import java.util.HashSet;
                
                import org.apache.commons.logging.Log;
                import org.apache.commons.logging.LogFactory;
                import org.jbpm.graph.def.ActionHandler;
                import org.jbpm.graph.exe.ExecutionContext;
                import org.jbpm.taskmgmt.exe.SwimlaneInstance;
                
                public class ClearSwimlaneHandler implements ActionHandler {
                 private static final Log log = LogFactory.getLog(ClearSwimlaneHandler.class);
                
                 private String swimlane;
                
                 public void execute(ExecutionContext executionContext) throws Exception {
                 SwimlaneInstance swi = executionContext.getProcessInstance().getTaskMgmtInstance().getSwimlaneInstance(swimlane);
                 if (swi == null) {
                 log.error("cant reassign: Swimlane doesnt exists: "
                 + swimlane);
                 } else {
                 swi.setActorId(null);
                 swi.setPooledActors(new HashSet());
                 log.info("clearing actors for swimlane: "+ swimlane);
                 }
                 }
                }

                The action gets invoked at the affected task:
                <task-node name="Analyze State">
                 <task name="Analyze" swimlane="Responsible">
                 <event type="task-create">
                 <action name="Always Assignment"
                 class="my.ClearSwimlaneHandler">
                 <swimlane>Responsible</swimlane>
                 </action>
                 </event>

                But the assignment is 'null'

                The I tried to delete the swimlane of the task:
                public void execute(ExecutionContext executionContext) throws Exception {
                 executionContext.getTask().setSwimlane(null);

                But no assignment:
                The code of the taskinstance (jbpm 3.0.2) says:

                public void assign(ExecutionContext executionContext) {
                 TaskMgmtInstance taskMgmtInstance = executionContext
                 .getTaskMgmtInstance();
                
                 Swimlane swimlane = task.getSwimlane();
                 // if this task is in a swimlane
                 if (swimlane != null) {
                
                 // if this is a task assignment for a start-state
                 if (isStartTaskInstance()) {
                 // initialize the swimlane
                 swimlaneInstance = new SwimlaneInstance(swimlane);
                 taskMgmtInstance.addSwimlaneInstance(swimlaneInstance);
                 // with the current authenticated actor
                 swimlaneInstance.setActorId(Authentication
                 .getAuthenticatedActorId());
                
                 } else {
                
                 // lazy initialize the swimlane...
                 // get the swimlane instance (if there is any)
                 swimlaneInstance = taskMgmtInstance
                 .getInitializedSwimlaneInstance(executionContext,
                 swimlane);
                
                 // copy the swimlaneInstance assignment into the taskInstance
                 // assignment
                 copySwimlaneInstanceAssignment(swimlaneInstance);
                 }
                
                 } else { // this task is not in a swimlane
                 taskMgmtInstance.invokeAssignmentHandler(task
                 .getAssignmentDelegation(), this, executionContext);
                 }
                
                 updatePooledActorsReferences(swimlaneInstance);
                 }

                So it should be enough to clear the swimlane of the task, or am I wrong?

                • 5. Re: Task assignment problem
                  kukeltje

                  you clear the actorid, not the swimlane. The code you show tests for the swimlane to be null, not the actor or so.

                  Could be that the same is true for 3.1 as well, then I was wrong and you should make the swimlane null.