use of org.kie.server.api.model.instance.NodeInstanceList in project droolsjbpm-integration by kiegroup.
the class RuntimeDataServiceBase method getProcessInstanceHistory.
public NodeInstanceList getProcessInstanceHistory(long processInstanceId, Boolean active, Boolean completed, Integer page, Integer pageSize) {
logger.debug("About to search for node instances with page {} and page size {}", page, pageSize);
Collection<NodeInstanceDesc> result = null;
if ((Boolean.TRUE.equals(active) && Boolean.TRUE.equals(completed)) || (active == null && completed == null)) {
logger.debug("Searching for active and completed node instances for process instance with id {}", processInstanceId);
result = runtimeDataService.getProcessInstanceFullHistory(processInstanceId, buildQueryContext(page, pageSize));
} else if (Boolean.TRUE.equals(active)) {
logger.debug("Searching for active node instances for process instance with id {}", processInstanceId);
result = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, buildQueryContext(page, pageSize));
} else if (Boolean.TRUE.equals(completed)) {
logger.debug("Searching for completed node instances for process instance with id {}", processInstanceId);
result = runtimeDataService.getProcessInstanceHistoryCompleted(processInstanceId, buildQueryContext(page, pageSize));
}
NodeInstanceList nodeInstanceList = convertToNodeInstanceList(result);
logger.debug("Returning result of node instances search: {}", nodeInstanceList);
return nodeInstanceList;
}
use of org.kie.server.api.model.instance.NodeInstanceList in project droolsjbpm-integration by kiegroup.
the class CaseResource method getCaseInstanceActiveNodes.
@ApiOperation(value = "Returns node instances for a specified case instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Case instance not found"), @ApiResponse(code = 200, response = NodeInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = NODE_INSTANCES_JSON) })) })
@GET
@Path(CASE_NODE_INSTANCES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstanceActiveNodes(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that case instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the case instance", required = true, example = "CASE-00000000001") @PathParam(CASE_ID) String caseId, @ApiParam(value = "optional flag that allows to control which node instances to load - active or completed, defaults to false loading only active ones", required = false) @QueryParam("completed") @DefaultValue("false") Boolean completed, @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) {
return invokeCaseOperation(headers, containerId, caseId, (Variant v, String type, Header... customHeaders) -> {
logger.debug("About to look for active nodes in case {}", caseId);
NodeInstanceList responseObject = null;
if (completed) {
responseObject = this.caseManagementRuntimeDataServiceBase.getCompletedNodes(containerId, caseId, page, pageSize);
} else {
responseObject = this.caseManagementRuntimeDataServiceBase.getActiveNodes(containerId, caseId, page, pageSize);
}
logger.debug("Returning OK response with content '{}'", responseObject);
return createCorrectVariant(responseObject, headers, Response.Status.OK, customHeaders);
});
}
use of org.kie.server.api.model.instance.NodeInstanceList in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findActiveNodeInstances.
@Override
public List<NodeInstance> findActiveNodeInstances(Long processInstanceId, Integer page, Integer pageSize) {
NodeInstanceList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(PROCESS_INST_ID, processInstanceId);
String queryString = getPagingQueryString("?activeOnly=true", page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + NODE_INSTANCES_BY_INSTANCE_ID_GET_URI, valuesMap) + queryString, NodeInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstanceHistory", new Object[] { processInstanceId, true, false, page, pageSize })));
ServiceResponse<NodeInstanceList> response = (ServiceResponse<NodeInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getNodeInstances() != null) {
return Arrays.asList(result.getNodeInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.instance.NodeInstanceList in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findCompletedNodeInstances.
@Override
public List<NodeInstance> findCompletedNodeInstances(Long processInstanceId, Integer page, Integer pageSize) {
NodeInstanceList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(PROCESS_INST_ID, processInstanceId);
String queryString = getPagingQueryString("?completedOnly=true", page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + NODE_INSTANCES_BY_INSTANCE_ID_GET_URI, valuesMap) + queryString, NodeInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstanceHistory", new Object[] { processInstanceId, false, true, page, pageSize })));
ServiceResponse<NodeInstanceList> response = (ServiceResponse<NodeInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getNodeInstances() != null) {
return Arrays.asList(result.getNodeInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.instance.NodeInstanceList in project droolsjbpm-integration by kiegroup.
the class ProcessResource method getProcessInstanceHistory.
@ApiOperation(value = "Returns node instances for the specified process instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process Instance or Container Id not found"), @ApiResponse(code = 200, response = NodeInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_INSTANCE_NODES_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_INSTANCES_NODE_INSTANCES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessInstanceHistory(@Context HttpHeaders headers, @PathParam(CONTAINER_ID) @ApiParam(value = "container id that process instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") String containerId, @ApiParam(value = "identifier of the process instance that history should be collected for", required = true, example = "123") @PathParam(PROCESS_INST_ID) long processInstanceId, @ApiParam(value = "instructs if active nodes only should be collected, defaults to false", required = false) @QueryParam("activeOnly") Boolean active, @ApiParam(value = "instructs if completed nodes only should be collected, defaults to false", required = false) @QueryParam("completedOnly") Boolean completed, @ApiParam(value = "entry type from the history", required = false, example = "123") @QueryParam(PROCESS_INST_HISTORY_TYPE) String processInstHistoryType, @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) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
NodeInstanceList nodeInstanceList = null;
if (processInstHistoryType == null) {
nodeInstanceList = runtimeDataServiceBase.getProcessInstanceHistory(processInstanceId, active, completed, page, pageSize);
} else {
nodeInstanceList = runtimeDataServiceBase.getProcessInstanceFullHistoryByType(processInstanceId, processInstHistoryType, page, pageSize);
}
logger.debug("Returning result of node instances search: {}", nodeInstanceList);
return createCorrectVariant(nodeInstanceList, headers, Response.Status.OK, conversationIdHeader);
} catch (ProcessInstanceNotFoundException e) {
return notFound(MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceId), v, 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