4 Replies Latest reply on Sep 16, 2010 6:22 PM by Rafael Espirito Santo

    JBPM how to signal a transition from Node Action Expression

    Anthony Yulo Newbie

      How do you signal a named transition from a Node (Node Type) from within the action Expression method.


      I have the following jpdl and code snippet but after the node name2 is executed, the next node ApproveQuote1 does not execute:


      <start-state name="Start">
      
                <transition to="node2"></transition>
           </start-state>
      
           <node name="node2">
                <action expression="#{controlBean.testAction}"></action>
                <transition to="ApproveQuote1" name="quote1"></transition>
           </node>
      
           <task-node name="ApproveQuote1"  end-tasks="true">
                <task name="ApproveQuote1" description="Approve Quote1">
                     <assignment actor-id="engel"/>
                     <controller></controller>
                </task>
                <transition to="Update StatusD" name="deny"></transition>
                <transition to="UpdateStatusA" name="approve"></transition>
           </task-node>
      ...
      ...
      



           //this code executes but the flow does not go thru the next node anymore even if i
           //had specified a transition to go.
           @Transition("quote1")
           public String  testAction(){
                // TODO Auto-generated method stub
                log.info("Execute Called");
                IvItemM item = this.getResultList().get(0);
                item.setItemMaxOrderQty(new Float(7852.2));
                this.getEntityManager().persist(item);
                //processInstance.signal("quote1");
                return "gotoNextPage";
                
                
                
           }
      



      Any ideas?


        • 1. Re: JBPM how to signal a transition from Node Action Expression
          Gergely Nagy Newbie

          If you specify an action on the node itself, you need to take care of execution propagation yourself. Unless you want to influence transitions, simply add the action on an event like node-enter and not worry about activating the transition.


          <node name="foo">
              <event type="node-enter">
                  <action expression="#{controlBean.testAction}"></action>
              </event>
          </node>
          


          See also section 10.5 of the JBPM 3.2 documentation.


          If you really need an action on the node to control the transitions, consider implementing
          org.jbpm.graph.def.ActionHandler;
          where you have access to the execution context, and then can perform something like:


          executionContext.getNode().leave(executionContext, transition);
          


          • 3. Re: JBPM how to signal a transition from Node Action Expression
            Rafael Espirito Santo Newbie

            Hi!


            I have a similar issue... but at the end of action method, I need to return to a specific page.


            This is a fragment of xhtml page



            <h:selectOneListbox value="#{chooseMetodologyAction.methodology}" size="1">
                             <f:selectItem itemValue="Quasi Systematic Review" itemLabel="Quasi Systematic Review"/>
                             <f:selectItem itemValue="Systematic Review" itemLabel="Systematic Review"/>
                        </h:selectOneListbox>
                        <div style="clear:both"/>
                        </div>
                    </rich:panel>
            
                    <div class="actionButtons">
                        <h:commandButton value="#{messages['button.next']}" action="#{chooseMetodologyAction.execute}">
                             <f:param name="taskId" value="#{taskInstance.id}"/>
                        </h:commandButton>



            So, based on methodology value, I redirect the process to run on different paths



            <task-node name="fill methodology">
                   <task name="methodology" description="#{messages['srprocess.choosemethodology.description']}">
                        <assignment pooled-actors="researcher"/>
                   </task>
                   <transition name="Systematic Review" to="fill meta analysis" />
                   <transition name="Quasi Systematic Review" to="fill primary question" />
              </task-node>



            The problem is that I can´t return a string on execute method (defined in ActionHandler interface)



            @Name("chooseMetodologyAction")
            @Scope(ScopeType.PAGE)
            public class ChooseMetodologyAction implements ActionHandler, Serializable {
                 /**
                  * 
                  */
                 private static final long serialVersionUID = 4304516385829464005L;
                 private static final Object SYSTEMATIC_REVIEW = null;
                 private String methodology;
                 
                 public String getMethodology() {
                      return methodology;
                 }
            
                 public void setMethodology(String methodology) {
                      this.methodology = methodology;
                 }
                 
                 @EndTask
                 public String endChooseMetodology() {
                      //TODO: Choose correct path!
                      return "/listActivities.xhtml";
                 }
            
                 public void execute(ExecutionContext executionContext) throws Exception {
                      if (methodology.equals(ChooseMetodologyAction.SYSTEMATIC_REVIEW)) {
                           executionContext.getNode().leave(executionContext, "Yes");
                      } else {
                           executionContext.getNode().leave(executionContext, "No");
                      }
                      //return "/listActivities.xhtml";
                 }
            }
            



            What can I do to choose a transition and redirect to listActivitives.xhtml?


            Thanks!


            PS: Apologies for anything written wrong... I don´t have to much practice writing in english





            • 4. Re: JBPM how to signal a transition from Node Action Expression
              Rafael Espirito Santo Newbie

              Hi!
              I remember that I can inject Transition component like this.



              @Name("chooseMetodologyAction")
              @Scope(ScopeType.PAGE)
              public class ChooseMetodologyAction implements Serializable {
                   /**
                    * 
                    */
                   private static final long serialVersionUID = 4304516385829464005L;
                   private static final Object SYSTEMATIC_REVIEW = "Systematic Review";
                   private static final Object QUASI_SYSTEMATIC_REVIEW = "Quasi Systematic Review";
                   private String methodology;
                   
                   @In
                   private StatusMessages statusMessages;
                   
                   @In
                   private Transition transition;
                   
                   public String getMethodology() {
                        return methodology;
                   }
              
                   public void setMethodology(String methodology) {
                        this.methodology = methodology;
                   }
                   
                   @EndTask
                   public String endChooseMetodology() {
                        if (methodology.equals(ChooseMetodologyAction.SYSTEMATIC_REVIEW)) {
                             transition.setName("Systematic Review");
                        } else if (methodology.equals(ChooseMetodologyAction.QUASI_SYSTEMATIC_REVIEW)){
                             transition.setName("Quasi Systematic Review");
                        }
                        return "/listActivities.xhtml";
                   }
              }