Search in sources :

Example 1 with RestIdentityLink

use of org.activiti.rest.service.api.engine.RestIdentityLink 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 2 with RestIdentityLink

use of org.activiti.rest.service.api.engine.RestIdentityLink 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 3 with RestIdentityLink

use of org.activiti.rest.service.api.engine.RestIdentityLink 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 4 with RestIdentityLink

use of org.activiti.rest.service.api.engine.RestIdentityLink 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)

Example 5 with RestIdentityLink

use of org.activiti.rest.service.api.engine.RestIdentityLink in project Activiti by Activiti.

the class RestResponseFactory method createRestIdentityLink.

public RestIdentityLink createRestIdentityLink(String type, String userId, String groupId, String taskId, String processDefinitionId, String processInstanceId, RestUrlBuilder urlBuilder) {
    RestIdentityLink result = new RestIdentityLink();
    result.setUser(userId);
    result.setGroup(groupId);
    result.setType(type);
    String family = null;
    if (userId != null) {
        family = RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS;
    } else {
        family = RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_GROUPS;
    }
    if (processDefinitionId != null) {
        result.setUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINK, processDefinitionId, family, (userId != null ? userId : groupId)));
    } else if (taskId != null) {
        result.setUrl(urlBuilder.buildUrl(RestUrls.URL_TASK_IDENTITYLINK, taskId, family, (userId != null ? userId : groupId), type));
    } else {
        result.setUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINK, processInstanceId, (userId != null ? userId : groupId), type));
    }
    return result;
}
Also used : RestIdentityLink(org.activiti.rest.service.api.engine.RestIdentityLink)

Aggregations

RestIdentityLink (org.activiti.rest.service.api.engine.RestIdentityLink)6 IdentityLink (org.activiti.engine.task.IdentityLink)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ArrayList (java.util.ArrayList)2 Task (org.activiti.engine.task.Task)2 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 HistoricIdentityLink (org.activiti.engine.history.HistoricIdentityLink)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1