Search in sources :

Example 91 with CommandScript

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

the class CaseServicesClientImpl method getCaseInstancesOwnedBy.

@Override
public List<CaseInstance> getCaseInstancesOwnedBy(String owner, 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("?owner=" + owner, 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", "getCaseInstancesOwnedBy", new Object[] { owner, 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 92 with CommandScript

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

the class CaseServicesClientImpl method getComments.

@Override
public List<CaseComment> getComments(String containerId, String caseId, String sortBy, Integer page, Integer pageSize) {
    CaseCommentList 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("?sort=" + sortBy, page, pageSize);
        list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_COMMENTS_GET_URI, valuesMap) + queryString, CaseCommentList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "getComments", new Object[] { containerId, caseId, sortBy, page, pageSize })));
        ServiceResponse<CaseCommentList> response = (ServiceResponse<CaseCommentList>) 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) CaseCommentList(org.kie.server.api.model.cases.CaseCommentList) 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 CommandScript

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

the class CaseServicesClientImpl method getCaseInstance.

@Override
public CaseInstance getCaseInstance(String containerId, String caseId, boolean withData, boolean withRoles, boolean withMilestones, boolean withStages) {
    CaseInstance caseInstance = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(CASE_ID, caseId);
        String queryString = "?withData=" + withData + "&withRoles=" + withRoles + "&withMilestones=" + withMilestones + "&withStages=" + withStages;
        caseInstance = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_INSTANCE_GET_URI, valuesMap) + queryString, CaseInstance.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "getCaseInstance", marshaller.getFormat().getType(), new Object[] { containerId, caseId, withData, withRoles, withMilestones, withStages })));
        ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        caseInstance = deserialize(response.getResult(), CaseInstance.class);
    }
    return caseInstance;
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) CaseInstance(org.kie.server.api.model.cases.CaseInstance) 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 CommandScript

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

the class CaseServicesClientImpl method putCaseInstanceData.

@Override
public void putCaseInstanceData(String containerId, String caseId, String name, Object data, List<String> restrictions) {
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(CASE_ID, caseId);
        valuesMap.put(CASE_FILE_ITEM, name);
        String queryString = getAdditionalParams("", "restrictedTo", restrictions);
        makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_FILE_BY_NAME_POST_URI, valuesMap) + queryString, data, null);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "putCaseFileDataByName", serialize(data), marshaller.getFormat().getType(), new Object[] { containerId, caseId, name, safeList(restrictions) })));
        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 95 with CommandScript

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

the class CaseServicesClientImpl method internalAddDynamicTask.

protected void internalAddDynamicTask(String containerId, String caseId, String stageId, Map<String, Object> taskSpecMap) {
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(CASE_ID, caseId);
        if (stageId != null) {
            valuesMap.put(CASE_STAGE_ID, stageId);
            makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_DYNAMIC_TASK_IN_STAGE_POST_URI, valuesMap), taskSpecMap, null);
        } else {
            makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_DYNAMIC_TASK_POST_URI, valuesMap), taskSpecMap, null);
        }
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "addDynamicTask", serialize(taskSpecMap), marshaller.getFormat().getType(), new Object[] { containerId, caseId, emptyIfNull(stageId) })));
        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)

Aggregations

CommandScript (org.kie.server.api.commands.CommandScript)275 ServiceResponse (org.kie.server.api.model.ServiceResponse)269 KieServerCommand (org.kie.server.api.model.KieServerCommand)256 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)232 HashMap (java.util.HashMap)218 Wrapped (org.kie.server.api.model.Wrapped)27 ArrayList (java.util.ArrayList)22 ProcessInstanceList (org.kie.server.api.model.instance.ProcessInstanceList)18 ServiceResponsesList (org.kie.server.api.model.ServiceResponsesList)17 TaskSummaryList (org.kie.server.api.model.instance.TaskSummaryList)16 NodeInstanceList (org.kie.server.api.model.instance.NodeInstanceList)14 WebSocketServiceResponse (org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse)12 KieContainerResource (org.kie.server.api.model.KieContainerResource)9 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 CallContainerCommand (org.kie.server.api.commands.CallContainerCommand)5