Search in sources :

Example 31 with ServiceResponse

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

the class UserTaskServicesClientImpl method getTaskAttachmentsByTaskId.

@Override
public List<TaskAttachment> getTaskAttachmentsByTaskId(String containerId, Long taskId) {
    TaskAttachmentList attachmentList = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(TASK_INSTANCE_ID, taskId);
        attachmentList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_ATTACHMENTS_GET_URI, valuesMap), TaskAttachmentList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "getAttachmentsByTaskId", marshaller.getFormat().getType(), new Object[] { containerId, taskId })));
        ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        attachmentList = deserialize(response.getResult(), TaskAttachmentList.class);
        ;
    }
    if (attachmentList.getTasks() != null) {
        return Arrays.asList(attachmentList.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) TaskAttachmentList(org.kie.server.api.model.instance.TaskAttachmentList) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 32 with ServiceResponse

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

the class UserTaskServicesClientImpl method suspendTask.

@Override
public void suspendTask(String containerId, Long taskId, String userId, Map<String, Object> parameters) {
    if (config.isRest()) {
        sendTaskOperation(containerId, taskId, TASK_URI + "/" + TASK_INSTANCE_SUSPEND_PUT_URI, getUserQueryStr(userId), parameters);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "suspend", serialize(safeMap(parameters)), marshaller.getFormat().getType(), 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)

Example 33 with ServiceResponse

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

the class UserTaskServicesClientImpl method getTaskInstance.

@Override
public TaskInstance getTaskInstance(String containerId, Long taskId) {
    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);
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_GET_URI, valuesMap), TaskInstance.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "getTask", marshaller.getFormat().getType(), new Object[] { containerId, taskId, false, false, false })));
        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 34 with ServiceResponse

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

the class UserTaskServicesClientImpl method setTaskExpirationDate.

@Override
public void setTaskExpirationDate(String containerId, Long taskId, Date date) {
    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_EXPIRATION_DATE_PUT_URI, valuesMap), serialize(date), String.class, getHeaders(null));
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "setExpirationDate", serialize(date), 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 35 with ServiceResponse

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

the class UserTaskServicesClientImpl method exitTask.

@Override
public void exitTask(String containerId, Long taskId, String userId) {
    if (config.isRest()) {
        sendTaskOperation(containerId, taskId, TASK_URI + "/" + TASK_INSTANCE_EXIT_PUT_URI, getUserQueryStr(userId));
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "exit", 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

ServiceResponse (org.kie.server.api.model.ServiceResponse)315 CommandScript (org.kie.server.api.commands.CommandScript)269 KieServerCommand (org.kie.server.api.model.KieServerCommand)261 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)234 HashMap (java.util.HashMap)224 ArrayList (java.util.ArrayList)41 Wrapped (org.kie.server.api.model.Wrapped)32 ServiceResponsesList (org.kie.server.api.model.ServiceResponsesList)23 KieContainerResource (org.kie.server.api.model.KieContainerResource)18 ProcessInstanceList (org.kie.server.api.model.instance.ProcessInstanceList)18 TaskSummaryList (org.kie.server.api.model.instance.TaskSummaryList)17 NodeInstanceList (org.kie.server.api.model.instance.NodeInstanceList)15 Map (java.util.Map)13 Message (org.kie.server.api.model.Message)13 WebSocketServiceResponse (org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse)13 Test (org.junit.Test)11 List (java.util.List)9 ReleaseId (org.kie.server.api.model.ReleaseId)9 ProcessDefinitionList (org.kie.server.api.model.definition.ProcessDefinitionList)9 ExecutionErrorInstanceList (org.kie.server.api.model.admin.ExecutionErrorInstanceList)8