Search in sources :

Example 96 with DescriptorCommand

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

the class CaseAdminServicesClientImpl method getCaseInstances.

@Override
public List<CaseInstance> getCaseInstances(List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    CaseInstanceList list = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        String queryString = getPagingQueryString("", page, pageSize);
        queryString = getAdditionalParams(queryString, "status", status);
        queryString = getSortingQueryString(queryString, sort, sortOrder);
        list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_CASE_URI + "/" + ADMIN_CASE_ALL_INSTANCES_GET_URI, valuesMap) + queryString, CaseInstanceList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseInstances", new Object[] { safeList(status), page, pageSize, sort, sortOrder })));
        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 97 with DescriptorCommand

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

the class ProcessAdminServicesClientImpl method migrateProcessInstances.

@Override
public List<MigrationReportInstance> migrateProcessInstances(String containerId, List<Long> processInstancesId, String targetContainerId, String targetProcessId, Map<String, String> nodeMapping) {
    MigrationReportInstanceList reportInstanceList = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        Map<String, String> headers = new HashMap<String, String>();
        String queryStringBase = buildQueryString(PROCESS_INST_ID, processInstancesId);
        String queryString = queryStringBase + "&targetContainerId=" + targetContainerId + "&targetProcessId=" + targetProcessId;
        reportInstanceList = makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_PROCESS_URI + "/" + MIGRATE_PROCESS_INSTANCES_PUT_URI, valuesMap) + queryString, nodeMapping, MigrationReportInstanceList.class, headers);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("ProcessAdminService", "migrateProcessInstances", serialize(safeMap(nodeMapping)), marshaller.getFormat().getType(), new Object[] { containerId, processInstancesId, targetContainerId, targetProcessId })));
        ServiceResponse<MigrationReportInstanceList> response = (ServiceResponse<MigrationReportInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        reportInstanceList = response.getResult();
    }
    if (reportInstanceList != null) {
        return reportInstanceList.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) MigrationReportInstanceList(org.kie.server.api.model.admin.MigrationReportInstanceList) CommandScript(org.kie.server.api.commands.CommandScript)

Example 98 with DescriptorCommand

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

the class ProcessAdminServicesClientImpl method migrateProcessInstanceWithSubprocess.

@Override
public List<MigrationReportInstance> migrateProcessInstanceWithSubprocess(String containerId, Long processInstanceId, String targetContainerId, MigrationSpecification migrationSpecification) {
    MigrationReportInstanceList reportInstanceList = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(PROCESS_INST_ID, processInstanceId);
        Map<String, String> headers = new HashMap<>();
        String queryString = "?targetContainerId=" + targetContainerId;
        reportInstanceList = makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_PROCESS_URI + "/" + MIGRATE_PROCESS_SUBPROCESS_INST_PUT_URI, valuesMap) + queryString, migrationSpecification, MigrationReportInstanceList.class, headers);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("ProcessAdminService", "migrateProcessInstanceWithAllSubprocess", serialize(migrationSpecification), marshaller.getFormat().getType(), new Object[] { containerId, processInstanceId, targetContainerId })));
        ServiceResponse<MigrationReportInstanceList> response = (ServiceResponse<MigrationReportInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        reportInstanceList = response.getResult();
    }
    if (reportInstanceList != null) {
        return reportInstanceList.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) MigrationReportInstanceList(org.kie.server.api.model.admin.MigrationReportInstanceList) CommandScript(org.kie.server.api.commands.CommandScript)

Example 99 with DescriptorCommand

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

the class ProcessAdminServicesClientImpl method migrateProcessInstance.

@Override
public MigrationReportInstance migrateProcessInstance(String containerId, Long processInstanceId, String targetContainerId, String targetProcessId, Map<String, String> nodeMapping) {
    MigrationReportInstance reportInstance = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(PROCESS_INST_ID, processInstanceId);
        Map<String, String> headers = new HashMap<String, String>();
        String queryString = "?targetContainerId=" + targetContainerId + "&targetProcessId=" + targetProcessId;
        reportInstance = makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_PROCESS_URI + "/" + MIGRATE_PROCESS_INST_PUT_URI, valuesMap) + queryString, nodeMapping, MigrationReportInstance.class, headers);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("ProcessAdminService", "migrateProcessInstance", serialize(safeMap(nodeMapping)), marshaller.getFormat().getType(), new Object[] { containerId, processInstanceId, targetContainerId, targetProcessId })));
        ServiceResponse<MigrationReportInstance> response = (ServiceResponse<MigrationReportInstance>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        reportInstance = response.getResult();
    }
    return reportInstance;
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) MigrationReportInstance(org.kie.server.api.model.admin.MigrationReportInstance) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 100 with DescriptorCommand

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

the class ProcessAdminServicesClientImpl method cancelNodeInstance.

@Override
public void cancelNodeInstance(String containerId, Long processInstanceId, Long nodeInstanceId) {
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(PROCESS_INST_ID, processInstanceId);
        valuesMap.put(NODE_INSTANCE_ID, nodeInstanceId);
        makeHttpDeleteRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_PROCESS_URI + "/" + CANCEL_NODE_INST_PROCESS_INST_DELETE_URI, valuesMap), null);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("ProcessAdminService", "cancelNodeInstance", new Object[] { containerId, processInstanceId, nodeInstanceId })));
        ServiceResponse<?> response = (ServiceResponse<?>) 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

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