1 2 Previous Next 17 Replies Latest reply on Feb 15, 2006 5:12 AM by Koen Aers

    assign a task to a group using <assignment expression...

    issak dav Newbie

      Hi,
      I have problems with Assigning a task to a group.
      I'm using jbpm-starters-kit-3.0.2, and run some tests from there.
      I created in the ProcessDefinition a task with this assignment:

      <assignment expression='group(group1) --> member(role1)'

      where in the DB I have the Identity tables with correct data.

      I debugged the process and I saw that the AssignmentHandler recives the
      expression well but it process it in a wrong way.

      The results of this assignment were :
      1) the ActorId of the TaskInstance was set to a single user
      2) the pooledActorArray was null.

      I'm sure that in the membership table there are 2 users with role
      "role1", so :

      Later I used this assignment:
      <assignment expression='group(group1)
      the pooledActorArray was set with "group1"
      and there was no mention to the users.


      1) Way the AssignmentHandler made setActorId?
      2) How can I assign a task to a pool of users?
      3) Why the AssignmentHandler set pooledActorArray with the grpup name
      and not with the users of the group?
      4) I can change the AssignmentHandler so it will work correctly, it is recommended ?
      5) So what should I do?

      Any help will be appreciated.

      Issak.



        • 1. Re: assign a task to a group using <assignment expression...
          Alejandro Guizar Master

          We need to clarify the identity model. In my view, groups are related to organizational structures. They are less prone to change than the people enrolled in them. This is why assigning to groups offers more flexibility. When a task is assigned to a group, the actorId property should be set, rather than the pooledActorArray. The meaning is that the task is shared by all members of that group, whoever they are. This way new members can quickly get involved with the responsibilities of the group.

          It follows that the findTasksByActorId(actorId) query should retrieve tasks assigned to that actorId plus tasks assigned to each group that actor belongs. In fact, things already work like that:

          Conversely, assignment to specific members of a group should be regarded as personal assignments (i.e. with names of specific individuals) to be shared among players of similar roles in the organization.

          The question is, what is the right picture of the identity model?

          • 2. Re: assign a task to a group using <assignment expression...
            issak dav Newbie

            Hi,
            Thank's for the quick response,

            I still have to understand something.

            let's assume that I have one Group : g1.
            In this group I have 4 Users u0 --> u3.
            In the memberShip table there is connection between the group and the users:
            g1 -- u0-- roleName = role1
            g1 -- u1 -- roleName = role1
            g1 -- u2 -- roleName = role1
            g1 -- u3 -- roleName = role2

            I want to put in the pooledActorArray only the users from Group g1 that have the roleName - role1 (the users u0,u1).

            I thought that by doing expression = 'group(g1)-->member(role1)'
            I will get set of actorId (u0,u1), and that It will set:
            setPooledActorArray (new String[] {u1.u2})
            By u1,u2 I mean their Id.

            The ExpressionAssignmentHandler, just put one user and does:
            setActorId(the first user in the group).
            It's look like a bug!

            I don't want to have many groups, I thought that for Role managment we use the memberShip table.

            I wanted to extend the ExpressionAssignmentHandler, however I saw that
            in order to use my extend ExpressionAssignmentHandler I will need to extend also the JpdlXmlParser.java.

            Seems that all this issue hasn't been developed yet.

            Am I correct?

            Issak

            • 3. Re: assign a task to a group using <assignment expression...
              Koen Aers Master

              Issak,

              I have looked at the issue. You could call it a bug, but there is a reason why this problem appears. To understand it properly, you should have a look for yourself in the implementation of the class org.jbpm.identity.assignment.ExpressionAssignmentHandler. You will see there that the resolveNext method indeed returns the first entity in the set of members it finds. It would be ok to return a set of actorIds if this member expression was the last of the chain, but if this is not the last and there are multiple entities returned, it is impossible to resolve the next part of the expression chain.
              The implementation will not change shortly. If you would like such a thing to be added, enter a JIRA issue for it. Keep in mind that the syntax would have to change slightly (perhaps introducing a 'members()' function that can only be used as the last part of the expression chain. Alternatively, you could implement a custom assignment handler that provides this kind of behaviour (it is not really that difficult to implement) and we will gladly look at your solution to integrate it if you are willing to contribute.

              Regards,
              Koen

              • 4. Re: assign a task to a group using <assignment expression...
                issak dav Newbie

                Hi Koen,
                I looked at the ExpressionAssignmentHandler, and I understood the code.
                In my opinion, if you want some users from a group by a spesific role
                the actorPooledArray should be set, not the setActorId.
                There is no reason to set the first actor from the group or the last actor from the group, I need to set all the actors as optionaly actor - i.e setPooledActorArray.

                I know that I can extend the ExpressionAssignmentHandler, however,
                I saw that in the JpdlXmlParser.java there is link to the class - hardcoded.
                If I will extend the ExpressionAssignmentHandler, I will need to change the JpdlXmlParser.java , If I will do that, I will have to change the class in each time that I will use new version of JBPM.

                There for I decided to wait untill the ExpressionAssignmentHandler will be more mature, I don't mind to share my work till now and contribute to the
                JBPM.

                • 5. Re: assign a task to a group using <assignment expression...
                  Koen Aers Master

                  Well there *is* a reason. If you have e.g. this expression : previous --> group(jbpm-users) --> member(expert) --> group(hierachy) --> member(boss) then you will have a problem resolving the fourth and fifth expression if there is more than one expert jbpm-user.
                  Anyway, providing your own AssignmentHandler is not that difficult. The hardcoded relationship in JpdlParser is not important. You simply implement an AssignmentHandler e.g. by inheriting from ExpressionAssignmentHandler and define one 'expression' field in this class. You then should use the 'handler' configuration option in the task (instead of 'expression') and configure the expression string though the field configuration mechanism.

                  Regards,
                  Koen

                  • 6. Re: assign a task to a group using <assignment expression...
                    issak dav Newbie

                    Ok, so in some cases you need only one actors.
                    I used the assignment by class that extend the AssignmentHandler,
                    However I need to pass a String as the role.


                    • 7. Re: assign a task to a group using <assignment expression...
                      brittm Novice

                       

                      When a task is assigned to a group, the actorId property should be set, rather than the pooledActorArray. The meaning is that the task is shared by all members of that group, whoever they are. This way new members can quickly get involved with the responsibilities of the group.

                      It follows that the findTasksByActorId(actorId) query should retrieve tasks assigned to that actorId plus tasks assigned to each group that actor belongs. In fact, things already work like that:


                      Alex,
                      I see a few problems with this approach--unless I've missed some changes in the last couple months.

                      The first is that if I'm using my own user/group directory (Active Directory for instance), jBPM isn't going to have any idea which user belongs to which group and will only return tasks directly assigned to that group as an 'actorId'. Behavior of such a basic API call should be consistent whether I'm using jBPM's user management system or my own enterprise system.

                      The second issue is a little more subtle, but is the kind of reason my company is passing by Oracle's BPEL solution and using jBPM. Consider that a particular trouble ticket task is associated with a 'Ticket Pool' from which members of the Customer Care group claim tasks. A user named Bill claims a task out of the pool but does not perform the task for some reason, and the ticket must revert back to the pool. If our system supports separate work group assignment, our task contains assignment data related to both the current actor (Bill) and it's governing work group (the Ticket Pool); consequently, simply disassociating Bill from the task allows the system to see this task as being back in the Ticket Pool. If we didn't have both user and group data simultaneously associated with the task, the system wouldn't know to which pool to return the task. We could not determine this simply by referencing to which pool Bill belongs, because Bill may work out of more than one pool. To handle this scenario, we're using 'pooledActors' to hold the pool/group name to which the task belongs.

                      Am I way off base, or does some of this make sense?

                      Thanks,
                      Britt

                      • 8. Re: assign a task to a group using <assignment expression...
                        boerse scholz Newbie

                         

                        I created in the ProcessDefinition a task with this assignment:

                        <assignment expression='group(group1) --> member(role1)'

                        where in the DB I have the Identity tables with correct data.


                        Hi, how did you do that? I mean, create the groups... where did you define them?

                        • 9. Re: assign a task to a group using <assignment expression...
                          issak dav Newbie

                          Hi,
                          I just used the API somthing like this:

                          IdentitySessionFactory fact = new IdentitySessionFactory();
                          IdentitySession identitySession = fact.openIdentitySession() ;
                          identitySession.beginTransaction() ;
                          User john = new User("john");
                          User mosh = new User("mosh");
                          identitySession.saveUser(john);
                          identitySession.saveUser(mosh);
                          Group qaTeam = new Group("qa team", "hierarchy");
                          Group marketingTeam = new Group("marketing team", "hierarchy");
                          identitySession.saveGroup(marketingTeam);
                          identitySession.saveGroup(qaTeam);
                          Membership.create(john, "mgr", qaTeam);
                          Membership.create(mosh, "mgr", qaTeam);
                          Membership.create(john, "mgr", marketingTeam);
                          identitySession.commitTransaction() ;
                          identitySession.close();

                          • 10. Re: assign a task to a group using <assignment expression...
                            boerse scholz Newbie

                            hi yd40, thanks for your answer, have you tried inserting that info via src/resources/hsqldb/identity.db.xml? does anybody how this could be done so?
                            i do:

                            and
                            then



                            and in the processdefinition.xml:




                            and it assigns the task to null :(

                            Using 3.0.2 w 4.0.3SP1 (not starter kit, complete versions deployed) and just running the example very lightly modified to see if i do things to work.

                            • 11. Re: assign a task to a group using <assignment expression...
                              Mennen Newbie

                              I'm having a problem when assigning a task to a group..

                              I created a group in the identity component (identity.db.xml), along with the users and memberships

                              < group name="administrationOD" type="administration_generale"/>
                              < membership name="administration" role="administration" user="laurence" group="administrationOD"/>
                              < membership name="comptabilite" role="comptabilite" user="violaine" group="administrationOD"/>

                              here are the users
                              < user name="violaine" email="violaine@objetdirect.com" password="violaine" />
                              < user name="laurence" email="lbattendier@objetdirect.com" password="laurence" />


                              And all these appear in the database.. so no problem until here..

                              The problem is when i assign a swimlane to a group:
                              < swimlane name="administration">
                              < assignment expression="group(administrationOD)">< /assignment>
                              < /swimlane>


                              So in this group, there is supposed to be 2 users : Violaine and Laurence
                              But when i deploy the process definition (.par) , i start a process instance (with the Laurence login), the task only appears to Laurence, and isn't even mentionned in Violaine's tasklist.

                              Maybe someone could clarify this to me: if I assign a swimlane to a group, aren't all the members of the group supposed to see the task instance created (by a member of the same group) ??
                              I checked the database and the pooledActor table is empty, as well as the taskActorPool table.
                              I just checked the JBPM_delegation table and here is what i found in it:
                              CLASSNAME_ org.jbpm.identity.assignment.ExpressionAssignmentHandler
                              CONFIGURATION_ < expression>group(administrationOD)< /expression>



                              Any ideas?

                              Thanks in advance

                              Mennen



                              • 12. Re: assign a task to a group using <assignment expression...
                                boerse scholz Newbie

                                Bonjour Mennen, you had more luck than me. I'm still fighting against these assignments with the same problems like you. The data of the table jbpm_id_memberships has all the values ok? Mine (with 3.1B3 and JBoss 403SP1) returns null in the "name" field.

                                Other posts where we try to solucionate this task are (one of them were initiated by you).

                                http://jboss.org/index.html?module=bb&op=viewtopic&t=76736 and http://jboss.org/index.html?module=bb&op=viewtopic&t=77268. Hope we can find a solution....

                                • 13. Re: assign a task to a group using <assignment expression...
                                  Mennen Newbie

                                  Thanks for your reply boerse

                                  I'm using jbpm 3.0.2, not the beta , with mysql and jboss 4.0.3

                                  I'm still having the problem of membership name still being set to null in the database. I updated my post http://www.jboss.com/index.html?module=bb&op=viewtopic&t=76736

                                  Hope this bug is fixed in the new release..

                                  Mennen

                                  • 14. Re: assign a task to a group using <assignment expression...
                                    boerse scholz Newbie

                                    Hi Mennen,

                                    i'm now using 3.1B3 (originally 302) because i wanted to try if 3.1 had this problem solved, but it hadn't. :(

                                    We're still on it....

                                    P.S. Are you sure it's a bug?

                                    1 2 Previous Next