8 Replies Latest reply on Jun 9, 2008 6:16 AM by csplrj1

    Does JBPM Supports fully actor based taskList

    csplrj1

      I think I can't understand whether JBPM supports actor based TaskList?

      I have 2 tasks. The First one is assigned to actor "b" and then the next task is assigned to actor "a"

      the process of assigning is through AssignmentHandler
      assignable.setActorId

      After that process is passed from the First Task then I print the count of TasksList of both actor by using

      System.out.println("a1 "+ taskMgmtSession.findTaskInstances("a").size());
      System.out.println("b1 "+ taskMgmtSession.findTaskInstances("b").size());

      The output is
      a1 1
      b1 1

      but the expected output is
      a1 1
      b1 0

      as Now the Second Task is being awaited and only a has been assigned to the Second Task then how can that task be available in actor "b" 's Task List


      Does JBPM supports fully actor based Tasks?

      Thanks in advance

      CSJakharia

        • 1. Re: Does JBPM Supports fully actor based taskList
          johan.parent

          Hi,

          What's your process definition? Is that task assigned to "b" not just a left over from a previous/other process instance?

          Because the answer to your question is otherwise YES :)

          Best regards,

          Johan

          • 2. Re: Does JBPM Supports fully actor based taskList
            csplrj1

            The files as per below

            Thanks in advance

            CSJakharia

            processdefinition.xml

            <?xml version="1.0" encoding="UTF-8"?>
            
            <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="authoring">
             <start-state name="start-state1">
             <task>
             </task>
             <transition to="task1"></transition>
             </start-state>
            
            
             <task-node name="task1">
             <description>
             task1
             </description>
             <task>
             <assignment class="com.workflow.AssignTask"></assignment>
             </task>
             <transition to="task2"></transition>
             </task-node>
            
             <task-node name="task2">
             <description>
             task2
             </description>
             <task>
             <assignment class="com.workflow.AssignTask1"></assignment>
             </task>
             <transition to="end"></transition>
             </task-node>
            
             <node name="end">
             <action class="com.workflow.HandleAction"> </action>
             <transition to="end-state1"></transition>
             </node>
            
            
             <end-state name="end-state1">
            
             </end-state>
            
            
            </process-definition>



            AssignTask.java
            public class AssignTask implements AssignmentHandler {
            
             public void assign(Assignable assignable, ExecutionContext executionContext)
             throws Exception {
             // TODO Auto-generated method stub
             assignable.setActorId("b");
             }
            
            }


            AssignTask1.java
            public class AssignTask1 implements AssignmentHandler {
            
             public void assign(Assignable assignable, ExecutionContext executionContext)
             throws Exception {
             // TODO Auto-generated method stub
             assignable.setActorId("a");
             }
            
            }




            Test.java
            import java.io.FileInputStream;
            import java.io.FileNotFoundException;
            import java.util.Set;
            
            import org.jbpm.JbpmConfiguration;
            import org.jbpm.JbpmContext;
            import org.jbpm.db.GraphSession;
            import org.jbpm.db.TaskMgmtSession;
            import org.jbpm.graph.def.ProcessDefinition;
            import org.jbpm.graph.exe.ProcessInstance;
            import org.jbpm.graph.exe.Token;
            import org.jbpm.taskmgmt.exe.PooledActor;
            import org.jbpm.taskmgmt.exe.TaskInstance;
            
            public class Test {
             static JbpmConfiguration jbpmConfiguration = null;
            
             public static void deployProcessDefinition()
             {
             try {
             ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(new FileInputStream("D:\\Cobra\\workspace\\WorkFlowAuthoringPOC\\src\\main\\jpdl\\authoring\\processdefinition.xml"));
             JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
             jbpmContext.deployProcessDefinition(processDefinition);
             jbpmContext.close();
             } catch (FileNotFoundException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
             }
             }
            
             /**
             * @param args
             */
             public static void main(String[] args) {
             // TODO Auto-generated method stub
             try {
             jbpmConfiguration = JbpmConfiguration.parseInputStream(new FileInputStream("D:\\Cobra\\workspace\\WorkFlowAuthoringPOC\\src\\main\\config\\jbpm.cfg.xml"));
             jbpmConfiguration.createSchema();
             deployProcessDefinition();
             JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
             System.out.println("jbpmContext.getActorId() "+jbpmContext.getActorId());
             GraphSession graphSession = jbpmContext.getGraphSession();
             ProcessDefinition processDefinition =
             graphSession.findLatestProcessDefinition("authoring");
             ProcessInstance processInstance = new ProcessInstance(processDefinition);
             Token token=processInstance.getRootToken();
             // Let's start the process execution, leaving the start-state
             // over its default transition.
             token.signal();
             TaskInstance taskInstance = (TaskInstance)
             processInstance
             .getTaskMgmtInstance()
             .getTaskInstances()
             .iterator().next();
            
             System.out.println("size "+processInstance.getTaskMgmtInstance().getTaskInstances().size());
             System.out.println("taskInstance.getActorId() " +taskInstance.getActorId());
             System.out.println("taskInstance.getPooledActors() " +taskInstance.getPooledActors());
             TaskMgmtSession taskMgmtSession= jbpmContext.getTaskMgmtSession();
             System.out.println(taskMgmtSession.findPooledTaskInstances("a").size());
             System.out.println(taskMgmtSession.findPooledTaskInstances("b").size());
             ((TaskInstance)taskMgmtSession.findTaskInstances("b").get(0)).getToken().signal();
             System.out.println("a1 "+ ((TaskInstance)taskMgmtSession.findTaskInstances("a").get(0)).getToken().getNode().getName());
             System.out.println("b1 "+ ((TaskInstance)taskMgmtSession.findTaskInstances("b").get(0)).getToken().getNode().getName());
             System.out.println("a1 "+ taskMgmtSession.findTaskInstances("a").size());
             System.out.println("b1 "+ taskMgmtSession.findTaskInstances("b").size());
             System.out.println("c1 "+ taskMgmtSession.findTaskInstances("c").size());
            
             } catch (FileNotFoundException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
             }
             }
            
            }
            


            • 3. Re: Does JBPM Supports fully actor based taskList
              kukeltje

              first of all, ditch ALL the system.out.* and replace them with asserts, so make a REAL unittest.... much clearer then to show us what you expect.

              Second, you signal the token, not end the task so it stays there.... So a1 1, b1 1 is what I expect

              • 4. Re: Does JBPM Supports fully actor based taskList
                csplrj1

                I tried ((TaskInstance)taskMgmtSession.findTaskInstances("b").get(0)).getToken().end();
                instead of
                ((TaskInstance)taskMgmtSession.findTaskInstances("b").get(0)).getToken().signal();

                but then the result comes as
                a1 0
                b1 1

                What I require is that the task should be proceeded and as the second task is assigned to Actor "a" then the result should come something like this

                a1 1
                b1 0


                Thanks in advance

                CSJakharia

                • 5. Re: Does JBPM Supports fully actor based taskList
                  rbradwell

                  Just out of interest assume his taskNodes had a few transitions and he has transitioned to the second task node, resulting in both task being open as below. Then what would happen if he signalled the first task over a transition, is that possible? There are two tasks but only one token.

                  • 6. Re: Does JBPM Supports fully actor based taskList
                    csplrj1

                    I solved the issue. Actually I was putting an end to Token instead of TaskInstance due to which whole ProcessInstance was closed

                    Finally I am able to solve the issue

                    Thanks for that

                    CSJakharia

                    • 7. Re: Does JBPM Supports fully actor based taskList
                      kukeltje

                      that's what I said in my post.... ending tasks, not ending (or signalling) tokens

                      • 8. Re: Does JBPM Supports fully actor based taskList
                        csplrj1

                        Yes your statement was proper but somehow i missed the meaning. That's my fault

                        Thanks for the help kukeltje

                        CSJakharia