9 Replies Latest reply on Mar 13, 2008 12:54 PM by kukeltje

    Movo to node

    jagr

      I've defined a process like this.


      <?xml version="1.0" encoding="UTF-8"?>
      <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="reserva">
       <swimlane name="reception">
       <assignment actor-id="pepeito"></assignment>
       </swimlane>
       <start-state name="Offer petition">
       <task name="Offer petition" swimlane="reception">
       <controller></controller>
       </task>
       <transition to="searchClient" name="search"></transition>
       </start-state>
       <task-node name="Create client">
       <task name="Create client" swimlane="reception">
       <controller></controller>
       </task>
       <event type="node-enter">
       <action class="com.aixtelecom.actions.CreateClientAction"></action>
       </event>
       <transition to="Create offer" name="crear oferta"></transition>
       </task-node>
       <task-node name="Create offer">
       <task name="Create offer" swimlane="reception">
       <controller></controller>
       </task>
       <event type="node-enter">
       <action class="com.aixtelecom.actions.CreateOfferAction"></action>
       </event>
       <transition to="Createbooking" name="yes"></transition>
       <transition to="finish" name="no"></transition>
       </task-node>
       <task-node name="Createbooking">
       <task name="Createbooking" swimlane="reception">
       <controller></controller>
       </task>
       <transition to="finish" name="Fi"></transition>
       </task-node>
       <node name="searchClient">
       <event type="node-enter">
       <action class="com.aixtelecom.actions.SearchClientAction"></action>
       </event>
       <transition to="Create offer" name="tr_create_offer"></transition>
       <transition to="Create client" name="tr_create_client"></transition>
       </node>
       <end-state name="finish"></end-state>
      </process-definition>
      


      At seachClient node i've created action handler on node-enter.
      This action is:
      public class SearchClientAction implements ActionHandler{
      
       /** The log. */
       private Logger log = Logger.getLogger(SearchClientAction.class);
      
       private static final long serialVersionUID = 3364679100134686576L;
      
       public void execute(ExecutionContext context) throws Exception {
      
       [connection with external mysql data base]
      
       if (result of query){
       //go to create offer
       node.leave(context, "tr_create_offer");
       }
       else{
       //go to create client
       node.leave(context, "tr_create_client");
       }
       }
      }
      


      I want depending on result of query, automatically process go to create client or create offer.
      On create client node and create offer node i've configured actions with
      System.out.println("Running on CreateClientAction...");
      or
      System.out.println("### Running on CreateOfferAction");

      When i start the process and enter on searchClient node, always the process finish into create offer node.

      17:06:49,000 INFO [STDOUT] Running on CreateClientAction...
      17:06:49,000 WARN [ProxyWarnLog] Narrowing proxy to class org.jbpm.graph.node.TaskNode - thi
      s operation breaks ==
      17:06:49,000 INFO [STDOUT] ### Running on CreateOfferAction
      


      Any idea?


        • 1. Re: Movo to node
          kukeltje

          what happens if the value of "result of query" is explicitly true? if that fails, please make a unittest that I can cut and paste (in one file) to try it out....

          • 2. Re: Movo to node
            jagr

            In this case

             if (true){
             //go to create offer
             node.leave(context, "tr_create_offer");
             }
             else{
             //go to create client
             node.leave(context, "tr_create_client");
             }
            


            the result is

            09:31:22,750 INFO [STDOUT] ### Running on CreateOfferAction
            09:31:22,781 INFO [STDOUT] ### Running on CreateOfferAction
            


            Seems that node changes how code is defined, but at last time always go to CreateOffer node.

            • 3. Re: Movo to node
              kukeltje

              so, maybe the response of your query is not (always) correct?

              • 4. Re: Movo to node
                jagr

                Yes. Query response it's correct.
                In exemple, If I execute this ActionHandler

                public class SearchClientAction implements ActionHandler{
                
                 /** The log. */
                 private Logger log = Logger.getLogger(SearchClientAction.class);
                
                 private static final long serialVersionUID = 3364679100134686576L;
                
                 public void execute(ExecutionContext context) throws Exception {
                
                 [connection with external mysql data base]
                
                 if (1==1){
                 //go to create offer
                 node.leave(context, "tr_create_offer");
                 }
                 else{
                 //go to create client
                 node.leave(context, "tr_create_client");
                 }
                 }
                }
                


                Result will be
                INFO [STDOUT] ### Running on CreateOfferAction
                INFO [STDOUT] ### Running on CreateOfferAction

                If I execute this code

                public class SearchClientAction implements ActionHandler{
                
                 /** The log. */
                 private Logger log = Logger.getLogger(SearchClientAction.class);
                
                 private static final long serialVersionUID = 3364679100134686576L;
                
                 public void execute(ExecutionContext context) throws Exception {
                
                 [connection with external mysql data base]
                
                 if (1==2){
                 //go to create offer
                 node.leave(context, "tr_create_offer");
                 }
                 else{
                 //go to create client
                 node.leave(context, "tr_create_client");
                 }
                 }
                }
                


                Result will be
                INFO [STDOUT] Running on CreateClientAction...
                INFO [STDOUT] ### Running on CreateOfferAction

                • 5. Re: Movo to node
                  kukeltje

                  sorry, then you are on your own... if it works with static true/false, but not with your query, we can't help you

                  • 6. Re: Movo to node
                    jagr

                    I think that i haven't explained very well.

                    In all actions, (static true/false, query result, equals between int, string...) when code execute

                    node.leave(context, "name of transaction");
                    

                    always, the process enter into 2 nodes. Into node that execute code, and other node.
                    In exemple.
                    If I execute node.leave(context, "tr_create_client"); without if, always proces go to node :
                    first: create client node
                    second: create offer node.

                    • 7. Re: Movo to node
                      kukeltje

                      sorry, but to me this does not make it much more clear... make a real unit test with embedded processdefinition (as string) and inner class for action.... then we can have a look

                      • 8. Re: Movo to node
                        jagr

                        Sorry kukeltje.
                        Can you say some link that explain how to make unit test? I've never made it.
                        Thanks!!

                        • 9. Re: Movo to node
                          kukeltje

                          http://www.junit.org/

                          and look at (almost) *all* the testcases in the jbpm source for real jbpm related examples