Search in sources :

Example 21 with CommandScript

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

the class UIServicesClientImpl method getProcessInstanceImage.

@Override
public String getProcessInstanceImage(String containerId, Long processInstanceId) {
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(RestURI.CONTAINER_ID, containerId);
        valuesMap.put(RestURI.PROCESS_INST_ID, processInstanceId);
        Map<String, String> headers = new HashMap<String, String>();
        headers.put("Accept", MediaType.APPLICATION_SVG_XML);
        return makeHttpGetRequestAndCreateRawResponse(build(loadBalancer.getUrl(), IMAGE_URI + "/" + PROCESS_INST_IMG_GET_URI, valuesMap), headers);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("ImageService", "getActiveProcessImage", new Object[] { containerId, processInstanceId })));
        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 22 with CommandScript

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

the class UserTaskServicesClientImpl method getTaskInstance.

@Override
public TaskInstance getTaskInstance(String containerId, Long taskId, boolean withInputs, boolean withOutputs, boolean withAssignments) {
    TaskInstance result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(TASK_INSTANCE_ID, taskId);
        StringBuilder queryString = new StringBuilder();
        queryString.append("?withInputData").append("=").append(withInputs).append("&withOutputData").append("=").append(withOutputs).append("&withAssignments").append("=").append(withAssignments);
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_GET_URI, valuesMap) + queryString.toString(), TaskInstance.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "getTask", marshaller.getFormat().getType(), new Object[] { containerId, taskId, withInputs, withOutputs, withAssignments })));
        ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = deserialize(response.getResult(), TaskInstance.class);
    }
    return result;
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) TaskInstance(org.kie.server.api.model.instance.TaskInstance) 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 23 with CommandScript

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

the class UserTaskServicesClientImpl method findTasksOwned.

@Override
public List<TaskSummary> findTasksOwned(String userId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    TaskSummaryList taskSummaryList = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        String queryString = getUserAndPagingQueryString(userId, page, pageSize) + "&sort=" + sort + "&sortOrder=" + sortOrder;
        taskSummaryList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + TASKS_OWNED_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksOwnedByStatus", new Object[] { 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 24 with CommandScript

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

the class UserTaskServicesClientImpl method setTaskName.

@Override
public void setTaskName(String containerId, Long taskId, String name) {
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(TASK_INSTANCE_ID, taskId);
        makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_NAME_PUT_URI, valuesMap), serialize(name), String.class, getHeaders(null));
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "setName", serialize(name), marshaller.getFormat().getType(), new Object[] { containerId, taskId })));
        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) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 25 with CommandScript

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

the class UserTaskServicesClientImpl method setTaskSkipable.

@Override
public void setTaskSkipable(String containerId, Long taskId, boolean skipable) {
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(TASK_INSTANCE_ID, taskId);
        makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_SKIPABLE_PUT_URI, valuesMap), serialize(skipable), String.class, getHeaders(null));
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "setSkipable", serialize(skipable), marshaller.getFormat().getType(), new Object[] { containerId, taskId })));
        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) 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