use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findVariablesCurrentState.
@Override
public List<VariableInstance> findVariablesCurrentState(Long processInstanceId) {
VariableInstanceList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(PROCESS_INST_ID, processInstanceId);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + VAR_INSTANCES_BY_INSTANCE_ID_GET_URI, valuesMap), VariableInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getVariablesCurrentState", new Object[] { processInstanceId })));
ServiceResponse<VariableInstanceList> response = (ServiceResponse<VariableInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getVariableInstances() != null) {
return Arrays.asList(result.getVariableInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findProcessInstanceByCorrelationKey.
@Override
public ProcessInstance findProcessInstanceByCorrelationKey(CorrelationKey correlationKey) {
ProcessInstance result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CORRELATION_KEY, correlationKey.toExternalForm());
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_INSTANCE_BY_CORRELATION_KEY_GET_URI, valuesMap), ProcessInstance.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstanceByCorrelationKey", new Object[] { correlationKey.toExternalForm() })));
ServiceResponse<ProcessInstance> response = (ServiceResponse<ProcessInstance>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
return response.getResult();
}
return result;
}
use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method query.
@Override
public <T> List<T> query(String queryName, String mapper, QueryFilterSpec filterSpec, 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, page, pageSize);
result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + RUN_FILTERED_QUERY_DEF_POST_URI, valuesMap) + queryString, filterSpec, resultTypeList);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "queryFiltered", serialize(filterSpec), marshaller.getFormat().getType(), new Object[] { queryName, mapper, 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.DescriptorCommand in project droolsjbpm-integration by kiegroup.
the class UIServicesClientImpl method getProcessFormByType.
private String getProcessFormByType(String containerId, String processId, String language, String formType, boolean marshallContent) {
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(RestURI.CONTAINER_ID, containerId);
valuesMap.put(RestURI.PROCESS_ID, processId);
StringBuffer params = new StringBuffer();
params.append("type=").append(formType);
params.append("&marshallContent=").append(marshallContent);
boolean filter = false;
if (!StringUtils.isEmpty(language)) {
params.append("&lang=").append(language);
filter = true;
}
params.append("&filter=").append(filter);
return makeHttpGetRequestAndCreateRawResponse(build(loadBalancer.getUrl(), FORM_URI + "/" + PROCESS_FORM_GET_URI, valuesMap) + "?" + params.toString());
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("FormService", "getFormDisplayProcess", new Object[] { containerId, processId, StringUtils.defaultString(language), !StringUtils.isEmpty(language), formType })));
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();
}
}
use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method findTasksAssignedAsPotentialOwner.
@Override
public List<TaskSummary> findTasksAssignedAsPotentialOwner(String userId, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
TaskSummaryList taskSummaryList = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
String userQuery = getUserQueryStr(userId);
String statusQuery = getAdditionalParams(userQuery, "status", status);
String queryString = getPagingQueryString(statusQuery, page, pageSize) + "&sort=" + sort + "&sortOrder=" + sortOrder;
taskSummaryList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + TASKS_ASSIGN_POT_OWNERS_GET_URI, valuesMap) + queryString, TaskSummaryList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getTasksAssignedAsPotentialOwner", new Object[] { safeList(status), 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();
}
Aggregations