Search in sources :

Example 1 with ProcessInstanceList

use of org.kie.server.api.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.

the class QueryServicesClientImpl method findProcessInstancesByStatus.

@Override
public List<ProcessInstance> findProcessInstancesByStatus(List<Integer> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    ProcessInstanceList result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        String statusQueryString = getAdditionalParams("?sort=" + sort + "&sortOrder=" + sortOrder, "status", status);
        String queryString = getPagingQueryString(statusQueryString, page, pageSize);
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_INSTANCES_GET_URI, valuesMap) + queryString, ProcessInstanceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstances", new Object[] { safeList(status), "", "", page, pageSize, sort, sortOrder })));
        ServiceResponse<ProcessInstanceList> response = (ServiceResponse<ProcessInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null && result.getProcessInstances() != null) {
        return Arrays.asList(result.getProcessInstances());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ProcessInstanceList(org.kie.server.api.model.instance.ProcessInstanceList) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 2 with ProcessInstanceList

use of org.kie.server.api.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.

the class QueryServicesClientImpl method findProcessInstancesByContainerId.

@Override
public List<ProcessInstance> findProcessInstancesByContainerId(String containerId, List<Integer> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    ProcessInstanceList result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        String statusQueryString = getAdditionalParams("?sort=" + sort + "&sortOrder=" + sortOrder, "status", status);
        String queryString = getPagingQueryString(statusQueryString, page, pageSize);
        result = makeHttpGetRequestAndCreateCustomResponseWithHandleNotFound(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_INSTANCES_BY_CONTAINER_ID_GET_URI, valuesMap) + queryString, ProcessInstanceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstancesByDeploymentId", new Object[] { containerId, safeList(status), page, pageSize, sort, sortOrder })));
        ServiceResponse<ProcessInstanceList> response = (ServiceResponse<ProcessInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null && result.getProcessInstances() != null) {
        return Arrays.asList(result.getProcessInstances());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ProcessInstanceList(org.kie.server.api.model.instance.ProcessInstanceList) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 3 with ProcessInstanceList

use of org.kie.server.api.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.

the class QueryServicesClientImpl method findProcessInstancesByProcessIdAndInitiator.

@Override
public List<ProcessInstance> findProcessInstancesByProcessIdAndInitiator(String processId, String initiator, List<Integer> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    ProcessInstanceList result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(PROCESS_ID, processId);
        String statusQueryString = getAdditionalParams("?initiator=" + initiator + "&sort=" + sort + "&sortOrder=" + sortOrder, "status", status);
        String queryString = getPagingQueryString(statusQueryString, page, pageSize);
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_INSTANCES_BY_PROCESS_ID_GET_URI, valuesMap) + queryString, ProcessInstanceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstancesByProcessId", new Object[] { processId, safeList(status), initiator, page, pageSize, sort, sortOrder })));
        ServiceResponse<ProcessInstanceList> response = (ServiceResponse<ProcessInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null && result.getProcessInstances() != null) {
        return Arrays.asList(result.getProcessInstances());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ProcessInstanceList(org.kie.server.api.model.instance.ProcessInstanceList) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 4 with ProcessInstanceList

use of org.kie.server.api.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.

the class QueryServicesClientImpl method findProcessInstancesByVariable.

@Override
public List<ProcessInstance> findProcessInstancesByVariable(String variableName, List<Integer> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    ProcessInstanceList result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(VAR_NAME, variableName);
        String statusQueryString = getAdditionalParams("?sort=" + sort + "&sortOrder=" + sortOrder, "status", status);
        String queryString = getPagingQueryString(statusQueryString, page, pageSize);
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_INSTANCE_BY_VAR_NAME_GET_URI, valuesMap) + queryString, ProcessInstanceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstanceByVariables", new Object[] { variableName, "", safeList(status), page, pageSize, sort, sortOrder })));
        ServiceResponse<ProcessInstanceList> response = (ServiceResponse<ProcessInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null && result.getProcessInstances() != null) {
        return Arrays.asList(result.getProcessInstances());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ProcessInstanceList(org.kie.server.api.model.instance.ProcessInstanceList) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 5 with ProcessInstanceList

use of org.kie.server.api.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.

the class QueryServicesClientImpl method findProcessInstancesByCorrelationKey.

@Override
public List<ProcessInstance> findProcessInstancesByCorrelationKey(CorrelationKey correlationKey, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    ProcessInstanceList result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CORRELATION_KEY, correlationKey.toExternalForm());
        String queryString = getPagingQueryString("?sort=" + sort + "&sortOrder=" + sortOrder, page, pageSize);
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_INSTANCES_BY_CORRELATION_KEY_GET_URI, valuesMap) + queryString, ProcessInstanceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstancesByCorrelationKey", new Object[] { correlationKey.toExternalForm(), page, pageSize, sort, sortOrder })));
        ServiceResponse<ProcessInstanceList> response = (ServiceResponse<ProcessInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null && result.getProcessInstances() != null) {
        return Arrays.asList(result.getProcessInstances());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ProcessInstanceList(org.kie.server.api.model.instance.ProcessInstanceList) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Aggregations

ProcessInstanceList (org.kie.server.api.model.instance.ProcessInstanceList)34 HashMap (java.util.HashMap)15 CommandScript (org.kie.server.api.commands.CommandScript)14 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)14 KieServerCommand (org.kie.server.api.model.KieServerCommand)14 ServiceResponse (org.kie.server.api.model.ServiceResponse)14 GET (javax.ws.rs.GET)9 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)9 ApiOperation (io.swagger.annotations.ApiOperation)8 ApiResponses (io.swagger.annotations.ApiResponses)8 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)8 Header (org.kie.server.remote.rest.common.Header)8 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)7 ConvertUtils.convertToProcessInstanceList (org.kie.server.services.jbpm.ConvertUtils.convertToProcessInstanceList)6 ArrayList (java.util.ArrayList)5 Variant (javax.ws.rs.core.Variant)4 ProcessInstance (org.kie.server.api.model.instance.ProcessInstance)4 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)3 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)2