找出候选组任务的最佳方法是什么?

jkl*_*lee 3 business-process-management process camunda

在我使用 taskQuery 加载任务列表之后

taskService.createTaskQuery()
            .processDefinitionKey(PROCESSKEY)
            .taskCandidateGroupIn(list).initializeFormKeys().list()
Run Code Online (Sandbox Code Playgroud)

找出每项任务的候选组的最佳方法是什么?我想在 JSF 视图中显示它,但类 Task 没有相应的字段。

tho*_*ben 6

您可以使用任务服务获取任务的身份链接。在其他关系中,候选组关系表示为身份链接。以下代码为代表候选组的那些过滤任务的身份链接:

List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());

for (IdentityLink identityLink : identityLinks) {
  String type = identityLink.getType(); 
  /* type corresponds to the constants defined in IdentityLinkType.
  "candidate" identitifies a candidate relation */

  String groupId = identityLink.getGroupId();

  if (IdentityLinkType.CANDIDATE.equals(type) && groupId != null) {
    // we have found a candidate group; do something
  }
}
Run Code Online (Sandbox Code Playgroud)