8 Replies Latest reply on Jun 28, 2007 10:03 AM by cristian_e

    How to use FindTaskInstances in multiple transitions?

    mindthegap

      Hi,

      Im newbie in jBPM and i got a simple question for the experts of this forum. I've got a process definiton like this:

      Start->A
      A->B
      A->C
      B->C
      C->End

      A, B and C are task-nodes with one task each, but its not mandatory (i can change that if you got a solution).

      After that, i want to see in a "pending tasks interface" the work for a certain user (authenticated).

      If i got this users:
      - User1 with permissions to B and C
      - User2 with permissions to C
      - User3 with permissions to A

      Then, when the User3 enters in A, he does A.start() and A.end().:

      After that, the "pending tasks interface" for the users must be:

      - User1: one
      - User2: one
      - User3: none

      Using FindTaskInstances(ActorId) i cannot obtain the task instances because when i do A.end() he jumps to the first transition, in this case to B.

      I read the documentation about the various types of nodes in jBPM, but the decision node and the fork node are not the solutions for my case, because the decision in choose the B or C is made by the user in the interface.

      Can you help me?
      Thanks in advance!!

      RQ_









        • 1. Re: How to use FindTaskInstances in multiple transitions?
          cristian_e

          You could set node A's signalling off. This way it won't signal the token when the taskInstance is end()ed. Then, after the end() you can signal it manually to the correct transition.

          Hope it helps.

          • 2. Re: How to use FindTaskInstances in multiple transitions?
            mindthegap

            Ok, thats right!
            But in this case, findTaskInstances work?

            Thanks!

            • 3. Re: How to use FindTaskInstances in multiple transitions?
              cristian_e

               

              "MindTheGap" wrote:
              Ok, thats right!
              But in this case, findTaskInstances work?

              Thanks!


              findTaskInstances(actorID) shows you just the taskInstances who's actorID equals the parameter and that are currently open (not ended). The actual HQL query been done is:

              select ti
               from org.jbpm.taskmgmt.exe.TaskInstance as ti
               where ti.actorId = :actorId
               and ti.isOpen = true

              (obtained from the source code for TaskMgmtSession and the hibernate.queries.hbm.xml).

              As you can see, it is fairly simple. So, if you have played with signalling and directed the token only to the task nodes you want for that user, only the taskInstances created for him will appear as a result of the findTaskInstances function.

              Of course you have to take into consideration the difference between assigning a single actor to a taskInstance and assigning a group of them by using a pool of actors, which is essentially different. This function only returns the single actor case.

              • 4. Re: How to use FindTaskInstances in multiple transitions?
                jgreiner

                Here is the java code....

                 JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
                 jbpmContext = jbpmConfiguration.createJbpmContext();
                 GraphSession graphSession = jbpmContext.getGraphSession();
                
                 List actors = new Vector(10);
                 actors.add("user1");
                
                 // You can use this method against a group or the getTaskList(String) for a specific user.
                 List<TaskInstance> tasks = jbpmContext.getGroupTaskList(actors);
                
                 for (TaskInstance t : tasks)
                 {
                 // Do whatever you want here.
                 }
                


                • 5. Re: How to use FindTaskInstances in multiple transitions?
                  mindthegap

                  Thanks to all, but not answer my question...

                  In this process:

                  A->B
                  A->C

                  A, B and C are task-nodes with one task each

                  When a user end the task in A, i want that the token stays in A (ok...signaling off).
                  What i want next is that the users that can resume B and C can see in their pending task list interface the B and C tasks...

                  Is this possible with findTaskInstances? or i need to get the leaving transitions collection and collect the tasks manually?



                  Thanks

                  • 6. Re: How to use FindTaskInstances in multiple transitions?
                    kukeltje

                    if the token stays in A there are no tasks in B and C (the tasknodes are not entered yet)

                    • 7. Re: How to use FindTaskInstances in multiple transitions?
                      mindthegap

                      Ok, that's my point!

                      So what type of nodes i must use to have this kind of interface?

                      Fork node? ... using it, the token goes to B and C...and if the user choice B can i suspend/terminate the token in C?

                      Decision node? if the token is in decision node, can i use findTaskInstances method to show pending tasks to the users in the interface?

                      I think this is a important feature that i cannot understand if jBPM supports it or its not possible using jBPM.

                      Thanks to all!

                      • 8. Re: How to use FindTaskInstances in multiple transitions?
                        cristian_e

                         

                        "MindTheGap" wrote:
                        Ok, that's my point!

                        So what type of nodes i must use to have this kind of interface?

                        Fork node? ... using it, the token goes to B and C...and if the user choice B can i suspend/terminate the token in C?

                        Yes, you can. We have done this with the following steps:

                        - Capture the node-enter event for the fork's join. It will be activated when the first subtoken gets to the join.

                        - Set a context variable saying that the first token has arrived to the join. This can be whatever you want.

                        - Using this token, get a reference to all it's siblings (token.getParent().getChildren()).

                        - Cancel or end every sibling. If they are signalling, then at the join node-enter handler you have to check if the variable set when the first one entered is set. If it is, the previous steps should not be done again, and the token has to simply enter the node without doing anything more.

                        For the decision node case there are not subtokens, it's just the root token in this case that get redirected to either path. So you won't have B and C task instances simultaneously created, only one.