4 Replies Latest reply on Jul 17, 2006 4:38 AM by s_telios

    Custom fork - jbpm 3

    s_telios

      Hi I'm trying to make a custom fork. The number of the Transitions is dynamic and different in each process instance. In the process definition I have added one Transition leaving from the fork. A loop in its action handler, creates new tokens for 1-n times and lets the current token to do the n Transition.

      
       public void execute(ExecutionContext executionContext) throws Exception {
      
       String parts = (String)executionContext.getContextInstance().getVariable("txtParticipantList");
       String p = (String)executionContext.getContextInstance().getVariable("tmpParticipant");
       String[] users = parts.split(",");
      
       if (p == null || p.equals("")){
       Transition transition = executionContext.getTransition();
       for (int j=0; j<users.length-1; j++) {
       String user = users[j];
       Token newToken = new Token(executionContext.getToken(), "dist." + j);
       //newToken.setTerminationImplicit(true);
       executionContext.getJbpmContext().save(newToken);
       ExecutionContext newExecutionContext = new ExecutionContext(newToken);
       newExecutionContext.setVariable("tmpParticipant", user);
       newExecutionContext.setVariable("pCount", Integer.toString(users.length));
       executionContext.getTransitionSource().leave(newExecutionContext, transition);
       }
       executionContext.setVariable("txtParticipant", users[users.length-1]);
       executionContext.setVariable("pCount", Integer.toString(users.length));
       }
       else{
       executionContext.getContextInstance().setVariable("txtParticipant", p);
       executionContext.setVariable("pCount", Integer.toString(users.length));
       }
      
       }
      
      


      The swimlane for the task after the fork is

       <swimlane name="reviewer">
       <assignment expression="variable(txtParticipant)"/>
       </swimlane>
      


      My problem is that the 'txtParticipant' although is set, the delegation doesn't see. It thinks that is null and throws delegation exceptions.

      I was based on that:
      http://wiki.jboss.org/wiki/attach?page=ForEachForkActionHandler%2FForEachForkActionHandler.java

      Any ideas?

        • 1. Re: Custom fork - jbpm 3
          bkaremba

          Did you manage to get any answers for this?

          Regards

          Brian

          • 2. Re: Custom fork - jbpm 3
            c.vidal

            Hi,

            I'm also interested by the answer to this :) I'm trying to achieve the exact same purpose.

            Tchao

            • 3. Re: Custom fork - jbpm 3
              bkaremba

              Did you manage to get any answers for this?

              Regards

              Brian

              • 4. Re: Custom fork - jbpm 3
                s_telios

                Yes I managed to do it.
                My understanding is that while you are at the fork the child-tokens are not 'commited' to the database yet and that is the reason of the exceptions.

                What I did is that:

                One the next task I defined to use a custom assigment:

                <assignment class='my class that implements an AssignmentHandler/>


                And in the assign() method of that class I set the actor id:

                String reviewer = (String)executionContext.getContextInstance().getVariable("txtParticipant");
                assignable.setActorId(reviewer);
                



                Regards,

                Stelios