AnsweredAssumed Answered

[Issue] TaskCandidateQuery uses different group id from TaskCandidateGroup

Question asked by cfitch on May 2, 2013
Latest reply on Jun 24, 2013 by jbarrez
Greetings, I'm having an issue with the Vacation Request example and taskCandidateUser/Group Queries.
Env:
Grails 2.2.1, JDK 1.6, Activiti Plugin 5.10, Shiro Plugin 1.14

Description
I installed the Activiti Plugin and followed the code for another plugin in order to integrate wth Shiro. I've installed the Vacation Request Sample app. Other than some quirks mostly due to my ignorance, everything has been working pretty well. However, there is one issue that I've run in to. Basically a task query using taskCandidateQuery returns no tasks for a newly created process instance while taskCandidateGroup queries do return the task. After adding some logging and enabling debug, I've found an inconsistency: when using taskCandidateUser, the query executed uses the group id. However, when using taskCandidateGroup, the group name is used. In the ACT_RU_IDENTITYLINK table, the GROUP_ID column contains the names of the groups and not the id's.

So my question is, how do I resolve this inconsistency? I'm guessing the issue is related to how the shiro user/role code works with activiti user/group code.

Here's the SQL executed for taskCandidateQuery and the parameters(formatted for easy viewing):

2013-05-02 10:25:44,042 [http-bio-8080-exec-3]
DEBUG TaskEntity.selectTaskByQueryCriteria  - ==>
    Preparing: select distinct T.*
               from ACT_RU_TASK T
               inner join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = T.ID_
               WHERE T.PROC_INST_ID_ = ?
               and T.ASSIGNEE_ is null
               and I.TYPE_ = 'candidate'
               and ( I.USER_ID_ = ? or I.GROUP_ID_ IN ( ? ) )
               LIMIT ? OFFSET ?

2013-05-02 10:25:44,042 [http-bio-8080-exec-3]
DEBUG TaskEntity.selectTaskByQueryCriteria  - ==>
Parameters: 1201(String),
            admin(String),
            1(String),
            2147483647(Integer),
            0(Integer)


Here's the SQL executed for taskCandidateQuery and the parameters(formatted for easy viewing):

2013-05-02 10:25:44,062 [http-bio-8080-exec-3]
DEBUG TaskEntity.selectTaskByQueryCriteria  - ==> 
   Preparing: select distinct T.*
            from ACT_RU_TASK T
            inner join ACT_RU_IDENTITYLINK I on I.TASK_ID_ = T.ID_
            WHERE T.PROC_INST_ID_ = ?
            and T.ASSIGNEE_ is null
            and I.TYPE_ = 'candidate'
            and ( I.GROUP_ID_ IN ( ? ) )
            LIMIT ? OFFSET ?
           
2013-05-02 10:25:44,063 [http-bio-8080-exec-3]
DEBUG TaskEntity.selectTaskByQueryCriteria  - ==>
Parameters: 1201(String),
         Admin(String),
         2147483647(Integer),
         0(Integer)



The identity link table contains the following data:

SELECT * FROM ACT_RU_IDENTITYLINK;
ID_     REV_     GROUP_ID_     TYPE_     USER_ID_     TASK_ID_     PROC_DEF_ID_ 
1109   1   PMSupport   candidate   null   1108   null
1110   1   Admin   candidate   null   1108   null


Here are the two queries (first one returns nothing, second one works)

task = activitiService.taskService.createTaskQuery()
                                    .processInstanceId(pi.id)
                                    .taskCandidateUser(username)
                                    .singleResult();



task = activitiService.taskService.createTaskQuery()
                                    .processInstanceId(pi.id)
                                    .taskCandidateGroup(theUser.getUserRoleName())
                                    .singleResult();


Other info:
I modified the process definition slightly to use my role names instead of the defaults. They are: Admin, PMSupport.

I can provide additional info as requested.

Any help or insight would be greatly appreciated.

Outcomes