Search in sources :

Example 16 with ProcessDefinitionList

use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.

the class CaseServicesClientImpl method findProcesses.

@Override
public List<ProcessDefinition> findProcesses(String filter, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    ProcessDefinitionList result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        String queryString = getPagingQueryString("?filter=" + filter + "&sort=" + sort + "&sortOrder=" + sortOrder, page, pageSize);
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_QUERY_URI + "/" + CASE_ALL_PROCESSES_INSTANCES_GET_URI, valuesMap) + queryString, ProcessDefinitionList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getProcessDefinitions", new Object[] { filter, "", page, pageSize, sort, sortOrder })));
        ServiceResponse<ProcessDefinitionList> response = (ServiceResponse<ProcessDefinitionList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null && result.getProcesses() != null) {
        return Arrays.asList(result.getProcesses());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) CommandScript(org.kie.server.api.commands.CommandScript)

Example 17 with ProcessDefinitionList

use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.

the class CaseServicesClientImpl method findProcessesByContainerId.

@Override
public List<ProcessDefinition> findProcessesByContainerId(String containerId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    ProcessDefinitionList result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        String queryString = getPagingQueryString("?sort=" + sort + "&sortOrder=" + sortOrder, page, pageSize);
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_QUERY_URI + "/" + CASE_PROCESSES_BY_CONTAINER_INSTANCES_GET_URI, valuesMap) + queryString, ProcessDefinitionList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getProcessDefinitions", new Object[] { "", containerId, page, pageSize, sort, sortOrder })));
        ServiceResponse<ProcessDefinitionList> response = (ServiceResponse<ProcessDefinitionList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null && result.getProcesses() != null) {
        return Arrays.asList(result.getProcesses());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) CommandScript(org.kie.server.api.commands.CommandScript)

Example 18 with ProcessDefinitionList

use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.

the class CaseManagementRuntimeDataServiceBase method getProcessDefinitions.

public ProcessDefinitionList getProcessDefinitions(String filter, String containerId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    Collection<org.jbpm.services.api.model.ProcessDefinition> processDescs = null;
    sort = safeCaseDefinitionSort(sort);
    if (containerId != null && !containerId.isEmpty()) {
        try {
            containerId = context.getContainerId(containerId, ContainerLocatorProvider.get().getLocator());
        } catch (IllegalArgumentException e) {
        // container was not found by locator use given
        }
        processDescs = caseRuntimeDataService.getProcessDefinitionsByDeployment(containerId, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
    } else if (filter != null && !filter.isEmpty()) {
        processDescs = caseRuntimeDataService.getProcessDefinitions(filter, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
    } else {
        processDescs = caseRuntimeDataService.getProcessDefinitions(ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
    }
    ProcessDefinitionList processDefinitions = ConvertUtils.transformProcesses(processDescs);
    return processDefinitions;
}
Also used : ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList)

Example 19 with ProcessDefinitionList

use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.

the class ConvertUtils method transformProcesses.

public static ProcessDefinitionList transformProcesses(Collection<ProcessDefinition> definitions) {
    if (definitions == null) {
        return new ProcessDefinitionList(new org.kie.server.api.model.definition.ProcessDefinition[0]);
    }
    List<org.kie.server.api.model.definition.ProcessDefinition> processes = new ArrayList<org.kie.server.api.model.definition.ProcessDefinition>(definitions.size());
    for (ProcessDefinition pd : definitions) {
        org.kie.server.api.model.definition.ProcessDefinition definition = transformProcess(pd);
        processes.add(definition);
    }
    return new ProcessDefinitionList(processes);
}
Also used : ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) ArrayList(java.util.ArrayList) ProcessDefinition(org.jbpm.services.api.model.ProcessDefinition)

Aggregations

ProcessDefinitionList (org.kie.server.api.model.definition.ProcessDefinitionList)19 ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 HashMap (java.util.HashMap)6 GET (javax.ws.rs.GET)6 Produces (javax.ws.rs.Produces)6 ServiceResponse (org.kie.server.api.model.ServiceResponse)6 Header (org.kie.server.remote.rest.common.Header)6 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)6 Path (javax.ws.rs.Path)5 ProcessDefinition (org.jbpm.services.api.model.ProcessDefinition)5 CommandScript (org.kie.server.api.commands.CommandScript)5 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)5 KieServerCommand (org.kie.server.api.model.KieServerCommand)5 Variant (javax.ws.rs.core.Variant)3 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)3 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)3 ArrayList (java.util.ArrayList)2 WebTarget (javax.ws.rs.client.WebTarget)1 Response (javax.ws.rs.core.Response)1