1 2 3 Previous Next 33 Replies Latest reply on Apr 24, 2007 8:41 AM by Sanket Shirodkar Go to original post
      • 15. Re: Assign a task to 2 users, how please?
        Elmo Novice

        Hi boerse,

        I will try to share my solution to you. I assume you already know how to add groups, users and membership. You try the solution

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


        When it creates the task, try this SQL query:
        SELECT
         t.ID_ AS taskid,
         t.NAME_ AS taskname,
         t.DESCRIPTION_ AS taskdescription,
         u.NAME_ AS userid,
         t.START_ AS startdate,
         t.DUEDATE_ AS duedate,
         t.END_ AS enddate
        FROM jbpm_taskinstance t
        INNER JOIN jbpm_taskactorpool p ON t.ID_ = p.TASKINSTANCE_
        INNER JOIN jbpm_pooledactor pa ON p.POOLEDACTOR_ = pa.ID_
        INNER JOIN jbpm_id_group g ON pa.ACTORID_ = g.NAME_
        INNER JOIN jbpm_id_membership m ON m.GROUP_ = g.ID_
        INNER JOIN jbpm_id_user u ON u.ID_ = m.USER_
        WHERE t.END_ IS NULL
        
        .

        This should give you the list of pooled actors with their pending tasks. Only one can accomplish this task, when one has accomplished the task, this query returns null. Like I said, some solutions I resort using SQL and this is one of them.

        Regards,

        Elmo

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

          Hi Elmo, thanks a lot for your reply, now i have to finish some othe tasks and i'm in a hurry, but as soon as i can i'll give it a try! Hope it helps other ppl of this forum, too!

          • 17. Re: Assign a task to 2 users, how please?
            Patrick Dalla Bernardina Apprentice

            HI, everybody,

            I think the problem is that:

            JbpmContext.getCurrentJbpmContext().getTaskMgmtSession().findTaskInstances(userName);

            Does not return the tasks that were assigned to a group that the user is member of.

            JBPM core doesn't implement the relationship between group and user (membership). It simply assign tasks to an actorId. This actorID can be user or group.

            I solved this problem searching for all groups the user is member of, an passing each actorId of the groups plus actorID of the user to:

            jbpmContext.getGroupTaskList(actorsList);

            This method return the task assigned to any of the actorIds in the list.

            • 18. Re: Assign a task to 2 users, how please?
              Patrick Dalla Bernardina Apprentice

              The code for the HomeBean getTaskInstances method should be:


              public List getTaskInstances() {
              List actorsList = new ArrayList();
              actorsList.add(userBean.getUserName());

              Iterator i = userBean.getUser().getMemberships().iterator();
              while(i.hasNext()){
              Membership m = (Membership) i.next();
              actorsList.add(m.getGroup().getName());
              }

              List taskList = jbpmContext.getGroupTaskList(actorsList);

              return taskList;
              }

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

                does it work this way? have you tried it?

                • 20. Re: Assign a task to 2 users, how please?
                  Tom Baeyens Master

                   

                  "patrickdalla" wrote:
                  The code for the HomeBean getTaskInstances method should be:


                  public List getTaskInstances() {
                  List actorsList = new ArrayList();
                  actorsList.add(userBean.getUserName());

                  Iterator i = userBean.getUser().getMemberships().iterator();
                  while(i.hasNext()){
                  Membership m = (Membership) i.next();
                  actorsList.add(m.getGroup().getName());
                  }

                  List taskList = jbpmContext.getGroupTaskList(actorsList);

                  return taskList;
                  }


                  no. you should fetch all the groups for a user and search for all the tasks assigned to the user or to one of his/her groups.

                  otherwise the identity module would not be pluggable.

                  regards, tom.

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

                    What I understand is that the assignation as is described in the documentation does not work, but I wonder why it is not being recognized *oficially*. Can't you just say?: no, for the moment being it does not work, so don't waste your time making 10000000000 tries with something you won't get. That'd be pretty nice in my oppinion, that is, not giving ppl the hope to use that when everybody knows that it just does not work...

                    • 22. Re: Assign a task to 2 users, how please?
                      d b Newbie

                      related question:
                      is it necessary to involve groups/swimlanes?
                      i.e. in my case i have two userids that i get at runtime, "donald", "arnold" that should be assigned to a task (the users might be different each runtime and does not necessary belong to the same group or have same role; they are calculated out of our database depending on different factors)

                      and by reading the user guide i get the impression that groups/swimlanes are optional:


                      Both TaskInstances and SwimlaneInstances can be assigned to a specific user or to a pool of actors. To assign a TaskInstance to a user, call Assignable.setActorId(String actorId). To assign a TaskInstance to a pool of candidate actors, call Assignable.setPooledActors(String[] actorIds).

                      Each task in the process definition can be associated with an assignment handler implementation to perform the assignment at runtime.

                      When more then one task in a process should be assigned to the same person or group of actors, consider the usage of a swimlane


                      so my understanding was that i could use

                      String[] actors = {"donald", "arnold"};
                      assignable.setPooledActors(actors);


                      instead of the code i use when assigning a single actor
                      assignable.setActorId("donald")


                      but jbpm_taskinstance.actorid_ is set to null
                      how is the relation between the task and the pooled actors?
                      how can i see that these users have been assigned the task?

                      would be grateful if someone could bring some light into this.


                      • 23. Re: Assign a task to 2 users, how please?
                        d b Newbie

                        ah, i shouldnt look that much in the database,
                        simply calling

                        Iterator iter = task.getPooledActors().iterator();
                        

                        delivered exactly that i wanted.


                        • 24. Re: Assign a task to 2 users, how please?
                          Ronald van Kuijk Master

                          well, there is one addition and it has to do with the being 'null' of the actorID. If it is null, the task is only assigned to the group and shows up in the group list (if you have one) if it is not null, it is assinged to the individual actor. By setting it to null aggain the task is put back in the group task list

                          • 25. Re: Assign a task to 2 users, how please?
                            Brian Greene Newbie

                            the previous post is dead on in my experience, and we use the null actorid versus a non-null extensively to determine where a task is to be displayed.

                            You're using the identity module...

                            I'm not using the Identity module - we looked at it and we have better luck with a handful of custom swimlane implementations that we use for nearly everything. setActorIds(String[]) works exactly as advertised, and is how we assign to multiple users. And the task does in fact show up exactly where it's supposed to...

                            curious you're having this problem with the identity module, and I'll be curious to see how it works out. I know if you take full control with your own assignment implementations (they're rather little you know), you'll be more than happy with the flexibility of the assignment system to groups and users in jBPM.

                            • 26. Re: Assign a task to 2 users, how please?
                              wehbe jean Newbie

                              Hello All.
                              I tried to assign a task to 2 users.
                              I used:
                              String[] actors = {"ernie", "TonyRog"};
                              assignable.setPooledActors(actors);
                              Nothing is work.
                              Please i need an example applied about this issue.

                              What is the type of the assignment.
                              Please I want also to know what is the difference between :
                              Field,Bean,Constructor,Compatibility.
                              Which one i choose?

                              • 27. Re: Assign a task to 2 users, how please?
                                Koen Aers Master

                                Have a look at the documentation please :
                                - http://docs.jboss.com/jbpm/v3/userguide/jpdl.html#configurationofdelegations for a discussion on the configuration options of handlers.
                                - http://docs.jboss.com/jbpm/v3/userguide/taskmanagement.html#assignment for the pooled actors/assignments.

                                Regards,
                                Koen

                                • 28. Re: Assign a task to 2 users, how please?
                                  Gino Bramieri Newbie

                                  i had same problem but i resolved it. There is no bugs in jBPM about group assignment, just websale example does not implement it.
                                  talking about websale example, if you use "group(groupName)" in a task or swimlane assignment, and logging with some of groupName members you will not find any tasks in their tasklist. This is correct because in that tasklist (that of websale example) you will find only task assigned to user logged. If you want to see a tasklist with tasks assigned to user's group, you have to write in home.jsp another list table. See my example below:

                                  <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
                                  <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
                                  
                                  <f:view>
                                  
                                  <jsp:include page="header1.jsp" />
                                  Home
                                  <jsp:include page="header2.jsp" />
                                  
                                  <b><h:messages /></b>
                                  
                                  <h4>Tasklist assigned</h4>
                                  <h:dataTable value="#{homeBean.taskInstances}" var="taskInstance" headerClass="tableheader" columnClasses="tablecell">
                                   <h:column >
                                   <f:facet name="header">
                                   <h:outputText value="Task Form Link" />
                                   </f:facet>
                                   <h:commandLink action="#{homeBean.selectTaskInstance}">
                                   <f:param name="taskInstanceId" value="#{taskInstance.id}"/>
                                   <h:outputText value="#{taskInstance.name}" />
                                   </h:commandLink>
                                   </h:column>
                                   <h:column>
                                   <f:facet name="header">
                                   <h:outputText value="Process" />
                                   </f:facet>
                                   <h:outputText value="#{taskInstance.taskMgmtInstance.taskMgmtDefinition.processDefinition.name}" />
                                   </h:column>
                                   <h:column>
                                   <f:facet name="header">
                                   <h:outputText value="Version" />
                                   </f:facet>
                                   <h:outputText value="#{taskInstance.taskMgmtInstance.taskMgmtDefinition.processDefinition.version}" />
                                   </h:column>
                                  </h:dataTable>
                                  
                                  <!-- author Ciro -->
                                  <h4>Tasklist assignable</h4>
                                  <h:dataTable value="#{homeBean.pooledTaskInstances}" var="pooledTaskInstance" headerClass="tableheader" columnClasses="tablecell">
                                   <h:column >
                                   <f:facet name="header">
                                   <h:outputText value="Task Form Link" />
                                   </f:facet>
                                   <h:commandLink action="#{homeBean.assignTaskInstance}">
                                   <f:param name="taskInstanceId" value="#{pooledTaskInstance.id}"/>
                                   <h:outputText value="#{pooledTaskInstance.name}" />
                                   </h:commandLink>
                                   </h:column>
                                   <h:column>
                                   <f:facet name="header">
                                   <h:outputText value="Process" />
                                   </f:facet>
                                   <h:outputText value="#{pooledTaskInstance.taskMgmtInstance.taskMgmtDefinition.processDefinition.name}" />
                                   </h:column>
                                   <h:column>
                                   <f:facet name="header">
                                   <h:outputText value="Version" />
                                   </f:facet>
                                   <h:outputText value="#{pooledTaskInstance.taskMgmtInstance.taskMgmtDefinition.processDefinition.version}" />
                                   </h:column>
                                  </h:dataTable>
                                  
                                  <h4>Start New Process Execution</h4>
                                  
                                  ...
                                  
                                  


                                  then write related methods in homeBean.java:

                                  
                                  ...
                                  
                                   public List getTaskInstances() {
                                   return taskMgmtSession.findTaskInstances(userBean.getUserName());
                                   }
                                  
                                   //author Ciro
                                   public List getPooledTaskInstances() {
                                   Session session=null;
                                   String user = userBean.getUserName();
                                   JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
                                   session=jbpmContext.getSession();
                                   Query query= session.createQuery("select membership.group.name " +
                                   "from org.jbpm.identity.Membership as membership " +
                                   "where membership.user.name='"+user+"'");
                                   List list=query.list();
                                   List l;
                                   if(!list.isEmpty())l=taskMgmtSession.findPooledTaskInstances(list);
                                   else l=list;
                                   return l;
                                   }
                                  
                                   public List getLatestProcessDefinitions() {
                                   return graphSession.findLatestProcessDefinitions();
                                   }
                                  
                                   /**
                                   * selects a task.
                                   */
                                   public String selectTaskInstance() {
                                   // Get the task instance id from request parameter
                                   long taskInstanceId = JsfHelper.getId("taskInstanceId");
                                   TaskInstance taskInstance = taskMgmtSession.loadTaskInstance(taskInstanceId);
                                   taskBean.initialize(taskInstance);
                                   return "task";
                                   }
                                  
                                   //author Ciro
                                   public String assignTaskInstance(){
                                   long id = JsfHelper.getId("taskInstanceId");
                                   TaskInstance taskInst = taskMgmtSession.loadTaskInstance(id);
                                   taskInst.setActorId(userBean.getUserName());
                                   return "home";
                                   }
                                  
                                  ...
                                  
                                  


                                  regards,
                                  Ciro

                                  • 29. Re: Assign a task to 2 users, how please?
                                    Mohamed Abbes Newbie

                                    Hello
                                    Finally what is the perfect method to Assign a task to 2 users or +
                                    thanks