1 2 3 Previous Next 33 Replies Latest reply on Apr 24, 2007 8:41 AM by shirodkar4

    Assign a task to 2 users, how please?

    boerse

      Hello, i've searched the forum and i found no successful result: is there anyway to assign a single task to 2 users? I tried via assignment expression, pooled-actors, etc, etc. Just a clue how to assign a single tasz in the way to 2 users:

      <task swimlane="buyer" name="task1">
       <controller>
       <variable name="var1" access="read"/>
       <variable name="var1" access="read"/>
       <variable name="var3" access="read"/>
       </controller>
       </task>
      


      Thanks... a lot!

        • 1. Re: Assign a task to 2 users, how please?
          mennen

          i tried several ways but it never worked out either.

          Would appreciate it a lot if someone gave us an example as to how to assign a task to 2 users..

          Thanks,

          • 2. Re: Assign a task to 2 users, how please?
            boerse

            hi mennen!

            Nice to read you, i know you had the same problem and we never found a solution, hope anyone helps (it there is a solution). I think it's something very usefull for all us...

            P.s. how's your develop going?

            • 3. Re: Assign a task to 2 users, how please?
              mennen

              Hey boerse!

              i'm getting to know jbpm little by little, i think it it's really powerful if you master most of it..

              I solved many problems by myself, but it's really time-consuming though..

              hope your development's doing well too.

              • 4. Re: Assign a task to 2 users, how please?
                boerse

                :)

                So do i, and i agree with you: superpowerful but time consuming. My develop is currently stoped because 2 related problems (one of them is multiuser assignment) and how to end a task. If you (or someone) needs help, if i know, i'll be pleased to help...

                Hope someone can help us with this assignment... a simple working-example would save my life.

                • 5. Re: Assign a task to 2 users, how please?
                  forjbpm

                  Hey!
                  I am in too!!! :-(

                  • 6. Re: Assign a task to 2 users, how please?
                    boerse

                    What a shock, i thought i had an answer... :(
                    We can organize a club...
                    To the other users: PLEASE HELP!

                    My mail (to colaborate) speichre at gmail dot com

                    • 7. Re: Assign a task to 2 users, how please?
                      fmuhlenberg

                      For your 2 user task assignment, why not create two tasks so there is a 1:1 relationship between a task and user. When one task is completed, you could always programatically check -- you have to write an action class anyway, the other task and end it if desired.
                      -fm

                      • 8. Re: Assign a task to 2 users, how please?
                        boerse

                        Hello fmuhlenberg!

                        Thank you for the response. I'm already trying to to as you say, but i have a problem: (correct me if i'm wrong): in a task node with 2 (or more) tasks you can only assign an action (per task) under the event "task-end" (ok, task-start ok, but it's too early), so if i want only ONE of the tasks to be executed before leaving the node, you can program the attribute "first", but the problem i have is that i have to "programatically" check and "kill" the pending tasks and that implies always that when the task is ended (or cancelled), the default transition is taken for each of the tasks, so if i want to confirm an order (for example), it'll be twice confirmed as the first task is ended by the user and the second is ended by the oder task. So I think i'd be perfect if I could simply assign a task to 2 users...

                        I hope with everyone's help we can solve this problem for all the forum.

                        • 9. Re: Assign a task to 2 users, how please?
                          enazareno

                          Hi boerse,

                          From what i understand of task assigned to pooled actors, only one actor can accomplish the task, but that user must belong to the pooled actors set. So if you check the actorid when a task is assigned to a pooled actor, the value is null. So its a first come first serve.

                          If you want to have concurrent tasks and you dont want it to continue unless all actors assigned to it have accomplished, then make the tasks blocking. I hope this helps.

                          Regards,

                          Elmo

                          • 10. Re: Assign a task to 2 users, how please?
                            boerse

                            Hi Elmo,

                            "enazareno" wrote:

                            From what i understand of task assigned to pooled actors, only one actor can accomplish the task, but that user must belong to the pooled actors set. So if you check the actorid when a task is assigned to a pooled actor, the value is null. So its a first come first serve.

                            That's exactly what i think we all want, and i don't mind if the actor-id is null when i read the assignation-message, but the point is that when i login as one of the users that *should* be able to access and make the task (in an appl like websale) but he has no pending tasks. I wrote my own assignment handler to create a string[] of actors separated with , but it doesn't work in my case. I tried also with the classical expression previous--group(group_type)-->member(boss) i thought so I could have at least 2 users (previous and the boss, but nope).

                            "enazareno" wrote:

                            If you want to have concurrent tasks and you dont want it to continue unless all actors assigned to it have accomplished, then make the tasks blocking. I hope this helps.


                            I want exactly the other behaviour, that is: keep on the flow when the first possible actor ends the task. As I said, that's possible with the attribute signal="first-wait" and end-tasks="true" but the point is that not only the ended task takes his transition but the by the system terminated task takes its default-transition and because of that i make twice the same operation (if the by the user make task took the same transition) or i make once a task i shouldn't do because this auto-transition should never be taken. I don't know if I have explained myself. It's still early in the morning :p

                            • 11. Re: Assign a task to 2 users, how please?
                              enazareno

                              Hi boerse,

                              As for my case, to get the pending tasks for pooled actors, I did not go via hibernate, i used plain jdbc (for some reasons). BTW, when signalling tasks, you can specify particular transitions. Example if the system ends the task, it can signal the task with a specific transition so that you can differentiate if a person has ended it.

                              If you can give me a concrete example, maybe I can contribute some input. It's already nighttime here, so maybe I can send a reply in the morning.

                              Regards,

                              Elmo

                              • 12. Re: Assign a task to 2 users, how please?
                                boerse

                                Hi Elmo, thank you for your quick reply:

                                My code is more or less:

                                <task-node name="order" create-tasks="true" signal="last">
                                 <task swimlane="admin" name="Control">
                                 <controller>
                                 <variable name="var1" access="read"/>
                                 <variable name="var2" access="read"/>
                                 </controller>
                                 <event type="task-end">
                                 <action class="org.jbpm.example.endTasks"/>
                                 </event>
                                 </task>
                                 <task swimlane="buyer" name="Buyer-control">
                                 <controller>
                                 <variable name="var1" access="read"/>
                                 <variable name="var2" access="read"/>
                                 </controller>
                                 <event type="task-end">
                                 <action class="org.jbpm.example.endTasks"/>
                                 </event>
                                 </task>
                                
                                 <transition name="Confirm" to="confirmed"/>
                                 <transition name="Cancel" to="cancel" />
                                
                                 </task-node>
                                


                                and the action something like:

                                package org.jbpm.example;
                                
                                import org.apache.commons.logging.Log;
                                import org.apache.commons.logging.LogFactory;
                                import org.jbpm.graph.def.ActionHandler;
                                import org.jbpm.graph.exe.ExecutionContext;
                                import org.jbpm.graph.exe.Token;
                                import org.jbpm.taskmgmt.exe.TaskInstance;
                                import java.util.Collection;
                                import java.util.*;
                                
                                public class endTasks implements ActionHandler {
                                
                                 private static final long serialVersionUID = 1L;
                                
                                 String swimlaneName;
                                
                                 public void execute(ExecutionContext executionContext) throws Exception {
                                
                                 Token token = executionContext.getToken();
                                 log.info("###############################################");
                                 log.info("### TASKS-TERMINATOR ");
                                 log.info("###############################################");
                                 log.info(" !"+executionContext.getTaskMgmtInstance().hasUnfinishedTasks(token)+" ");
                                
                                 TaskInstance ti= executionContext.getTaskInstance();
                                
                                 Collection tasks = executionContext.getTaskMgmtInstance().getUnfinishedTasks(token);
                                 Iterator taskItr = tasks.iterator();
                                 while(taskItr.hasNext()) {
                                 TaskInstance ti2 = (TaskInstance)taskItr.next();
                                 if (ti2!=ti) {
                                 if(!ti2.hasEnded() && !ti2.isCancelled()) {
                                 ti2.getContextInstance().createVariable("Ended by", "Class");
                                 ti2.setSignalling(false);
                                 ti2.cancel();
                                 }
                                 }
                                 else {
                                 ti.getContextInstance().createVariable("Ended by", "Class");
                                 }
                                 }
                                
                                
                                ti.end();
                                
                                
                                 private static final Log log = LogFactory.getLog(terminarTareas.class);
                                }
                                


                                I have also a timer in the process (in that task-node) but i don't have problems with it. The main point is that tasks always take their default transition (confirm in my case) and i don't want to execute twice the same action in that node. Now i'm trying to define a new default transition to a nop but it always appear as a button and i don't want the user to have this possibility. How do yo make to see how the task ended? do you distinguish between user and system ended tasks?

                                Thank you for your help. I didn't put my code in the first posts as i don't want to solve MY particular problem (although of course i want) but solve it as a general rule not only for me but for many other users of this forum who also have this problem.


                                • 13. Re: Assign a task to 2 users, how please?
                                  enazareno

                                  Hi boerse,

                                  The main point is that tasks always take their default transition (confirm in my case) and i don't want to execute twice the same action in that node.


                                  If you want to end tasks that goes to a certain transition, if I remember, you can signal it this way (make it a signalling task so when it signals it also ends the task)

                                  TaskInstance ti= executionContext.getTaskInstance();
                                  ti.end( transitionName );
                                  


                                  I assume you want to have a task to be done by somebody, like approving an order for example. If for some pre-determined time he does not accomplish, you want the system to do something. Is this the correct assumption? If this is the case, I would suggest to have only one task to keep things simple and add a timer to cancel that task if it has elapsed some period. If you want to have two or more users being able to carry the same task, first-come-first-serve, then add those users in a group and specify it in the swimlane, like so:

                                   <swimlane name="approver">
                                   <assignment expression="group(groupname)"/>
                                   </swimlane>
                                  


                                  and your task (This simply means anybody from the group can take on the task. In this example, the "system" must be a member of the group. btw, I have not tested the timer part but I think it should work):
                                   <task-node name="order" create-tasks="true">
                                   <timer duedate="3 business hours">
                                   <script>
                                   taskInstance.setActorId( "system" );
                                   taskInstance.end( "cancel" );
                                   </script>
                                   </timer>
                                   <task name="Approve-Order" swimlane="approver"/>
                                   <transition name="Approve" to="approve" />
                                   <transition name="Cancel" to="cancel" />
                                   </task-node>
                                  


                                  There are many ways how to to do it, so unless I know what you want to accomplish (real world example and not code), maybe I can add some input. If this code does not work tell me. I did not have time to test this and I might have forgotten some syntax, but the idea is there.

                                  Regards,

                                  Elmo


                                  • 14. Re: Assign a task to 2 users, how please?
                                    boerse

                                    Hi Elmo and thanks for your reply!

                                    What you said is exactly what i want to make (and many of us, i suppose): a timer and 2 or more users, first-come-first serve and keep on working. That's the right point and what in the paper pefectly works, i tried again (as i had already done 100000....00000 times :)

                                     <swimlane name="approver">
                                     <assignment expression="group(groupname)"/>
                                     </swimlane>
                                    


                                    but in my case, although i do that the task is assigned to null and the users of the group cannot permform the task. I believe there's a bug somewhere and i tried to report it http://jira.jboss.com/jira/browse/JBPM-563?page=all but it was refused. I found an alternative way to solve this problem but assigning a task to each user and ending the others when the first is served, but the central point of this post (i think) should be to clarify all of us if it's possible or not to assign a task to more than 1 user.

                                    1 2 3 Previous Next