JBoss Community

Re: Jump to end state from Node

created by Sasi R in jBPM Development - View the full discussion

Martin,

Thanks a lot for replying in detail

 

We have below process definition which has Node-Enter action as shown below. As soon as we start the process it will go to Node1 and from there we want to control the execution (Jump to End state by avoid execution of Node2/Node3. However in some scenarios we want to Jump to Node3)

 

But following code is not working as expected and its always executing all the nodes.

 

public class AutomationHandler implements ActionHandler {

public void execute(ExecutionContext executionContext) throws Exception

      {

                 

              System.out.println(new Date()+"Inside AutomationHandler::execute()");

             

                    System.out.println("########Going to End State###########");

                          EndState endState = (EndState)executionContext.getNode().getProcessDefinition().getNode("end-state");

                          Token token  = executionContext.getToken();

  token.setNode(endState);

 

                          //token.signal("trans4");

                          //token.end();

                             

  System.out.println(new Date()+"Inside AutomationHandler::execute()");

 

}

}

 

 

Process definition xml

********************************

<?xml version="1.0" encoding="UTF-8"?>

<process-definition  xmlns="urn:jbpm.org:jpdl-3.2"  name="automationtest">

<description>
  automationtest
</description>


<start-state name="start-state">
  <transition to="node1" name="trans1"></transition>
  <event type="process-start">
   <script name="Allocation Event Started">
    System.out.println(&quot;Event Creation Started &quot;+node);
   </script>
  </event>
</start-state>


<node name="node1">
  <event type="node-enter">
   <action class="com.citi.automation.build.jbpm.handler.AutomationHandler">
    <unixCommand>
     echo &quot;Hello World&quot;
    </unixCommand>
    <expectedRetunCodes>
     A,B,C
    </expectedRetunCodes>
    <successCondition>
     ExecuteCommand2
    </successCondition>
    <errorCondition>
     End
    </errorCondition>
   </action>
  </event>
  <transition to="node2" name="trans2"></transition>
  <transition to="end-state" name="trans4"></transition>
</node>

<node name="node2">
  <event type="node-enter">
   <action class="com.citi.automation.build.jbpm.handler.AutomationHandler">
    <unixCommand>
     echo &quot;sleeping&quot;; sleep 60
    </unixCommand>
    <expectedRetunCodes>
     A,D,E
    </expectedRetunCodes>
    <successCondition>
     ExecuteCommand3
    </successCondition>
    <errorCondition>
     End
    </errorCondition>
   </action>
  </event>
  <transition to="node3" name="trans3"></transition>
</node>

<node name="node3">
  <event type="node-enter">
   <action class="com.citi.automation.build.jbpm.handler.AutomationHandler">
    <unixCommand>
     echo &quot;Working&quot;
    </unixCommand>
    <successCondition>
     ExecuteCommand4
    </successCondition>
    <expectedRetunCodes>
     A,B,C
    </expectedRetunCodes>
    <errorCondition>
     End
    </errorCondition>
   </action>
  </event>
  <transition to="end-state" name="trans4"></transition>
</node>


<end-state name="end-state">
  <event type="process-end">
   <script name="Event End">
    System.out.println(&quot;Event End &quot;+node);
   </script>
  </event>
</end-state>

</process-definition>

********************************

Reply to this message by going to Community

Start a new discussion in jBPM Development at Community