Search in sources :

Example 86 with DescriptorCommand

use of org.kie.server.api.commands.DescriptorCommand 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)

Example 87 with DescriptorCommand

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

the class CaseServicesClientImpl method getCompletedNodes.

@Override
public List<NodeInstance> getCompletedNodes(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("?completed=true", 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", "getCompletedNodes", 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 88 with DescriptorCommand

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

the class CaseServicesClientImpl method internalAddRoleAssignment.

protected void internalAddRoleAssignment(String containerId, String caseId, String roleName, String user, String group) {
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(CASE_ID, caseId);
        valuesMap.put(CASE_ROLE_NAME, roleName);
        String queryString = "?user=" + emptyIfNull(user) + "&group=" + emptyIfNull(group);
        makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_ROLES_PUT_URI, valuesMap) + queryString, null, null, new HashMap<String, String>());
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "assignToRole", new Object[] { containerId, caseId, roleName, emptyIfNull(user), emptyIfNull(group) })));
        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 89 with DescriptorCommand

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

the class CaseServicesClientImpl method internalAddDynamicSubProcess.

protected void internalAddDynamicSubProcess(String containerId, String caseId, String stageId, String processId, 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);
        valuesMap.put(PROCESS_ID, processId);
        if (stageId != null) {
            valuesMap.put(CASE_STAGE_ID, stageId);
            makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_DYNAMIC_PROCESS_IN_STAGE_POST_URI, valuesMap), taskSpecMap, null);
        } else {
            makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_DYNAMIC_PROCESS_POST_URI, valuesMap), taskSpecMap, null);
        }
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "addDynamicSubprocess", serialize(safeMap(taskSpecMap)), marshaller.getFormat().getType(), new Object[] { containerId, caseId, emptyIfNull(stageId), processId })));
        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 90 with DescriptorCommand

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

the class CaseServicesClientImpl method findCaseTasksAssignedAsBusinessAdministrator.

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

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