use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class TaskRuntimeImpl method userCandidates.
@Override
public List<String> userCandidates(String taskId) {
List<IdentityLink> identityLinks = getIdentityLinks(taskId);
List<String> userCandidates = new ArrayList<>();
if (identityLinks != null) {
for (IdentityLink i : identityLinks) {
if (i.getUserId() != null) {
if (i.getType().equals(IdentityLinkType.CANDIDATE)) {
userCandidates.add(i.getUserId());
}
}
}
}
return userCandidates;
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class TaskRuntimeImpl method groupCandidates.
@Override
public List<String> groupCandidates(String taskId) {
List<IdentityLink> identityLinks = getIdentityLinks(taskId);
List<String> groupCandidates = new ArrayList<>();
if (identityLinks != null) {
for (IdentityLink i : identityLinks) {
if (i.getGroupId() != null) {
if (i.getType().equals(IdentityLinkType.CANDIDATE)) {
groupCandidates.add(i.getGroupId());
}
}
}
}
return groupCandidates;
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class TaskServiceTest method testGetIdentityLinksWithOwner.
public void testGetIdentityLinksWithOwner() {
Task task = taskService.newTask();
taskService.saveTask(task);
String taskId = task.getId();
taskService.claim(taskId, "kermit");
taskService.delegateTask(taskId, "fozzie");
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
assertThat(identityLinks).hasSize(2);
IdentityLink assignee = identityLinks.get(0);
assertThat(assignee.getUserId()).isEqualTo("fozzie");
assertThat(assignee.getGroupId()).isNull();
assertThat(assignee.getType()).isEqualTo(IdentityLinkType.ASSIGNEE);
IdentityLink owner = identityLinks.get(1);
assertThat(owner.getUserId()).isEqualTo("kermit");
assertThat(owner.getGroupId()).isNull();
assertThat(owner.getType()).isEqualTo(IdentityLinkType.OWNER);
// cleanup
taskService.deleteTask(taskId, true);
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class TaskIdentityLinksTest method testCandidateUserLink.
@Deployment(resources = "org/activiti/engine/test/api/task/IdentityLinksProcess.bpmn20.xml")
public void testCandidateUserLink() {
runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.addCandidateUser(taskId, "kermit");
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
IdentityLink identityLink = identityLinks.get(0);
assertThat(identityLink.getGroupId()).isNull();
assertThat(identityLink.getUserId()).isEqualTo("kermit");
assertThat(identityLink.getType()).isEqualTo(IdentityLinkType.CANDIDATE);
assertThat(identityLink.getTaskId()).isEqualTo(taskId);
assertThat(identityLinks).hasSize(1);
taskService.deleteCandidateUser(taskId, "kermit");
assertThat(taskService.getIdentityLinksForTask(taskId)).hasSize(0);
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class TaskIdentityLinksTest method testEmptyCandidateUserLink.
@Deployment(resources = "org/activiti/engine/test/api/task/IdentityLinksProcess.bpmn20.xml")
public void testEmptyCandidateUserLink() {
runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.addCandidateGroup(taskId, "muppets");
taskService.deleteCandidateUser(taskId, "kermit");
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
assertThat(identityLinks).isNotNull();
assertThat(identityLinks).hasSize(1);
IdentityLink identityLink = identityLinks.get(0);
assertThat(identityLink.getGroupId()).isEqualTo("muppets");
assertThat(identityLink.getUserId()).isEqualTo(null);
assertThat(identityLink.getType()).isEqualTo(IdentityLinkType.CANDIDATE);
assertThat(identityLink.getTaskId()).isEqualTo(taskId);
taskService.deleteCandidateGroup(taskId, "muppets");
assertThat(taskService.getIdentityLinksForTask(taskId)).hasSize(0);
}
Aggregations