0 Replies Latest reply on Sep 8, 2006 9:04 AM by John Menke

    Swimland reassignment Example

    John Menke Newbie

      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");
      
      
      
      
       }
      
      }