2 Replies Latest reply on Aug 14, 2007 2:26 PM by Jason Greiner

    Ending a Task.

    Jason Greiner Newbie

      When I am ending a taskinstance do I have to manually clear the actor, and the group assignments? What is happening is my tasks hang around in the group assignments even though I ended the task. I just wanted to verify, seems like ending the task should make sure that task does not come up any longer when you grab the tasks by group assignments.

      So what I plan on doing is clearing the group assignments manually, but wanted to check with the group and see if I am ending the task incorrectly or if there is a better way of doing it.

      Here is an example of the code I am using below.

       try
       {
       JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
       jbpmContext = jbpmConfiguration.createJbpmContext();
      
       pid = 23456;
      
       ProcessInstance pi = jbpmContext.getProcessInstance(pid);
      
       Collection tis = pi.getTaskMgmtInstance().getTaskInstances();
       Iterator li = tis.iterator();
       while (li.hasNext())
       {
       TaskInstance ti = (TaskInstance)li.next();
       if (ti.getEnd() == null && ti.getName().equals("taskname"))
       {
       if (transitionPath.equals(ProcessTransitions.WORK_QUEUE))
       {
       ti.setActorId(null);
       ti.end(ProcessTransitions.WORK_QUEUE);
       }
       else
       {
       ti.setActorId(null);
       ti.end(ProcessTransitions.END_PROCESS);
       }
       // Save the Task Instance
       jbpmContext.save(ti);
       break; // Do not need to contiue found our guy
       }
       }
       }
       }
       catch (Throwable ex)
       {
       logger.error("Error occured: " + ex);
       throw new EJBException("Error Occured: " + ex);
       }
       finally
       {
       if (jbpmContext != null)
       jbpmContext.close();
       }
      


      Thanks

        • 1. Re: Ending a Task.
          Ronald van Kuijk Master

           

          When I am ending a taskinstance do I have to manually clear the actor, and the group assignments?

          no

          What is happening is my tasks hang around in the group assignments even though I ended the task. I just wanted to verify, seems like ending the task should make sure that task does not come up any longer when you grab the tasks by group assignments.
          Make sure you get the *unfinished* tasks... there is an api for both

          • 2. Re: Ending a Task.
            Jason Greiner Newbie

            Well to be honest with you I did not believe your suggestion was any different than what I was doing since I was checking the end date to make sure the TaskInstance was not ended.

            However after trying your suggestion it worked perfectly. I will now have to dig through that source and see if I can not understand the difference.

            Thanks for your help.