use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class GetIdentityLinksForTaskCmd method execute.
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<IdentityLink> execute(CommandContext commandContext) {
ensureNotNull("taskId", taskId);
TaskManager taskManager = commandContext.getTaskManager();
TaskEntity task = taskManager.findTaskById(taskId);
ensureNotNull("Cannot find task with id " + taskId, "task", task);
checkGetIdentityLink(task, commandContext);
List<IdentityLink> identityLinks = (List) task.getIdentityLinks();
// and of course this leads to exception while trying to delete a non-existing identityLink
if (task.getAssignee() != null) {
IdentityLinkEntity identityLink = new IdentityLinkEntity();
identityLink.setUserId(task.getAssignee());
identityLink.setTask(task);
identityLink.setType(IdentityLinkType.ASSIGNEE);
identityLinks.add(identityLink);
}
if (task.getOwner() != null) {
IdentityLinkEntity identityLink = new IdentityLinkEntity();
identityLink.setUserId(task.getOwner());
identityLink.setTask(task);
identityLink.setType(IdentityLinkType.OWNER);
identityLinks.add(identityLink);
}
return (List) task.getIdentityLinks();
}
use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testGetIdentityLinksWithNonExistingOwner.
@Test
public void testGetIdentityLinksWithNonExistingOwner() {
Task task = taskService.newTask();
taskService.saveTask(task);
String taskId = task.getId();
taskService.claim(taskId, "nonExistingOwner");
taskService.delegateTask(taskId, "nonExistingAssignee");
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
assertEquals(2, identityLinks.size());
IdentityLink assignee = identityLinks.get(0);
assertEquals("nonExistingAssignee", assignee.getUserId());
assertNull(assignee.getGroupId());
assertEquals(IdentityLinkType.ASSIGNEE, assignee.getType());
IdentityLink owner = identityLinks.get(1);
assertEquals("nonExistingOwner", owner.getUserId());
assertNull(owner.getGroupId());
assertEquals(IdentityLinkType.OWNER, owner.getType());
// cleanup
taskService.deleteTask(taskId, true);
}
use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testGetIdentityLinksWithNonExistingAssignee.
@Test
public void testGetIdentityLinksWithNonExistingAssignee() {
Task task = taskService.newTask();
taskService.saveTask(task);
String taskId = task.getId();
taskService.claim(taskId, "nonExistingAssignee");
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
assertEquals(1, identityLinks.size());
assertEquals("nonExistingAssignee", identityLinks.get(0).getUserId());
assertNull(identityLinks.get(0).getGroupId());
assertEquals(IdentityLinkType.ASSIGNEE, identityLinks.get(0).getType());
// cleanup
taskService.deleteTask(taskId, true);
}
use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class TaskServiceTest method testGetIdentityLinksWithCandidateGroup.
@Test
public void testGetIdentityLinksWithCandidateGroup() {
Task task = taskService.newTask();
taskService.saveTask(task);
String taskId = task.getId();
identityService.saveGroup(identityService.newGroup("muppets"));
taskService.addCandidateGroup(taskId, "muppets");
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
assertEquals(1, identityLinks.size());
assertEquals("muppets", identityLinks.get(0).getGroupId());
assertNull(identityLinks.get(0).getUserId());
assertEquals(IdentityLinkType.CANDIDATE, identityLinks.get(0).getType());
// cleanup
taskService.deleteTask(taskId, true);
identityService.deleteGroup("muppets");
}
use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.
the class StartAuthorizationTest method testIdentityLinks.
@Deployment
public void testIdentityLinks() throws Exception {
setUpUsersAndGroups();
try {
ProcessDefinition latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process1").singleResult();
assertNotNull(latestProcessDef);
List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(0, links.size());
latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process2").singleResult();
assertNotNull(latestProcessDef);
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(2, links.size());
assertEquals(true, containsUserOrGroup("user1", null, links));
assertEquals(true, containsUserOrGroup("user2", null, links));
latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process3").singleResult();
assertNotNull(latestProcessDef);
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(1, links.size());
assertEquals("user1", links.get(0).getUserId());
latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("process4").singleResult();
assertNotNull(latestProcessDef);
links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
assertEquals(4, links.size());
assertEquals(true, containsUserOrGroup("userInGroup2", null, links));
assertEquals(true, containsUserOrGroup(null, "group1", links));
assertEquals(true, containsUserOrGroup(null, "group2", links));
assertEquals(true, containsUserOrGroup(null, "group3", links));
} finally {
tearDownUsersAndGroups();
}
}
Aggregations