3

How can I query all items claimed/unclaimed by user which belongs to a particular group? So I want to build an API of below format List getAllTasks4Group(String group)

The reason why I want this API is I don't have know all the users which might have acquired tasks and all these tasks belong to same group.

4

2 回答 2

4

Since the TaskQuery's candidateGroup method only returns unclaimed tasks, the easiest way I know to do this is to use a native query:

String groupId = ...

String taskTable = managementService.getTableName(TaskEntity.class);
String identityLinkTable = managementService.getTableName(IdentityLinkEntity.class);

List<Task> groupTasks = taskService.createNativeTaskQuery()
        .sql("select _TASK.*" +
             "  from " + taskTable + " _TASK" +
             "  join " + identityLinkTable + " _LINK on _TASK.ID_ = _LINK.TASK_ID_" +
             " where _LINK.TYPE_ = 'candidate'" +
             "   and _LINK.GROUP_ID_ = #{groupId}")
        .parameter("groupId", groupId)
        .list();
于 2013-11-18T17:30:00.173 回答
1

You can UserQuery for getting all users of a group:

UserQuery memberOfGroup(String groupId)

Only select Users that belong to the given group.

And then iterate over the users for collecting the tasks with TaskQuery:

TaskQuery taskAssignee(String assignee)

Only select tasks which are assigned to the given user.

There are also direct queries for candidate users / groups mentioned in the Javadocs.

于 2013-11-14T13:45:09.313 回答