use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method stopTask.
@Override
public void stopTask(String containerId, Long taskId, String userId) {
if (config.isRest()) {
sendTaskOperation(containerId, taskId, TASK_URI + "/" + TASK_INSTANCE_STOP_PUT_URI, getUserQueryStr(userId));
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "stop", new Object[] { containerId, taskId, userId })));
ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
}
}
use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method query.
@Override
public <T> List<T> query(String queryName, String mapper, String builder, Map<String, Object> parameters, Integer page, Integer pageSize, Class<T> resultType) {
Object result = null;
Class<?> resultTypeList = getResultTypeList(resultType);
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(QUERY_NAME, queryName);
String queryString = getPagingQueryString("?mapper=" + mapper + "&builder=" + builder, page, pageSize);
result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + RUN_FILTERED_QUERY_DEF_POST_URI, valuesMap) + queryString, parameters, resultTypeList);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "queryFilteredWithBuilder", serialize(safeMap(parameters)), marshaller.getFormat().getType(), new Object[] { queryName, mapper, builder, page, pageSize })));
ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null) {
if (result instanceof ItemList) {
return ((ItemList<T>) result).getItems();
} else if (result instanceof List) {
return (List) result;
} else if (result instanceof Wrapped) {
return (List) ((Wrapped) result).unwrap();
}
}
return Collections.emptyList();
}
use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findProcessInstancesByVariable.
@Override
public List<ProcessInstance> findProcessInstancesByVariable(String variableName, List<Integer> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
ProcessInstanceList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(VAR_NAME, variableName);
String statusQueryString = getAdditionalParams("?sort=" + sort + "&sortOrder=" + sortOrder, "status", status);
String queryString = getPagingQueryString(statusQueryString, page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_INSTANCE_BY_VAR_NAME_GET_URI, valuesMap) + queryString, ProcessInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstanceByVariables", new Object[] { variableName, "", safeList(status), page, pageSize, sort, sortOrder })));
ServiceResponse<ProcessInstanceList> response = (ServiceResponse<ProcessInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getProcessInstances() != null) {
return Arrays.asList(result.getProcessInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findProcessInstancesByCorrelationKey.
@Override
public List<ProcessInstance> findProcessInstancesByCorrelationKey(CorrelationKey correlationKey, Integer page, Integer pageSize, String sort, boolean sortOrder) {
ProcessInstanceList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CORRELATION_KEY, correlationKey.toExternalForm());
String queryString = getPagingQueryString("?sort=" + sort + "&sortOrder=" + sortOrder, page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_INSTANCES_BY_CORRELATION_KEY_GET_URI, valuesMap) + queryString, ProcessInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstancesByCorrelationKey", new Object[] { correlationKey.toExternalForm(), page, pageSize, sort, sortOrder })));
ServiceResponse<ProcessInstanceList> response = (ServiceResponse<ProcessInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getProcessInstances() != null) {
return Arrays.asList(result.getProcessInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findNodeInstanceByWorkItemId.
@Override
public NodeInstance findNodeInstanceByWorkItemId(Long processInstanceId, Long workItemId) {
NodeInstance result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(PROCESS_INST_ID, processInstanceId);
valuesMap.put(WORK_ITEM_ID, workItemId);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + NODE_INSTANCES_BY_WORK_ITEM_ID_GET_URI, valuesMap), NodeInstance.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getNodeInstanceForWorkItem", new Object[] { processInstanceId, workItemId })));
ServiceResponse<NodeInstance> response = (ServiceResponse<NodeInstance>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
return result;
}
Aggregations