Search in sources :

Example 91 with DescriptorCommand

use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.

the class CaseServicesClientImpl method getActiveNodes.

@Override
public List<NodeInstance> getActiveNodes(String containerId, String caseId, Integer page, Integer pageSize) {
    NodeInstanceList list = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(CASE_ID, caseId);
        String queryString = getPagingQueryString("", page, pageSize);
        list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_NODE_INSTANCES_GET_URI, valuesMap) + queryString, NodeInstanceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getActiveNodes", new Object[] { containerId, caseId, page, pageSize })));
        ServiceResponse<NodeInstanceList> response = (ServiceResponse<NodeInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        list = response.getResult();
    }
    if (list != null) {
        return list.getItems();
    }
    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) CommandScript(org.kie.server.api.commands.CommandScript) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList)

Example 92 with DescriptorCommand

use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.

the class CaseServicesClientImpl method getCaseInstances.

@Override
public List<CaseInstance> getCaseInstances(List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder, boolean withData) {
    CaseInstanceList list = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        String queryString = getPagingQueryString("", page, pageSize);
        queryString = getAdditionalParams(queryString, "status", status);
        queryString = getSortingQueryString(queryString, sort, sortOrder);
        queryString = getAdditionalParams(queryString, "withData", Collections.singletonList(withData));
        list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_QUERY_URI + "/" + CASE_ALL_INSTANCES_GET_URI, valuesMap) + queryString, CaseInstanceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseInstancesAnyRole", new Object[] { safeList(status), page, pageSize, sort, sortOrder, withData })));
        ServiceResponse<CaseInstanceList> response = (ServiceResponse<CaseInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        list = response.getResult();
    }
    if (list != null) {
        return list.getItems();
    }
    return Collections.emptyList();
}
Also used : CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) 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) CommandScript(org.kie.server.api.commands.CommandScript)

Example 93 with DescriptorCommand

use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.

the class CaseServicesClientImpl method internalTriggerAdHoc.

protected void internalTriggerAdHoc(String containerId, String caseId, String stageId, String adHocName, Map<String, Object> data) {
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(CASE_ID, caseId);
        valuesMap.put(CASE_NODE_NAME, adHocName);
        if (stageId != null) {
            valuesMap.put(CASE_STAGE_ID, stageId);
            makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_DYNAMIC_TASK_IN_STAGE_PUT_URI, valuesMap), data, null, new HashMap<String, String>());
        } else {
            makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_DYNAMIC_TASK_PUT_URI, valuesMap), data, null, new HashMap<String, String>());
        }
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "triggerAdHocNode", serialize(safeMap(data)), marshaller.getFormat().getType(), new Object[] { containerId, caseId, emptyIfNull(stageId), emptyIfNull(adHocName) })));
        ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
        throwExceptionOnFailure(response);
    }
}
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) CommandScript(org.kie.server.api.commands.CommandScript)

Example 94 with DescriptorCommand

use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.

the class CaseServicesClientImpl method getProcessInstances.

@Override
public List<ProcessInstance> getProcessInstances(String containerId, String caseId, List<Integer> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    ProcessInstanceList list = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(CASE_ID, caseId);
        String queryString = getPagingQueryString("", page, pageSize);
        queryString = getAdditionalParams(queryString, "status", status);
        queryString = getSortingQueryString(queryString, sort, sortOrder);
        list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_PROCESS_INSTANCES_GET_URI, valuesMap) + queryString, ProcessInstanceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getProcessInstancesForCase", new Object[] { containerId, caseId, safeList(status), page, pageSize, sort, sortOrder })));
        ServiceResponse<ProcessInstanceList> response = (ServiceResponse<ProcessInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        list = response.getResult();
    }
    if (list != null) {
        return list.getItems();
    }
    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 95 with DescriptorCommand

use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.

the class DMNServicesClientImpl method evaluateDecisions.

/**
 * Please notice this method is NOT exposed to the API interface.
 */
// DO NOT ADD @Override
public ServiceResponse<DMNResult> evaluateDecisions(String containerId, DMNContextKS payload) {
    ServiceResponse<DMNResult> result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        result = (ServiceResponse<DMNResult>) (ServiceResponse<?>) makeHttpPostRequestAndCreateServiceResponse(build(loadBalancer.getUrl(), DMN_URI, valuesMap), payload, DMNResultKS.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("DMNService", "evaluateDecisions", serialize(payload), marshaller.getFormat().getType(), new Object[] { containerId })));
        result = (ServiceResponse<DMNResult>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_DMN, containerId).getResponses().get(0);
        throwExceptionOnFailure(result);
        if (shouldReturnWithNullResponse(result)) {
            return null;
        }
    }
    if (result instanceof Wrapped) {
        return (ServiceResponse<DMNResult>) ((Wrapped) result).unwrap();
    }
    ServiceResponse<DMNResult> result2 = (ServiceResponse<DMNResult>) result;
    // to manage scalar values when deserializing from JSON always as a BigDecimal instead of default Jackson NumberDeserializers
    if (config.getMarshallingFormat() == MarshallingFormat.JSON) {
        recurseAndModifyByCoercingNumbers(result2.getResult().getContext());
        for (DMNDecisionResult dr : result2.getResult().getDecisionResults()) {
            DMNDecisionResultKS drKS = (DMNDecisionResultKS) dr;
            drKS.setResult(recurseAndModifyByCoercingNumbers(dr.getResult()));
        }
    }
    return result2;
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) DMNResult(org.kie.dmn.api.core.DMNResult) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) DMNResultKS(org.kie.server.api.model.dmn.DMNResultKS) DMNDecisionResultKS(org.kie.server.api.model.dmn.DMNDecisionResultKS) ServiceResponse(org.kie.server.api.model.ServiceResponse) Wrapped(org.kie.server.api.model.Wrapped) DMNDecisionResult(org.kie.dmn.api.core.DMNDecisionResult)

Aggregations

DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)238 KieServerCommand (org.kie.server.api.model.KieServerCommand)234 ServiceResponse (org.kie.server.api.model.ServiceResponse)234 CommandScript (org.kie.server.api.commands.CommandScript)232 HashMap (java.util.HashMap)218 Wrapped (org.kie.server.api.model.Wrapped)31 ArrayList (java.util.ArrayList)24 ProcessInstanceList (org.kie.server.api.model.instance.ProcessInstanceList)18 TaskSummaryList (org.kie.server.api.model.instance.TaskSummaryList)16 NodeInstanceList (org.kie.server.api.model.instance.NodeInstanceList)14 ExecutionErrorInstanceList (org.kie.server.api.model.admin.ExecutionErrorInstanceList)8 ProcessDefinitionList (org.kie.server.api.model.definition.ProcessDefinitionList)8 VariableInstanceList (org.kie.server.api.model.instance.VariableInstanceList)8 RequestInfoInstanceList (org.kie.server.api.model.instance.RequestInfoInstanceList)7 CaseInstanceList (org.kie.server.api.model.cases.CaseInstanceList)6 Map (java.util.Map)5 ServiceResponsesList (org.kie.server.api.model.ServiceResponsesList)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 List (java.util.List)4 QueryDefinitionList (org.kie.server.api.model.definition.QueryDefinitionList)4