Search in sources :

Example 11 with CommandScript

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

the class SolverServicesClientImpl method solvePlanningProblem.

@Override
public void solvePlanningProblem(String containerId, String solverId, Object planningProblem) {
    checkMandatoryParameter("ContainerID", containerId);
    checkMandatoryParameter("SolverId", solverId);
    checkMandatoryParameter("planningSolution", planningProblem);
    if (config.isRest()) {
        String uri = getURI(containerId, solverId) + "/" + RestURI.SOLVER_STATE_RUNNING;
        makeHttpPostRequestAndCreateCustomResponse(uri, planningProblem, ServiceResponse.class, getHeaders(planningProblem));
    } else {
        CommandScript script = new CommandScript(Collections.singletonList(new SolvePlanningProblemCommand(containerId, solverId, serialize(planningProblem))));
        ServiceResponse<Void> response = (ServiceResponse<Void>) executeJmsCommand(script, SolvePlanningProblemCommand.class.getName(), KieServerConstants.CAPABILITY_BRP, containerId).getResponses().get(0);
        throwExceptionOnFailure(response);
    }
}
Also used : ServiceResponse(org.kie.server.api.model.ServiceResponse) SolvePlanningProblemCommand(org.kie.server.api.commands.optaplanner.SolvePlanningProblemCommand) CommandScript(org.kie.server.api.commands.CommandScript)

Example 12 with CommandScript

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

the class SolverServicesClientImpl method terminateSolverEarly.

@Override
public void terminateSolverEarly(String containerId, String solverId) {
    checkMandatoryParameter("ContainerID", containerId);
    checkMandatoryParameter("SolverId", solverId);
    if (config.isRest()) {
        String uri = getURI(containerId, solverId) + "/" + RestURI.SOLVER_STATE_TERMINATING;
        makeHttpPostRequestAndCreateCustomResponse(uri, "", ServiceResponse.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList(new TerminateSolverEarlyCommand(containerId, solverId)));
        ServiceResponse<Void> response = (ServiceResponse<Void>) executeJmsCommand(script, TerminateSolverEarlyCommand.class.getName(), KieServerConstants.CAPABILITY_BRP, containerId).getResponses().get(0);
        throwExceptionOnFailure(response);
    }
}
Also used : ServiceResponse(org.kie.server.api.model.ServiceResponse) CommandScript(org.kie.server.api.commands.CommandScript) TerminateSolverEarlyCommand(org.kie.server.api.commands.optaplanner.TerminateSolverEarlyCommand)

Example 13 with CommandScript

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

the class UIServicesClientImpl method getProcessFormByType.

private String getProcessFormByType(String containerId, String processId, String language, String formType, boolean marshallContent) {
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(RestURI.CONTAINER_ID, containerId);
        valuesMap.put(RestURI.PROCESS_ID, processId);
        StringBuffer params = new StringBuffer();
        params.append("type=").append(formType);
        params.append("&marshallContent=").append(marshallContent);
        boolean filter = false;
        if (!StringUtils.isEmpty(language)) {
            params.append("&lang=").append(language);
            filter = true;
        }
        params.append("&filter=").append(filter);
        return makeHttpGetRequestAndCreateRawResponse(build(loadBalancer.getUrl(), FORM_URI + "/" + PROCESS_FORM_GET_URI, valuesMap) + "?" + params.toString());
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("FormService", "getFormDisplayProcess", new Object[] { containerId, processId, StringUtils.defaultString(language), !StringUtils.isEmpty(language), formType })));
        ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM-UI", containerId).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        return response.getResult();
    }
}
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 14 with CommandScript

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

the class UserTaskServicesClientImpl method findTasksAssignedAsPotentialOwner.

@Override
public List<TaskSummary> findTasksAssignedAsPotentialOwner(String userId, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    TaskSummaryList taskSummaryList = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        String userQuery = getUserQueryStr(userId);
        String statusQuery = getAdditionalParams(userQuery, "status", status);
        String queryString = getPagingQueryString(statusQuery, page, pageSize) + "&sort=" + sort + "&sortOrder=" + sortOrder;
        taskSummaryList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + TASKS_ASSIGN_POT_OWNERS_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksAssignedAsPotentialOwner", new Object[] { safeList(status), new ArrayList(), userId, page, pageSize, sort, sortOrder })));
        ServiceResponse<TaskSummaryList> response = (ServiceResponse<TaskSummaryList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        taskSummaryList = response.getResult();
    }
    if (taskSummaryList != null && taskSummaryList.getTasks() != null) {
        return Arrays.asList(taskSummaryList.getTasks());
    }
    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) ArrayList(java.util.ArrayList) CommandScript(org.kie.server.api.commands.CommandScript) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

Example 15 with CommandScript

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

the class UserTaskServicesClientImpl method claimTask.

@Override
public void claimTask(String containerId, Long taskId, String userId) {
    if (config.isRest()) {
        sendTaskOperation(containerId, taskId, TASK_URI + "/" + TASK_INSTANCE_CLAIM_PUT_URI, getUserQueryStr(userId));
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "claim", new Object[] { containerId, taskId, userId })));
        ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).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) 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