AnsweredAssumed Answered

Bug with TaskQuery.taskCandidateOrAssigned?

Question asked by schmke on Mar 15, 2016
Latest reply on Mar 18, 2016 by schmke
I'm seeing some behavior with using TaskQuery.taskCandidateOrAssigned that seems like a bug but wanted to check before opening an issue.

I have a process with two different user tasks, one called Manager with a candidate group manager and another called Review with no candidate group.  I have my own GroupEntityManager that implements the findGroupsByUser method and it is being called and working fine in most cases to get the groups for a user and return the right thing when using TaskQuery.taskCandidateUser for example.

Here is the scenario.

Two process instances are created that are at the Manager user task.  One is assigned to user john and the other is unassigned.  Additionally, there is a process instance at the Review task and it is assigned to andy.

Using taskCandidateUser with user andy returns the unassigned Manager task which is correct.  It does not return the task assigned to john nor the Review task assigned to andy.

However, if I use taskCandidateOrAssigned instead, just the Review task is returned.  I would expect this to still return the unassigned task as it is a candidate.

Looking at the code, specifically Task.xml, it appears for the taskCandidateUser case, the SQL generated includes something like this which uses the candidateGroups retrieved from my GroupEntityManager:

          <if test="candidateGroups != null &amp;&amp; candidateGroups.size() &gt; 0">
            I.GROUP_ID_ IN
            <foreach item="group" index="index" collection="candidateGroups"
                     open="(" separator="," close=")">
              #{group}
            </foreach>
          </if>

But in the case of using taskCandidateOrAssigned it is not, instead it is only using the internal table with this:

            <if test="candidateGroups == null">
              and (RES.ASSIGNEE_ = #{userIdForCandidateAndAssignee} or (RES.ASSIGNEE_ is null and (I.USER_ID_ = #{userIdForCandidateAndAssignee}
              or I.GROUP_ID_ IN (select g.GROUP_ID_ from ${prefix}ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{userIdForCandidateAndAssignee} ) ) ) )
            </if>


This seems like a bug to me, what is returned from taskCandidateOrAssigned should include everything returned from taskCandidateUser plus any assigned, and it shouldn't matter if a custom GroupEntityManager is used or not.

Please confirm and let me know if I need to open an issue.

Note, I'm using 5.19.0.2.

Thanks,

Kevin

Outcomes