use of org.kie.server.api.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findProcessInstancesWithFilters.
@Override
public List<ProcessInstance> findProcessInstancesWithFilters(String queryName, ProcessInstanceQueryFilterSpec filterSpec, Integer page, Integer pageSize) {
String mapper = "ProcessInstances";
ProcessInstanceList result = null;
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, ProcessInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "queryFiltered", serialize(filterSpec), marshaller.getFormat().getType(), new Object[] { queryName, mapper, page, pageSize })));
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) {
return result.getItems();
} else {
return Collections.emptyList();
}
}
use of org.kie.server.api.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findProcessInstancesByInitiator.
@Override
public List<ProcessInstance> findProcessInstancesByInitiator(String initiator, 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("?initiator=" + initiator + "&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), initiator, "", 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 findProcessInstances.
@Override
public List<ProcessInstance> findProcessInstances(Integer page, Integer pageSize, String sort, boolean sortOrder) {
ProcessInstanceList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
String queryString = getPagingQueryString("?sort=" + sort + "&sortOrder=" + sortOrder, 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[] { new ArrayList(), "", "", 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 RuntimeDataResource method getProcessInstanceByVariables.
@ApiOperation(value = "Returns process instances with a specified variable.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, message = "Successful response", response = ProcessInstanceList.class, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_INSTANCES_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_INSTANCE_BY_VAR_NAME_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessInstanceByVariables(@Context HttpHeaders headers, @ApiParam(value = "variable name to filter process instance", required = true) @PathParam("varName") String variableName, @ApiParam(value = "variable value to filter process instance, optional when filtering by name only required when filtering by name and value", required = false) @QueryParam("varValue") String variableValue, @ApiParam(value = "optional process instance status (active, completed, aborted) - defaults ot active (1) only", required = false, allowableValues = "1,2,3") @QueryParam("status") List<Integer> status, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize, @ApiParam(value = "optional sort column, no default", required = false) @QueryParam("sort") String sort, @ApiParam(value = "optional sort direction (asc, desc) - defaults to asc", required = false) @QueryParam("sortOrder") @DefaultValue("true") boolean sortOrder) {
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
ProcessInstanceList processInstanceList = runtimeDataServiceBase.getProcessInstanceByVariables(variableName, variableValue, status, page, pageSize, sort, sortOrder);
logger.debug("Returning result of process instance search: {}", processInstanceList);
return createCorrectVariant(processInstanceList, headers, Response.Status.OK, conversationIdHeader);
}
use of org.kie.server.api.model.instance.ProcessInstanceList in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method getProcessInstancesByCorrelationKey.
@ApiOperation(value = "Returns process instances with a specified correlation key.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, message = "Successful response", response = ProcessInstanceList.class, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_INSTANCES_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_INSTANCES_BY_CORRELATION_KEY_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessInstancesByCorrelationKey(@Context HttpHeaders headers, @ApiParam(value = "correlation key to filter process instance, can be given as partial correlation key like in starts with approach", required = true) @PathParam("correlationKey") String correlationKey, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize, @ApiParam(value = "optional sort column, no default", required = false) @QueryParam("sort") String sort, @ApiParam(value = "optional sort direction (asc, desc) - defaults to asc", required = false) @QueryParam("sortOrder") @DefaultValue("true") boolean sortOrder) {
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
ProcessInstanceList processInstanceList = runtimeDataServiceBase.getProcessInstancesByCorrelationKey(correlationKey, page, pageSize, sort, sortOrder);
return createCorrectVariant(processInstanceList, headers, Response.Status.OK, conversationIdHeader);
}
Aggregations