Showing posts with label jBPM decision node alternative. Show all posts
Showing posts with label jBPM decision node alternative. Show all posts

Tuesday, October 22, 2013

jBPM Node for Decision using ActionHandler

jBPM use non-decision node to choose workflow path

You can use the decision node to choose one of the workflow path . This is to show a workaround if you have constrains using the decision node.  Shown below simple workflow and can either branch to  "Yes" path or "No" path based on the decision by Node - ValidQuote


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

<process-definition xmlns="" name="Quote Process">


<start-state name="Start">
<transition to="Process Quote"></transition>
</start-state>



<node name="Process Quote">
<action class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
<esbServiceName>
ProcessQuote
</esbServiceName>
<esbCategoryName>
ESB_PROCESS_QUOTE
</esbCategoryName>
</action>
<transition to="ValidQuote"></transition>
</node>

<node name="ValidQuote">
<action name="ValidQuote" class="event.ValidQuote"></action>
<transition to="Log-NotifyCSR" name="No"></transition>
<transition to="EmailCustomer" name="Yes"></transition>
</node>

<node name="EmailCustomer">
<action class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
<esbCategoryName>
ESB_EMAIL
</esbCategoryName>
</action>
<transition to="Complete"></transition>
</node>

<node name="Log-NotifyCSR">
<action class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
<esbCategoryName>
ESB_CSR
</esbCategoryName>
</action>
<transition to="Complete"></transition>
</node>

<end-state name="Complete"></end-state>


</process-definition>



Action Handler ( defined in the ValidQuote)
package event;
import org.jbpm.graph.exe.ExecutionContext;

public class ValidQuote implements ActionHandler {

@Override
public void execute(ExecutionContext execContext) throws Exception {

if( somecondition...)
execContext.leaveNode("Yes");
else
execContext.leaveNode("No");
}

}