Search in sources :

Example 11 with IdentityLink

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

the class ProcessDefinitionIdentityLinkResource method getIdentityLink.

@RequestMapping(value = "/repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}", method = RequestMethod.GET, produces = "application/json")
public RestIdentityLink getIdentityLink(@PathVariable("processDefinitionId") String processDefinitionId, @PathVariable("family") String family, @PathVariable("identityId") String identityId, HttpServletRequest request) {
    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
    validateIdentityLinkArguments(family, identityId);
    // Check if identitylink to get exists
    IdentityLink link = getIdentityLink(family, identityId, processDefinition.getId());
    return restResponseFactory.createRestIdentityLink(link);
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) IdentityLink(org.activiti.engine.task.IdentityLink) RestIdentityLink(org.activiti.rest.service.api.engine.RestIdentityLink) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with IdentityLink

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

the class ProcessDefinitionIdentityLinkResource method getIdentityLink.

protected IdentityLink getIdentityLink(String family, String identityId, String processDefinitionId) {
    boolean isUser = family.equals(RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS);
    // Perhaps it would be better to offer getting a single identitylink from
    // the API
    List<IdentityLink> allLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinitionId);
    for (IdentityLink link : allLinks) {
        boolean rightIdentity = false;
        if (isUser) {
            rightIdentity = identityId.equals(link.getUserId());
        } else {
            rightIdentity = identityId.equals(link.getGroupId());
        }
        if (rightIdentity && link.getType().equals(IdentityLinkType.CANDIDATE)) {
            return link;
        }
    }
    throw new ActivitiObjectNotFoundException("Could not find the requested identity link.", IdentityLink.class);
}
Also used : ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) IdentityLink(org.activiti.engine.task.IdentityLink) RestIdentityLink(org.activiti.rest.service.api.engine.RestIdentityLink)

Example 13 with IdentityLink

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

the class TaskIdentityLinkFamilyResource method getIdentityLinksForFamily.

@RequestMapping(value = "/runtime/tasks/{taskId}/identitylinks/{family}", method = RequestMethod.GET, produces = "application/json")
public List<RestIdentityLink> getIdentityLinksForFamily(@PathVariable("taskId") String taskId, @PathVariable("family") String family, HttpServletRequest request) {
    Task task = getTaskFromRequest(taskId);
    if (family == null || (!RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_GROUPS.equals(family) && !RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS.equals(family))) {
        throw new ActivitiIllegalArgumentException("Identity link family should be 'users' or 'groups'.");
    }
    boolean isUser = family.equals(RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS);
    List<RestIdentityLink> results = new ArrayList<RestIdentityLink>();
    List<IdentityLink> allLinks = taskService.getIdentityLinksForTask(task.getId());
    for (IdentityLink link : allLinks) {
        boolean match = false;
        if (isUser) {
            match = link.getUserId() != null;
        } else {
            match = link.getGroupId() != null;
        }
        if (match) {
            results.add(restResponseFactory.createRestIdentityLink(link));
        }
    }
    return results;
}
Also used : Task(org.activiti.engine.task.Task) RestIdentityLink(org.activiti.rest.service.api.engine.RestIdentityLink) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ArrayList(java.util.ArrayList) RestIdentityLink(org.activiti.rest.service.api.engine.RestIdentityLink) IdentityLink(org.activiti.engine.task.IdentityLink) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with IdentityLink

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

the class TaskIdentityLinkResource method getIdentityLink.

protected IdentityLink getIdentityLink(String family, String identityId, String type, String taskId) {
    boolean isUser = family.equals(RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS);
    // Perhaps it would be better to offer getting a single identitylink from the API
    List<IdentityLink> allLinks = taskService.getIdentityLinksForTask(taskId);
    for (IdentityLink link : allLinks) {
        boolean rightIdentity = false;
        if (isUser) {
            rightIdentity = identityId.equals(link.getUserId());
        } else {
            rightIdentity = identityId.equals(link.getGroupId());
        }
        if (rightIdentity && link.getType().equals(type)) {
            return link;
        }
    }
    throw new ActivitiObjectNotFoundException("Could not find the requested identity link.", IdentityLink.class);
}
Also used : ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) IdentityLink(org.activiti.engine.task.IdentityLink) RestIdentityLink(org.activiti.rest.service.api.engine.RestIdentityLink)

Example 15 with IdentityLink

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

the class ProcessInstanceIdentityLinkResource method getIdentityLink.

@RequestMapping(value = "/runtime/process-instances/{processInstanceId}/identitylinks/users/{identityId}/{type}", method = RequestMethod.GET, produces = "application/json")
public RestIdentityLink getIdentityLink(@PathVariable("processInstanceId") String processInstanceId, @PathVariable("identityId") String identityId, @PathVariable("type") String type, HttpServletRequest request) {
    ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);
    validateIdentityLinkArguments(identityId, type);
    IdentityLink link = getIdentityLink(identityId, type, processInstance.getId());
    return restResponseFactory.createRestIdentityLink(link);
}
Also used : ProcessInstance(org.activiti.engine.runtime.ProcessInstance) IdentityLink(org.activiti.engine.task.IdentityLink) RestIdentityLink(org.activiti.rest.service.api.engine.RestIdentityLink) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IdentityLink (org.activiti.engine.task.IdentityLink)45 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)3 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