2 Replies Latest reply on Nov 15, 2005 12:29 AM by ashkumar

    AssignmentHandler for groups

    gwittwer

      Hello

      I'm working on the AssignmentHandler for my webapp.
      I took the ExpressionAssignmentHandler from the jbpm.identity module and changed the resolveTerm stuff to my requirements.

      If I use for e.g. the expression user(James Bond) the execution and assignment works great.
      But if I use expression group(Agent) the assignment is null.
      I added some log-information to the ExpressionHandler:

      18:57:24,779 DEBUG [TaskBean] Save and Close button pushed
      18:57:24,781 DEBUG [GraphElement] event 'task-end' on 'Task(Pflichtenheft erstellen)' for 'Token(/)'
      18:57:24,815 DEBUG [TaskInstance] completion of task 'Pflichtenheft erstellen' results in taking the default transition
      18:57:24,825 DEBUG [GraphElement] event 'before-signal' on 'TaskNode(Pflichtenheft erstellen)' for 'Token(/)'
      18:57:24,826 DEBUG [GraphElement] event 'node-leave' on 'TaskNode(Pflichtenheft erstellen)' for 'Token(/)'
      18:57:24,827 DEBUG [GraphElement] event 'transition' on 'Transition(d6ea97)' for 'Token(/)'
      18:57:24,829 DEBUG [GraphElement] event 'node-enter' on 'TaskNode(Pflichtenheft Abnahme)' for 'Token(/)'
      18:57:24,865 DEBUG [ExpressionAssignmentHandler] assign called
      18:57:24,866 DEBUG [ExpressionAssignmentHandler] resolving first term 'group(Agent)'
      18:57:24,867 DEBUG [ExpressionAssignmentHandler] assignment groupName: Agent
      18:57:24,867 DEBUG [ExpressionAssignmentHandler] get group by name: Projektbeteiligten
      18:57:24,879 DEBUG [ExpressionAssignmentHandler] assignment entityname: Agent
      18:57:24,880 DEBUG [ExpressionAssignmentHandler] entity is type of group: Agent
      18:57:24,881 DEBUG [GraphElement] event 'task-assign' on 'Task(Pflichtenheft Abnahme)' for 'Token(/)'
      18:57:24,884 DEBUG [GraphElement] event 'task-create' on 'Task(Pflichtenheft Abnahme)' for 'Token(/)'
      18:57:24,884 DEBUG [GraphElement] event 'after-signal' on 'TaskNode(Pflichtenheft erstellen)' for 'Token(/)'
      18:57:24,885 DEBUG [TaskBean] assignmentlogs: [task-assign[null,org.jbpm.taskmgmt.exe.TaskInstance@6991d8]]
      

      The group and all members exists and could be resolved.
      Just the assignment for the pooledActors doesn't work.

      Code section in AssignmentHandler:
      } else if (entity instanceof Group) {
       // put the group in the pool
       log.debug("entity is type of group: " + entity.getName());
       assignable.setPooledActors(new String[]{entity.getName()});
       //assignable.setActorId(Long.toString(entity.getId()));
       }
      


      Why doesn't it work??

      Thank you for your help. I searched the forum and found different posts, but none helped me.

      Regards Gerhard

        • 1. Re: AssignmentHandler for groups
          gwittwer

          Oh sorry, I did a mistake in the published log. I changed the group "Projektbeteiligte" to "Agent" and forgot one. Please ignore this mistake!

          • 2. Re: AssignmentHandler for groups
            ashkumar

            Hi Firstly, the following Jira issue has to be resolved.
            http://jira.jboss.com/jira/browse/JBPM-429
            This will allow you to specify your own Assignment handler in Process definition file.

            my assign method in the assignmentHandler looks like follows.

            ----------------------
            }else if (entity instanceof Group) {

            // put the group in the pool


            SpectrumAssignmentHandler assignmentHandler =
            new SpectrumAssignmentHandler ();

            SpectrumIdentitySession iSession = (SpectrumIdentitySession)assignmentHandler.getExpressionSession();

            //Get all the Groups to which user belongs

            Group group = iSession.getGroupByName(entity.getName());

            Set users = group.getUsers();

            Iterator it = users.iterator();

            Set userNames =
            new HashSet();

            while (it.hasNext()) {

            User tempUser = (User) it.next();

            userNames.add(
            new PooledActor(tempUser.getName()));

            }

            assignable.setPooledActors(userNames);
            --------------------------------

            Notice that I overloaded setPooledActors to accept ArrayList instead of String[]

            Basically, here is an opportunity for you to be as creative as possible.
            All the best !