[jboss-user] [JBoss jBPM] - How to design a Task Node with two Transition?

prajatna do-not-reply at jboss.com
Tue Aug 4 01:16:30 EDT 2009


  I have a task node (Ex. PM_Approval) in the process definition. There are two transitions associated with this node called "Accepted" & "Denied" . The Accepted transition connects to another Task Node "HOD_Approval" .And the Denied ends up with end-state....... The selection of transition should base on the decision , given by user in the action class.(ProcessAction in my design...given below.)

Now how to design this .. I tried with the following , but problem is that, when ever it goes to end state by selecting Reject transition, it is again begins from the current Node.  

Please suggest....what is going wrong.. with my design..


Processdefinition.xml 

  | 	<start-state name="start">
  | 		<transition to="PM_Approval" name="Test"></transition>
  | 	</start-state>
  | 
  | 
  | 	<task-node name="PM_Approval" >		
  | 		<event type="node-enter">
  | 			<action class="com.sample.action.ProcessAction">				
  | 			</action>
  | 		</event>
  | 		<transition to="HOD_Approval"></transition>
  | 		<transition to="end-state" name="Denied"></transition>	
  | 	</task-node>



ProcessAction.java


  | 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());
  | 			
  | 		String decission = null;
  | 		
  | 		System.out.print("Enter your decission: ");	
  | 	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  | 	    
  | 	   
  | 	    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.leaveNode("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 ");	
  | 	    }
  | 		
  | 	}
  | }
  | 


Java class I am using to invoke the process...( TravelProcessTest.java)


  | public class TravelProcessTest extends TestCase  {
  | 	
  | 	public static void main(String args[])throws Exception {
  | 		new TravelProcessTest().execute();
  | 	}
  | 	public void execute() throws Exception {
  | 		
  | 
  | 		
  | 		// Extract a process definition from the processdefinition.xml file.
  | 		ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("simple/processdefinition.xml");
  | 
  | 		ProcessInstance(processDefinition,map);
  | 		ProcessInstance instance = new ProcessInstance(processDefinition);
  | 		
  | 		System.out.println("Hi............");
  | 		
  | 		System.out.println("######################---------------------1-----------------###################### ."); 
  | 		
  | 
  | 		
  | 		instance.signal();
  | 		
  | 		System.out.println("######################---------------------3-----------------###################### .");
  | 		displayStatus(instance);
  | 		System.out.println("######################---------------------4-----------------###################### .");
  | 		);
  | 		
  | 		
  | 	}
  | 
  | 	private void displayStatus(ProcessInstance instance) {   
  | 		String nodeName = instance.getRootToken().getNode().getName();   
  | 		System.out.println("You are now in node: "+nodeName);
  | 	}
  | 
  | 	}
  | }

Console O/P


  | 10:37:23,038 [main] INFO  JbpmConfiguration : using jbpm configuration resource 'jbpm.cfg.xml'
  | 10:37:23,038 [main] DEBUG JbpmConfiguration : loading defaults in jbpm configuration
  | 10:37:23,128 [main] DEBUG ObjectFactoryImpl : adding object info 'default.jbpm.context'
  | 10:37:23,128 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.hibernate.cfg.xml'
  | 10:37:23,128 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.business.calendar'
  | 10:37:23,128 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.default.modules'
  | 10:37:23,128 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.converter'
  | 10:37:23,128 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.action.types'
  | 10:37:23,128 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.node.types'
  | 10:37:23,149 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.parsers'
  | 10:37:23,149 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.varmapping'
  | 10:37:23,149 [main] DEBUG ObjectFactoryImpl : adding object info 'resource.mail.templates'
  | 10:37:23,159 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.byte.block.size'
  | 10:37:23,159 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.task.instance.factory'
  | 10:37:23,159 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.variable.resolver'
  | 10:37:23,159 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.mail.smtp.host'
  | 10:37:23,159 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.mail.address.resolver'
  | 10:37:23,159 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.mail.from.address'
  | 10:37:23,169 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpm.job.executor'
  | 10:37:23,169 [main] DEBUG JbpmConfiguration : loading specific configuration...
  | 10:37:23,179 [main] DEBUG ObjectFactoryImpl : adding object info 'jbpmConfiguration'
  | 10:37:23,179 [main] INFO  StaleObjectLogConfigurer : stale object exceptions will be hidden from logging
  | 10:37:23,289 [main] DEBUG JpdlParser$JpdlEntityResolver : resolving schema reference publicId(null) systemId(http://jbpm.org/jpdl-3.2.xsd)
  | 10:37:23,289 [main] DEBUG JpdlParser$JpdlEntityResolver : providing input source to local 'jpdl-3.2.xsd' resource
  | 10:37:23,460 [main] DEBUG NodeTypes : node 'page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded
  | 10:37:23,460 [main] DEBUG NodeTypes : node 'start-page' will not be available. class 'org.jboss.seam.pageflow.Page' couldn't be loaded
  | 10:37:23,520 [main] DEBUG GraphElement : event 'process-start' on 'ProcessDefinition(processdefinition)' for 'Token(/)'
  | Hi............
  | ######################---------------------1-----------------###################### .
  | ######################---------------------2-----------------###################### .
  | 10:37:23,530 [main] DEBUG GraphElement : event 'before-signal' on 'StartState(start)' for 'Token(/)'
  | 10:37:23,530 [main] DEBUG GraphElement : event 'node-leave' on 'StartState(start)' for 'Token(/)'
  | 10:37:23,530 [main] DEBUG GraphElement : event 'transition' on 'Transition(Test)' for 'Token(/)'
  | 10:37:23,530 [main] DEBUG GraphElement : event 'node-enter' on 'TaskNode(PM_Approval)' for 'Token(/)'
  | 10:37:23,530 [main] DEBUG GraphElement : executing action 'Action(1efb836)'
  | 10:37:23,530 [main] DEBUG Token : token[0] is locked by token[0]
  | ######################---------ProcessAction------------1-----------------###################### .
  | This Node is---PM_Approval
  | Enter your decission: d
  | Thanks for the desission, d
  | ######################---------ProcessAction------------2-----------------###################### .
  | ######################---------ProcessAction-----d-------3-----------------###################### .
  | 10:37:34,071 [main] DEBUG GraphElement : event 'node-leave' on 'TaskNode(PM_Approval)' for 'Token(/)'
  | 10:37:34,071 [main] DEBUG GraphElement : event 'transition' on 'Transition(Denied)' for 'Token(/)'
  | 10:37:34,071 [main] DEBUG GraphElement : event 'node-enter' on 'EndState(end-state)' for 'Token(/)'
  | 10:37:34,071 [main] DEBUG GraphElement : event 'process-end' on 'ProcessDefinition(processdefinition)' for 'Token(/)'
  | 10:37:34,071 [main] DEBUG Token : token[0] is unlocked by token[0]
  | 10:37:34,071 [main] DEBUG GraphElement : event 'node-leave' on 'TaskNode(PM_Approval)' for 'Token(/)'
  | 10:37:34,071 [main] DEBUG GraphElement : event 'transition' on 'Transition(cec0c5)' for 'Token(/)'
  | 10:37:34,071 [main] DEBUG GraphElement : event 'node-enter' on 'TaskNode(HOD_Approval)' for 'Token(/)'
  | 10:37:34,071 [main] DEBUG GraphElement : executing action 'Action(116ab4e)'
  | 
  | 

As you can see, even when decision is denied , it is going to end state.. but again coming to next node...

Thanks in advance for your suggestion..

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

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



More information about the jboss-user mailing list