[jboss-user] [JBoss jBPM] - Problem with Tax Node

prajatna do-not-reply at jboss.com
Mon Aug 3 03:55:58 EDT 2009


Hi,
  I have a task node with two transitions and a task attached to it.The code is as follows..

  | <task-node name="HOD_Approval">
  |     <event type="node-enter">
  | 	<action class="com.sample.action.ProcessAction" accept-propagated-events="false"></action>
  |     </event>
  |     <transition to="Finance_Approval" name="Accepted"></transition>
  |     <transition to="end-state" name="Denied"></transition>
  | </task-node>
Inside ProcessAction class I am accepting the decision from user and want to go to the next transition accordingly..

  | public class ProcessAction implements ActionHandler  {
  | 
  | 	private static final long serialVersionUID = 1L;
  | 
  | 	public void execute(ExecutionContext executionContext) throws Exception {		System.out.println("######################---------ProcessAction------------1-----------------###################### .");
  | 		System.out.println("This Node is---"+executionContext.getNode().getName());
  | 		System.out.print("Enter your decission: ");	      
  | 	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  | 	    
  | 	    String decission = null;
  | 	    try {
  | 	    	decission = br.readLine();
  | 	    } catch (IOException ioe) {
  | 	       System.out.println("IO error trying to read your decission!");	       
  | 	    }
  | 	    System.out.println("Thanks for the desission, " + decission);
  | 	    System.out.println("######################---------ProcessAction------------2-----------------###################### .");
  | 	    if(decission != null && decission.equalsIgnoreCase("a")){
  | 	    	
  | 	    	System.out.println("######################---------ProcessAction----a--------3-----------------###################### .");
  | 	    	executionContext.getTaskInstance().end("Accepted");
  | 	    }
  | 	    else if(decission != null && decission.equalsIgnoreCase("d")){
  | 	    	
  | 	    	System.out.println("######################---------ProcessAction-----d-------3-----------------###################### .");
  | 	    	executionContext.leaveNode("Denied");
  | 	    }
  | 	    else if(decission != null && decission.equalsIgnoreCase("c")){
  | 	    	System.out.println("######################---------ProcessAction-----c-------3-----------------###################### .");
  | 	    	
  | 	    	executionContext.leaveNode("checkBudget");
  | 	    }
  | 	    else{
  | 	    	System.out.println("Error trying to read your decission!..Enter only a/d ");	
  | 	    }
  | 		
  | 	}
  | }
  | 


With this the flow is navigating correctly to the next node as per the decision, But after reaching end -state , again the process is selecting a default transition ..where as it should stop, at end node..

The class I am using to invoke the jBPM is as follows..


  | public class TravelProcessTest extends TestCase  {
  | 	
  | 	public static void main(String args[])throws Exception {
  | 		new TravelProcessTest().execute();
  | 	}
  | 	public void execute() throws Exception {
  | 		JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
  | 		JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  | 		
  | 		// Extract a process definition from the processdefinition.xml file.
  | 		ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("simple/processdefinition.xml");
  | 		//HashMap map = new HashMap();
  | 
  | 		//map.put("travelDate",new Integer(100)); 
  | 		//map.put("travelPeriod",new Integer(50));
  | 
  | 		//Create an instance of the process definition.
  | 		//ProcessInstance instance = new ProcessInstance(processDefinition,map);
  | 		ProcessInstance instance = new ProcessInstance(processDefinition);
  | 		System.out.println("--------------------1-----------------######### ."); 
  | 		displayStatus(instance);
  | 		System.out.println("---------------------2-----------------########## .");
  | 		instance.signal();
  | 		
  | 		System.out.println("---------------------3-----------------###########.");
  | 		displayStatus(instance);
  | 		System.out.println("---------------------4-----------------###########.");
  | 		instance.end();
  | 		
  | 		
  | 	}
  | 
  | 	private void displayStatus(ProcessInstance instance) {   
  | 		String nodeName = instance.getRootToken().getNode().getName();   
  | 		System.out.println("You are now in node: "+nodeName);   
  | 
  | 	}
  | }
  | 
  | 
  | 


Can you please suggest what is going wrong.. so that even after reaching end state , the process is again propagating to another transition..




View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4247506#4247506

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4247506



More information about the jboss-user mailing list