use of org.kie.server.api.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.
the class ProcessServicesClientImpl method findProcessInstancesByParent.
@Override
public List<ProcessInstance> findProcessInstancesByParent(String containerId, Long parentProcessInstanceId, 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(CONTAINER_ID, containerId);
valuesMap.put(PROCESS_INST_ID, parentProcessInstanceId);
String statusQueryString = getAdditionalParams("?sort=" + sort + "&sortOrder=" + sortOrder, "status", status);
String queryString = getPagingQueryString(statusQueryString, page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), PROCESS_URI + "/" + PROCESS_INSTANCES_BY_PARENT_GET_URI, valuesMap) + queryString, ProcessInstanceList.class);
} else {
CommandScript script = new CommandScript(singletonList((KieServerCommand) new DescriptorCommand("ProcessService", "getProcessInstancesByParent", new Object[] { parentProcessInstanceId, 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.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findProcessInstancesByProcessName.
@Override
public List<ProcessInstance> findProcessInstancesByProcessName(String processName, 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>();
String statusQueryString = getAdditionalParams("?processName=" + processName + "&sort=" + sort + "&sortOrder=" + sortOrder, "status", status);
String queryString = getPagingQueryString(statusQueryString, page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_INSTANCES_GET_URI, valuesMap) + queryString, ProcessInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstances", new Object[] { safeList(status), "", processName, 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.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.
the class ConvertUtils method convertToProcessInstanceWithVarsList.
public static ProcessInstanceList convertToProcessInstanceWithVarsList(Collection<ProcessInstanceWithVarsDesc> instances) {
if (instances == null) {
return new ProcessInstanceList(new org.kie.server.api.model.instance.ProcessInstance[0]);
}
List<ProcessInstance> processInstances = new ArrayList<ProcessInstance>(instances.size());
for (ProcessInstanceWithVarsDesc pi : instances) {
org.kie.server.api.model.instance.ProcessInstance instance = convertToProcessInstance(pi);
instance.setVariables(pi.getVariables());
processInstances.add(instance);
}
return new ProcessInstanceList(processInstances);
}
use of org.kie.server.api.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.
the class ConvertUtils method convertToProcessInstanceList.
public static ProcessInstanceList convertToProcessInstanceList(Collection<ProcessInstanceDesc> instances) {
if (instances == null) {
return new ProcessInstanceList(new org.kie.server.api.model.instance.ProcessInstance[0]);
}
List<ProcessInstance> processInstances = new ArrayList<ProcessInstance>(instances.size());
for (ProcessInstanceDesc pi : instances) {
org.kie.server.api.model.instance.ProcessInstance instance = convertToProcessInstance(pi);
processInstances.add(instance);
}
return new ProcessInstanceList(processInstances);
}
use of org.kie.server.api.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.
the class RuntimeDataServiceBase method getProcessInstancesByCorrelationKey.
public ProcessInstanceList getProcessInstancesByCorrelationKey(String correlationKey, Integer page, Integer pageSize, String sort, boolean sortOrder) {
if (sort == null || sort.isEmpty()) {
sort = "ProcessInstanceId";
}
String[] correlationProperties = correlationKey.split(":");
CorrelationKey actualCorrelationKey = correlationKeyFactory.newCorrelationKey(Arrays.asList(correlationProperties));
Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstancesByCorrelationKey(actualCorrelationKey, buildQueryContext(page, pageSize, sort, sortOrder));
ProcessInstanceList processInstanceList = convertToProcessInstanceList(instances);
logger.debug("Returning result of process instance search: {}", processInstanceList);
return processInstanceList;
}
Aggregations