Search in sources :

Example 1 with IdentityLink

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

the class TaskInvolvedPeopleComponent method initInvolvedPeople.

protected void initInvolvedPeople() {
    List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
    for (final IdentityLink identityLink : identityLinks) {
        if (identityLink.getUserId() != null) {
            // only user identity links, ignoring the group ids
            if (!IdentityLinkType.ASSIGNEE.equals(identityLink.getType()) && !IdentityLinkType.OWNER.equals(identityLink.getType())) {
                UserDetailsComponent involvedDetails = new UserDetailsComponent(identityLink.getUserId(), identityLink.getType(), i18nManager.getMessage(Messages.TASK_INVOLVED_REMOVE), new RemoveInvolvedPersonListener(identityLink, task, taskDetailPanel));
                peopleGrid.addComponent(involvedDetails);
            }
        }
    }
}
Also used : RemoveInvolvedPersonListener(org.activiti.explorer.ui.task.listener.RemoveInvolvedPersonListener) IdentityLink(org.activiti.engine.task.IdentityLink)

Example 2 with IdentityLink

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

the class RestResponseFactory method createRestIdentityLinks.

public List<RestIdentityLink> createRestIdentityLinks(List<IdentityLink> links) {
    RestUrlBuilder urlBuilder = createUrlBuilder();
    List<RestIdentityLink> responseList = new ArrayList<RestIdentityLink>();
    for (IdentityLink instance : links) {
        responseList.add(createRestIdentityLink(instance, urlBuilder));
    }
    return responseList;
}
Also used : RestIdentityLink(org.activiti.rest.service.api.engine.RestIdentityLink) ArrayList(java.util.ArrayList) IdentityLink(org.activiti.engine.task.IdentityLink) HistoricIdentityLink(org.activiti.engine.history.HistoricIdentityLink) RestIdentityLink(org.activiti.rest.service.api.engine.RestIdentityLink)

Example 3 with IdentityLink

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

the class ProcessDefinitionIdentityLinksResourceTest method testDeleteCandidateStarterFromProcessDefinition.

@Deployment(resources = { "org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml" })
public void testDeleteCandidateStarterFromProcessDefinition() throws Exception {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    repositoryService.addCandidateStarterGroup(processDefinition.getId(), "admin");
    repositoryService.addCandidateStarterUser(processDefinition.getId(), "kermit");
    // Delete user candidate
    HttpDelete httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINK, processDefinition.getId(), "users", "kermit"));
    CloseableHttpResponse response = executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT);
    closeResponse(response);
    // Check if group-link remains
    List<IdentityLink> remainingLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
    assertEquals(1, remainingLinks.size());
    assertEquals("admin", remainingLinks.get(0).getGroupId());
    // Delete group candidate
    httpDelete = new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINK, processDefinition.getId(), "groups", "admin"));
    response = executeRequest(httpDelete, HttpStatus.SC_NO_CONTENT);
    closeResponse(response);
    // Check if all links are removed
    remainingLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
    assertEquals(0, remainingLinks.size());
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) IdentityLink(org.activiti.engine.task.IdentityLink) Deployment(org.activiti.engine.test.Deployment)

Example 4 with IdentityLink

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

the class DefaultViewManager method showTaskPage.

// Tasks 
/**
   * Generic method which will figure out to which
   * task page must be jumped, based on the task data.
   * 
   * Note that, if possible, it is always more
   * performant to use the more specific showXXXPage() methods.
   */
public void showTaskPage(String taskId) {
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
    String loggedInUserId = ExplorerApp.get().getLoggedInUser().getId();
    if (task == null) {
        // If no runtime task exists, our only hope is the archive page
        boolean isOwner = historyService.createHistoricTaskInstanceQuery().taskId(taskId).taskOwner(loggedInUserId).count() == 1;
        if (isOwner) {
            showArchivedPage(taskId);
        } else {
            showNavigationError(taskId);
        }
    } else if (loggedInUserId.equals(task.getOwner())) {
        showTasksPage(taskId);
    } else if (loggedInUserId.equals(task.getAssignee())) {
        showInboxPage(taskId);
    } else if (taskService.createTaskQuery().taskInvolvedUser(loggedInUserId).count() == 1) {
        showInvolvedPage(taskId);
    } else {
        // queued
        List<String> groupIds = getGroupIds(loggedInUserId);
        List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
        Iterator<IdentityLink> identityLinkIterator = identityLinks.iterator();
        boolean pageFound = false;
        while (!pageFound && identityLinkIterator.hasNext()) {
            IdentityLink identityLink = identityLinkIterator.next();
            if (identityLink.getGroupId() != null && groupIds.contains(identityLink.getGroupId())) {
                showQueuedPage(identityLink.getGroupId(), task.getId());
                pageFound = true;
            }
        }
        // We've tried hard enough, the user now gets a notification. He deserves it.
        if (!pageFound) {
            showNavigationError(taskId);
        }
    }
}
Also used : Task(org.activiti.engine.task.Task) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) IdentityLink(org.activiti.engine.task.IdentityLink)

Example 5 with IdentityLink

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

the class StartAuthorizationTest method testAddAndRemoveIdentityLinks.

@Deployment
public void testAddAndRemoveIdentityLinks() throws Exception {
    setUpUsersAndGroups();
    try {
        ProcessDefinition latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarterNoDefinition").singleResult();
        assertNotNull(latestProcessDef);
        List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(0, links.size());
        repositoryService.addCandidateStarterGroup(latestProcessDef.getId(), "group1");
        links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(1, links.size());
        assertEquals("group1", links.get(0).getGroupId());
        repositoryService.addCandidateStarterUser(latestProcessDef.getId(), "user1");
        links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(2, links.size());
        assertEquals(true, containsUserOrGroup(null, "group1", links));
        assertEquals(true, containsUserOrGroup("user1", null, links));
        repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), "nonexisting");
        links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(2, links.size());
        repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), "group1");
        links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(1, links.size());
        assertEquals("user1", links.get(0).getUserId());
        repositoryService.deleteCandidateStarterUser(latestProcessDef.getId(), "user1");
        links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(0, links.size());
    } finally {
        tearDownUsersAndGroups();
    }
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) IdentityLink(org.activiti.engine.task.IdentityLink) Deployment(org.activiti.engine.test.Deployment)

Aggregations

IdentityLink (org.activiti.engine.task.IdentityLink)60 Deployment (org.activiti.engine.test.Deployment)21 Task (org.activiti.engine.task.Task)16 ArrayList (java.util.ArrayList)10 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)8 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)8 RestIdentityLink (org.activiti.rest.service.api.engine.RestIdentityLink)8 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 List (java.util.List)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 TaskService (org.activiti.engine.TaskService)3 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