Search in sources :

Example 51 with IdentityLink

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;
}
Also used : ArrayList(java.util.ArrayList) IdentityLink(org.activiti.engine.task.IdentityLink)

Example 52 with IdentityLink

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;
}
Also used : ArrayList(java.util.ArrayList) IdentityLink(org.activiti.engine.task.IdentityLink)

Example 53 with IdentityLink

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);
}
Also used : Task(org.activiti.engine.task.Task) IdentityLink(org.activiti.engine.task.IdentityLink)

Example 54 with IdentityLink

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);
}
Also used : IdentityLink(org.activiti.engine.task.IdentityLink) Deployment(org.activiti.engine.test.Deployment)

Example 55 with IdentityLink

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);
}
Also used : IdentityLink(org.activiti.engine.task.IdentityLink) Deployment(org.activiti.engine.test.Deployment)

Aggregations

IdentityLink (org.activiti.engine.task.IdentityLink)64 Deployment (org.activiti.engine.test.Deployment)21 Task (org.activiti.engine.task.Task)16 ArrayList (java.util.ArrayList)13 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)8 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)8 RestIdentityLink (org.activiti.rest.service.api.engine.RestIdentityLink)7 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 List (java.util.List)4 TaskService (org.activiti.engine.TaskService)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 TaskQuery (org.activiti.engine.task.TaskQuery)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 IdentityLinkDto (eu.bcvsolutions.idm.core.workflow.model.dto.IdentityLinkDto)2 WorkflowProcessDefinitionDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto)2 WorkflowTaskInstanceDto (eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowTaskInstanceDto)2 RepositoryService (org.activiti.engine.RepositoryService)2