4 Replies Latest reply on Apr 23, 2008 4:29 PM by kukeltje

    Very Simple Swimlane......help!

    francis1970

      Hi all Jbpm users,
      I have a simple process with 2 Task. Every Task has the same assignment class (assignment.AssignTask) which needs to know what kind of user is in charge to execute the Task.

      <?xml version="1.0" encoding="UTF-8"?>
      
      <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="Gap">
       <swimlane name="buyer" />
       <swimlane name="seller" />
      
      
      <start-state name="start">
       <transition to="buyItems"></transition>
      </start-state>
      
      <task-node name="buyItems">
      
       <task name="TaskBuyItems" swimlane="buyer">
       <assignment class="assignment.AssignTask" />
       </task>
       <transition to="sellItems"></transition>
      </task-node>
      
      <task-node name="sellItems">
      
       <task name="TaskSellItems" swimlane="seller">
       <assignment class="assignment.AssignTask" />
       </task>
       <transition to="end"></transition>
      </task-node>


      As you can see the swimlane is just a flag....inside the AssignTask class I look for buyers and sellers list....

      The problem is that I cannot read the value of the Swimlane inside the assignment.AssignTask class...

      public void assign(Assignable arg, ExecutionContext arg1) throws Exception {
      
       SwimlaneInstance swim = arg1.getTaskInstance().getSwimlaneInstance(); // RETURNS NULL
      
       String actorId = arg1.getTaskInstance().
       getActorId(); // ALSO THIS RETURNS NULL
       }


      Do I need to set up users/groups on the database in order to use swimlanes ? In this case the users/groups check-up has been already done by the web application, so I only need somehow to read the swimlane in the Task Assignment class....

      Any help ?
      Thanks


        • 1. Re: Very Simple Swimlane......help!
          salaboy21

          I think you must think the problem with this thought in mind...
          remember that you have to things called task (Task-Node and Task)
          Other thing that you must remember is the TaskMgmtInstance class..
          that lets you Manage all your task instances. So
          i think the following lines of code makes you clear what i'm talking about:


          TaskMgmtInstance taskMgmtInstance = processInstance.getTaskMgmtInstance();
          String actorId=taskMgmtInstance.getSwimlaneInstance("boss").getActorId();
          


          • 2. Re: Very Simple Swimlane......help!
            francis1970

            Hi thanks a lot for your reply. I made confusion between Task instance and Task management Instance

            Map map = arg1.getTaskMgmtInstance().getSwimlaneInstances();
            Set set = map.keySet();
            Iterator iter = set.iterator();
             while (iter.hasNext()) {
             String key = (String)iter.next();
             SwimlaneInstance swim = (SwimlaneInstance)map.get(key);
             // This returns "buyer" or "seller" depending on the
             // Task
             System.out.println("name " +swim.getName());
             }


            Now I know in which swim lane I am swimming :-)
            Thanks!
            Francesco

            • 3. Re: Very Simple Swimlane......help!
              salaboy21

              you're welcome!!!
              Keep coding!

              • 4. Re: Very Simple Swimlane......help!
                kukeltje

                you could also put the assignmenthandler IN the swimlane... much cleaner and no duplication, just pointing to the swimlane in a task