Search in sources :

Example 6 with IdentityLink

use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.

the class TaskIdentityLinksTest method testDeleteCandidateUser.

@Deployment(resources = "org/activiti/engine/test/api/task/TaskIdentityLinksTest.testDeleteCandidateUser.bpmn20.xml")
public void testDeleteCandidateUser() {
    runtimeService.startProcessInstanceByKey("TaskIdentityLinks");
    String taskId = taskService.createTaskQuery().singleResult().getId();
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
    assertEquals(1, identityLinks.size());
    IdentityLink identityLink = identityLinks.get(0);
    assertEquals("user", identityLink.getUserId());
}
Also used : IdentityLink(org.activiti.engine.task.IdentityLink) Deployment(org.activiti.engine.test.Deployment)

Example 7 with IdentityLink

use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.

the class TaskIdentityLinksTest method testCustomTypeUserLink.

@Deployment(resources = "org/activiti/engine/test/api/task/IdentityLinksProcess.bpmn20.xml")
public void testCustomTypeUserLink() {
    runtimeService.startProcessInstanceByKey("IdentityLinksProcess");
    String taskId = taskService.createTaskQuery().singleResult().getId();
    taskService.addUserIdentityLink(taskId, "kermit", "interestee");
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
    IdentityLink identityLink = identityLinks.get(0);
    assertNull(identityLink.getGroupId());
    assertEquals("kermit", identityLink.getUserId());
    assertEquals("interestee", identityLink.getType());
    assertEquals(taskId, identityLink.getTaskId());
    assertEquals(1, identityLinks.size());
    taskService.deleteUserIdentityLink(taskId, "kermit", "interestee");
    assertEquals(0, taskService.getIdentityLinksForTask(taskId).size());
}
Also used : IdentityLink(org.activiti.engine.task.IdentityLink) Deployment(org.activiti.engine.test.Deployment)

Example 8 with IdentityLink

use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.

the class TaskIdentityLinksTest method testCustomIdentityLink.

// Test custom identity links
@Deployment
public void testCustomIdentityLink() {
    runtimeService.startProcessInstanceByKey("customIdentityLink");
    List<Task> tasks = taskService.createTaskQuery().taskInvolvedUser("kermit").list();
    assertEquals(1, tasks.size());
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(tasks.get(0).getId());
    assertEquals(2, identityLinks.size());
    for (IdentityLink idLink : identityLinks) {
        assertEquals("businessAdministrator", idLink.getType());
        String userId = idLink.getUserId();
        if (userId == null) {
            assertEquals("management", idLink.getGroupId());
        } else {
            assertEquals("kermit", userId);
        }
    }
}
Also used : Task(org.activiti.engine.task.Task) IdentityLink(org.activiti.engine.task.IdentityLink) Deployment(org.activiti.engine.test.Deployment)

Example 9 with IdentityLink

use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.

the class TaskServiceTest method testGetIdentityLinksWithAssignee.

public void testGetIdentityLinksWithAssignee() {
    Task task = taskService.newTask();
    taskService.saveTask(task);
    String taskId = task.getId();
    identityService.saveUser(identityService.newUser("kermit"));
    taskService.claim(taskId, "kermit");
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(taskId);
    assertEquals(1, identityLinks.size());
    assertEquals("kermit", identityLinks.get(0).getUserId());
    assertNull(identityLinks.get(0).getGroupId());
    assertEquals(IdentityLinkType.ASSIGNEE, identityLinks.get(0).getType());
    //cleanup
    taskService.deleteTask(taskId, true);
    identityService.deleteUser("kermit");
}
Also used : Task(org.activiti.engine.task.Task) IdentityLink(org.activiti.engine.task.IdentityLink)

Example 10 with IdentityLink

use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.

the class GetIdentityLinksForProcessDefinitionCmd method execute.

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<IdentityLink> execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = commandContext.getProcessDefinitionEntityManager().findProcessDefinitionById(processDefinitionId);
    if (processDefinition == null) {
        throw new ActivitiObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class);
    }
    List<IdentityLink> identityLinks = (List) processDefinition.getIdentityLinks();
    return identityLinks;
}
Also used : List(java.util.List) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) IdentityLink(org.activiti.engine.task.IdentityLink)

Aggregations

IdentityLink (org.activiti.engine.task.IdentityLink)46 Deployment (org.activiti.engine.test.Deployment)21 Task (org.activiti.engine.task.Task)15 RestIdentityLink (org.activiti.rest.service.api.engine.RestIdentityLink)8 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)7 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 ArrayList (java.util.ArrayList)4 List (java.util.List)3 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)3 TaskService (org.activiti.engine.TaskService)3 ActivitiEntityEvent (org.activiti.engine.delegate.event.ActivitiEntityEvent)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 SystemException (com.evolveum.midpoint.util.exception.SystemException)2 Event (org.activiti.engine.task.Event)2 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)1 ObjectTypeUtil.toShortString (com.evolveum.midpoint.schema.util.ObjectTypeUtil.toShortString)1