6 Replies Latest reply on Jul 29, 2007 11:14 AM by damianharvey

    Unassign Task

    damianharvey

      I was searching for a way to return a task to the pooled tasks (ie. unassign it).

      This works for me and others may find it useful:

      jbpmContext.getTaskMgmtSession().loadTaskInstance(taskId).setActorId(null);
      

      where taskId is the id (type long) passed into the method via a request parameter.

      Would be handy if you could call setActor on the taskInstance returned from the taskInstanceList but it returns org.jbpm.taskmgmt.exe.TaskInstance which as it isn't a Seam component, can't be called from EL. Would be super-handy if you could just call task.unassign()


        • 1. Re: Unassign Task

          Have you tried the new extended EL in Seam 2? I'd be quite surprised if you couldn't call the method you want.

          • 2. Re: Unassign Task
            gavin.king

            #{pooledTask.assign(null)} should work I guess.

            But even better, let's add a PooledTask.unassign() method.

            • 3. Re: Unassign Task
              damianharvey

              I had tried #{pooledTask.assign(null)} but the task just disappeared from both lists as it sets the ACTORID column in the JBPM_TASKINSTANCE table to blank rather than NULL.

              I've noticed that you can't pass null using EL. It gets sent to the Bean as an empty string.

              • 4. Re: Unassign Task
                gavin.king

                Then please report that EL issue in Seam JIRA so that we can fix it. null!="" ;-)

                • 5. Re: Unassign Task
                  torsty

                  Don't know if I got you, but you said you did want

                  to return a task to the pooled tasks
                  I am assigning a task back to a (named) pool like this. (this is reassigning a task to a pool - but not unassigning the task completly):

                   public void reassignToPool()
                   {
                   Long taskIdLong = new Long( this.taskId); // Your taskId
                   PooledActor myPoolActor = new PooledActor("myPoolActorName");
                   Set<PooledActor> pool = new HashSet<PooledActor>();
                   pool.add(myPoolActor);
                   if ( taskId != null )
                   {
                   jbpmContext.getTaskMgmtSession().loadTaskInstance(taskIdLong.longValue()).setPooledActors( pool ) ;
                   jbpmContext.getTaskMgmtSession().loadTaskInstance(taskIdLong.longValue()).setActorId( null ) ;
                   }
                   else
                   {
                   //
                   }
                   }
                  


                  • 6. Re: Unassign Task
                    damianharvey

                    If you had assigned the task to the 'myPoolActorName' in the first place you only need set the actorId to null to return it.

                    Issue raised over the EL null thing : http://jira.jboss.com/jira/browse/JBSEAM-1737

                    Thanks,

                    Damian.