[jboss-user] [JBoss jBPM] - Swimland reassignment Example

jmjava do-not-reply at jboss.com
Fri Sep 8 09:04:58 EDT 2006


I recently figured out how to reassign swimlanes for a processInstance and thought an example might help others

Note: the assignments are currently hardcoded but a more production capable version of this Action could be designed that retrieves a processInstance varaible, possibly a hashMap and iterates over the key value pairs assigning the value to swimlane (key).

Any thoughts on the code?  I had to do the Session.save(swimlane) in order to get it to work.  Anyone see any problems with this?



  | 
  | package test;
  | 
  | import org.hibernate.Session;
  | import org.jbpm.JbpmConfiguration;
  | import org.jbpm.JbpmContext;
  | import org.jbpm.graph.def.ActionHandler;
  | import org.jbpm.graph.exe.ExecutionContext;
  | import org.jbpm.taskmgmt.def.Swimlane;
  | import org.jbpm.taskmgmt.exe.SwimlaneInstance;
  | 
  | public class SwimlaneReassignmentAction implements ActionHandler {
  | 
  | 	public void execute(ExecutionContext executionContext) throws Exception {
  | 		
  | 		
  | 		Session hibSession = executionContext.getJbpmContext().getSession();
  | 		
  | 		executionContext.getContextInstance().getProcessInstance()
  | 				.getTaskMgmtInstance().getSwimlaneInstance("buyer").setActorId(
  | 						"test8");
  | 		executionContext.getContextInstance().getProcessInstance()
  | 				.getTaskMgmtInstance().getSwimlaneInstance("salesman")
  | 				.setActorId("test7");
  | 		try {
  | 			executionContext.getContextInstance().getProcessInstance()
  | 					.getTaskMgmtInstance().getSwimlaneInstance("accountant")
  | 					.setActorId("test6");
  | 		} catch (Exception e) {
  | 			Swimlane sl = new Swimlane("accountant");
  | 			hibSession.save(sl);
  | 			SwimlaneInstance sli = new SwimlaneInstance(sl);
  | 			sli.setActorId("test6");
  | 			hibSession.save(sli);
  | 			
  | 			executionContext.getContextInstance().getProcessInstance()
  | 					.getTaskMgmtInstance().addSwimlaneInstance(sli);
  | 			
  | 			
  | 		}
  | 
  | 		try {
  | 
  | 			executionContext.getContextInstance().getProcessInstance()
  | 					.getTaskMgmtInstance().getSwimlaneInstance("shipper")
  | 					.setActorId("test5");
  | 
  | 		} catch (Exception e) {
  | 
  | 			Swimlane sl = new Swimlane("shipper");
  | 			hibSession.save(sl);
  | 			SwimlaneInstance sli = new SwimlaneInstance(sl);
  | 			sli.setActorId("test5");
  | 			hibSession.save(sli);
  | 			
  | 			executionContext.getContextInstance().getProcessInstance()
  | 					.getTaskMgmtInstance().addSwimlaneInstance(sli);
  | 		}
  | 		
  | 		
  | 		// propogate the token through the transition on this node
  | 		
  | 		
  | 		
  | 		executionContext.getNode().leave(executionContext, "evaluate web order");
  | 		
  | 	
  | 		
  | 
  | 	}
  | 
  | }
  | 

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

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



More information about the jboss-user mailing list