Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all claimed & unclaimed items for a group in Activiti

Tags:

activiti

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.

like image 385
ajjain Avatar asked Nov 19 '25 05:11

ajjain


1 Answers

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();
like image 193
matts Avatar answered Nov 22 '25 04:11

matts