10 Replies Latest reply on Mar 26, 2009 11:25 AM by Ronald van Kuijk

    Get tasks by a user's group

    Damian Nowak Newbie

      Hi,

      I'm just getting off with jBPM, and this is my first post in this forum: Hello everyone :)

      So far, I've gotten everything to work, until now. I'd like to get a list of all tasks assigned to groups a specific user belongs to.

      Example: User frank1 is in group sales and management. A task is assigned to management. I want to get this task by placing a query about tasks for frank1.

      Basically something like "findPooledTaskInstances(actorID)", which I've found in the guide:

      "To fetch the group task list for a given user, proceed as follows: Make a collection that includes the user's actorId and all the ids of groups that the user belongs to. With TaskMgmtSession.findPooledTaskInstances(String actorId) or TaskMgmtSession.findPooledTaskInstances(List actorIds) you can search for task instances that are not in a personal task list (actorId==null) and for which there is a match in the pooled actorIds. "

      The result unfortunately is empty:( How can I accomplish this?

      Thanks a lot and best regards,

      Damian

      PS: Is there any API about Groups? I defined some groups in the JBPM Console, but can't find any way to access them. Help please? :/

        • 1. Re: Get tasks by a user's group
          Ronald van Kuijk Master

          the findPooledTaskInstances both work for me...

          So please provide a unittest with everything embedded that demonstrates the problem.

          • 2. Re: Get tasks by a user's group
            Damian Nowak Newbie

            Thanks for your reply.

            Just to make sure:

            You provide an ActorID with the TaskMgmtSession.findPooledTaskInstances method and receive the tasks which are assigned to the group the actorID belongs to?

            • 3. Re: Get tasks by a user's group
              Ronald van Kuijk Master

              No, the core engine does *not* resolve group id's to individual id's since many companies use their own IDM solution

              You have to do that yourself in advance and provide the names of the groups then.

              • 4. Re: Get tasks by a user's group
                Damian Nowak Newbie

                Thanks, I've managed to get the groups and users from the jbpm identity library:

                Session session = JbpmContext.getCurrentJbpmContext().getSession();
                 IdentitySession identitySession = new IdentitySession(session);
                 for (int j = 0; j < identitySession.getUsers().size(); j++)
                 {
                
                 User jbpmUser = identitySession.getUsers().get(j);
                 List actorsList = new ArrayList();
                
                 Iterator i = jbpmUser.getMemberships().iterator();
                 while (i.hasNext())
                 {
                 Membership m = (Membership) i.next();
                 actorsList.add(m.getGroup().getName());
                 }
                
                 List pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances(actorsList);


                Unfortunately, I get a ClassCastException while calling the findPooledTaskInstances method:
                11:15:51,833 ERROR [jsp] java.lang.ClassCastException: org.hibernate.hql.ast.HqlToken
                 at org.hibernate.hql.ast.HqlLexer.makeToken(HqlLexer.java:39)
                 at org.hibernate.hql.antlr.HqlBaseLexer.mIDENT(HqlBaseLexer.java:580)
                 at org.hibernate.hql.antlr.HqlBaseLexer.nextToken(HqlBaseLexer.java:264)
                 at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:139)
                 at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:248)
                 at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
                 at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
                 at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
                 at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
                 at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
                 at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
                 at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1113)
                 at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
                 at org.jbpm.db.TaskMgmtSession.findPooledTaskInstances(TaskMgmtSession.java:133)
                 at com.empolis.processus.jbpm.eval.tasks.TaskProviderJbpmImpl.getAllTasksForUser(TaskProviderJbpmImpl.java:92)
                 at com.empolis.processus.portlet.tasks.TaskListBean.updateTableModel(TaskListBean.java:143)
                 at com.empolis.processus.portlet.tasks.TaskListBean.refreshTaskInstancesTable(TaskListBean.java:134)
                 at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:146)
                 at javax.faces.component.UICommand.broadcast(UICommand.java:325)
                 at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:287)



                Anyone got a hint?

                • 5. Re: Get tasks by a user's group
                  Ronald van Kuijk Master

                  have you searched using google? and is this the full stacktrace?

                  • 6. Re: Get tasks by a user's group
                    Damian Nowak Newbie

                    Yes and no. The rest of the stacktrace are just follow-ups though...

                    I have the feeling, that this is a classpath problem - but the libs are fine as far as I can tell.

                    I really have NO idea - anyone has a hint?

                    • 7. Re: Get tasks by a user's group
                      Damian Nowak Newbie

                      OK it is getting strange (for me).

                      I've set up a simple, new jBPM Project in Eclipse. Also, I've defined and deployed a simple Process, which calls some Java Method using an event.

                      This method basically does exactly what my application should - and it works!
                      The strange thing is, that I do NOT get the error in my application after the test-process ran. If I fire up my JBoss and try my application -> still error.

                      So I suppose I've got some hibernate or context problem.

                      Does that ring any bell? I suppose it must be a stupid error - but I am unable to find it and will go home after over 14 hours of work now :(

                      Best,
                      D.

                      • 8. Re: Get tasks by a user's group
                        Ronald van Kuijk Master

                        There are some things mentioned on the net regarding this classcast issue. And yes it is related to the classpath or even the appserver. In that way it 'rang' a bell, but nothing more. Look at the articles you can find with google and see if there is something in there.

                        • 9. Re: Get tasks by a user's group
                          Damian Nowak Newbie

                          Believe me - I did. I will stick to it, but if anyone has any idea where to look at, I'd really appreciate it.

                          Best,
                          Damian

                          • 10. Re: Get tasks by a user's group
                            Ronald van Kuijk Master

                            so you are saying that none of the articles you found gave any hint to a possible solution?
                            - It is not classloader isolation (or lack thereof, UCL)
                            - it is not a classpath 'conflict' somewhere
                            - it is not an issue that you run on an appserver whith limited support for hibernate 3 (Weblogic)
                            - you are running a recent version of JBoss AS (what are you running?)
                            - you are running a recent jdk (1.5 / 1.6) (what are you running?)

                            Then I have *no* idea... maybe the hibernate forum can help out.