use of org.kie.server.api.model.definition.CountDefinition in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method countProcessInstancesByContainerId.
public Long countProcessInstancesByContainerId(String containerId, List<Integer> status) {
CountDefinition result;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<>();
valuesMap.put(CONTAINER_ID, containerId);
String queryString = getAdditionalParams("", "status", status);
result = makeHttpGetRequestAndCreateCustomResponseWithHandleNotFound(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_INSTANCES_BY_CONTAINER_ID_COUNT_URI, valuesMap) + queryString, CountDefinition.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList(new DescriptorCommand("QueryService", "countProcessInstancesByDeploymentId", new Object[] { containerId, safeList(status) })));
ServiceResponse<CountDefinition> response = (ServiceResponse<CountDefinition>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null) {
return result.getCount();
}
return null;
}
use of org.kie.server.api.model.definition.CountDefinition in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method countProcessInstancesByDeploymentId.
@ApiOperation(value = "Returns the count of all process instances for a specified KIE container.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Container Id not found"), @ApiResponse(code = 200, response = CountDefinition.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = COUNT_PROCESS_INSTANCES_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_INSTANCES_BY_CONTAINER_ID_COUNT_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response countProcessInstancesByDeploymentId(@Context HttpHeaders headers, @ApiParam(value = "container id to filter process instance", required = true) @PathParam(CONTAINER_ID) String containerId, @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) {
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
Variant v = getVariant(headers);
try {
CountDefinition count = runtimeDataServiceBase.countProcessInstancesByDeploymentId(containerId, status);
logger.debug("Returning result of process instance count: {}", count);
return createCorrectVariant(count, headers, Response.Status.OK, conversationIdHeader);
} catch (DeploymentNotFoundException e) {
return notFound(MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
Aggregations