AnsweredAssumed Answered

Bug in TaskQuery.taskCandidateOrAssigned?

Question asked by xman-berlin on Apr 30, 2014
Latest reply on Jul 21, 2014 by trademak
Hi all,

after a discussion (http://forums.activiti.org/content/howto-get-both-assigned-tasks-and-tasks-where-use-candidate-one-call) about getting both assigned tasks and tasks being candidates in one call, I would like to discuss whether or not the function is buggy.

Here's the scenario:
  • Start process with a simple task.
  • user1 and user2 are candidates of the task.
  • user1 claims the task.
  • user1 queries tasks by TaskQuery.taskCandidateOrAssigned: returns task1. -> OK
  • user2 queries tasks by TaskQuery.taskCandidateOrAssigned: returns task1. -> FAIL.
I thought that claiming a task removes it from tasklist of other candidates. To prove the failure, I tried to claim the task by user2 but this works as expected -> Activiti throws ActivitiTaskAlreadyClaimedException.

This is the SQL query which is used to retrieve the task list.
 <when test="bothCandidateAndAssigned">
          <if test="userIdForCandidateAndAssignee != 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 ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{userIdForCandidateAndAssignee} ) ) )
          </if>
        </when>


I think, the query is missing the limitation to "RES.ASSIGNEE_ is null" when testing the user groups, e.g.:
 <when test="bothCandidateAndAssigned">
          <if test="userIdForCandidateAndAssignee != null">
            and (RES.ASSIGNEE_ = #{userIdForCandidateAndAssignee} or (RES.ASSIGNEE_ is null and I.USER_ID_ = #{userIdForCandidateAndAssignee} or  (RES.ASSIGNEE_ is null and I.GROUP_ID_ IN (select g.GROUP_ID_ from ACT_ID_MEMBERSHIP g where g.USER_ID_ = #{userIdForCandidateAndAssignee} ) ) ) )
          </if>
        </when>


If I am right, I'd like to file a bug report. Where's the right place?

Thanks,
Best regards,
Torsten

Outcomes