2 Replies Latest reply on Aug 8, 2005 10:56 AM by rorysteele

    How to get actorId from transitions

      Hello

      Does anybody know how to get the actor id in an ActionHandler from a transition leaving a task-node?
      i.e

      ...
      <task-node ...>
       <transition to="somewhere">
       <action class="SomeHandler">
       </transition>
      </task-node>
      ...


      and tried

      class SomeHandler {
      
       public void execute(final ExecutionContext context) throws Exception {
       String actor = context.getTaskInstance().getActorId(); // returns null
       ...
       }
      }


      and

      class SomeHandler {
      
       public void execute(final ExecutionContext context) throws Exception {
       long id = context.getToken().getId();
       JbpmSession session = JbpmSession.getCurrentJbpmSession();
       List tasks = session.getTaskMgmtSession().findTaskInstancesByToken(id);
       TaskInstance task = ((TaskInstance) tasks.iterator().next()).getActorId(); // returns null
       ...
       }
      }


      Any help's appreciated

      Cheers,
      Rory

        • 1. Re: How to get actorId from transitions

          Hi

          I should have said this is in JBPM 3 and to correct the code examples slightly:

          - the task node does have a inner task element in the XML
          - in the first example it returns a null TaskInstance not actorId (then a NullPointerException on getActorId())
          - in the second example the list of tasks is empty

          Cheers
          Rory

          • 2. Re: How to get actorId from transitions

            I'll answer my own question for those that may come across the same problem...

            String query =
            "select ti from org.jbpm.taskmgmt.exe.TaskInstance as ti "+
            "where ti.end is not null and ti.token.id = :tokenId";
            
            ....
            ExecutionContext context = ....
            JbpmSession session = JbpmSession.getCurrentJbpmSession();
            Query query = session.getSession().createQuery(query);
            query.setLong("tokenId", context.getToken().getId());
            List tasks = query.list();
            
            // so something with tasks
            
            session.close();
            


            I'm assuming that the TaskInstance is 'ended' before the transition is taken - would be nice to have access to this functionality via TaskMgmtSession

            Rory