use of org.kie.server.api.model.instance.NodeInstanceList in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findNodeInstances.
@Override
public List<NodeInstance> findNodeInstances(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("", 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, 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 RuntimeDataResource method getProcessInstanceHistory.
@ApiOperation(value = "Returns node instances for a specified process instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = NodeInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_INSTANCE_NODES_RESPONSE_JSON) })) })
@GET
@Path(NODE_INSTANCES_BY_INSTANCE_ID_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessInstanceHistory(@Context HttpHeaders headers, @ApiParam(value = "process instance id to to retrive history for", required = true) @PathParam(PROCESS_INST_ID) long processInstanceId, @ApiParam(value = "include active nodes only", required = false) @QueryParam("activeOnly") Boolean active, @ApiParam(value = "include completed nodes only", required = false) @QueryParam("completedOnly") 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) {
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
NodeInstanceList nodeInstanceList = runtimeDataServiceBase.getProcessInstanceHistory(processInstanceId, active, completed, page, pageSize);
logger.debug("Returning result of node instances search: {}", nodeInstanceList);
return createCorrectVariant(nodeInstanceList, headers, Response.Status.OK, conversationIdHeader);
}
use of org.kie.server.api.model.instance.NodeInstanceList in project droolsjbpm-integration by kiegroup.
the class CaseManagementRuntimeDataServiceBase method getActiveNodes.
public NodeInstanceList getActiveNodes(String containerId, String caseId, Integer page, Integer pageSize) {
Collection<NodeInstanceDesc> activeNodeInstances = caseRuntimeDataService.getActiveNodesForCase(caseId, ConvertUtils.buildQueryContext(page, pageSize));
List<NodeInstance> activeNodes = ConvertUtils.transformNodeInstance(activeNodeInstances);
NodeInstanceList activeNodesList = new NodeInstanceList(activeNodes);
return activeNodesList;
}
use of org.kie.server.api.model.instance.NodeInstanceList in project droolsjbpm-integration by kiegroup.
the class KieClientServicesIntegrationTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
KieServerInfo info = new KieServerInfo("mock", "1.2.3");
List<String> capabilities = Arrays.asList(KieServerConstants.CAPABILITY_BPM, KieServerConstants.CAPABILITY_BPM_UI, KieServerConstants.CAPABILITY_BRM, KieServerConstants.CAPABILITY_BRP, KieServerConstants.CAPABILITY_CASE, KieServerConstants.CAPABILITY_DMN);
info.setCapabilities(capabilities);
ServiceResponse<KieServerInfo> response = new ServiceResponse<KieServerInfo>(ResponseType.SUCCESS, "Kie Server info");
response.setResult(info);
stubFor(get(urlEqualTo("/")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(response, KieServerInfo.class, ServiceResponse.class))));
// case mock response
ProcessDefinitionList caseResponse = new ProcessDefinitionList();
caseResponse.setProcesses(new ProcessDefinition[] { new ProcessDefinition() });
stubFor(get(urlMatching("/queries/cases/processes.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(caseResponse, ProcessDefinitionList.class, ProcessDefinition.class))));
// document mock response
DocumentInstance documentResponse = new DocumentInstance();
documentResponse.setIdentifier("1234");
stubFor(get(urlMatching("/documents/1234")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(documentResponse, DocumentInstance.class))));
// job service mock response
RequestInfoInstanceList jobResponse = new RequestInfoInstanceList();
stubFor(get(urlMatching("/jobs.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(jobResponse, RequestInfoInstanceList.class))));
// query service mock response
NodeInstanceList queryResponse = new NodeInstanceList();
stubFor(get(urlMatching("/queries/processes/instances/100/nodes/instances.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(queryResponse, NodeInstanceList.class))));
// solver service mock response
SolverInstanceList solverResponse = new SolverInstanceList();
stubFor(get(urlMatching("/containers/my-container/solvers")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(solverResponse, SolverInstanceList.class))));
// ui service mock response
stubFor(get(urlMatching("/containers/my-container/forms/processes/my-process.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody("my form")));
// user task mock response
TaskSummaryList userTaskResponse = new TaskSummaryList();
stubFor(get(urlMatching("/queries/tasks/instances.*")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/xml").withBody(toXML(userTaskResponse, TaskSummaryList.class))));
return new RouteBuilder() {
@Override
public void configure() {
from("direct:start").to("kie:" + getAuthenticadUrl("admin", "admin")).to("mock:result");
}
};
}
use of org.kie.server.api.model.instance.NodeInstanceList in project droolsjbpm-integration by kiegroup.
the class ProcessServicesClientImpl method findNodeInstancesByType.
@Override
public List<NodeInstance> findNodeInstancesByType(String containerId, Long processInstanceId, String entryType, Integer page, Integer pageSize) {
NodeInstanceList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(PROCESS_INST_ID, processInstanceId);
String queryString = getPagingQueryString("?" + RestURI.PROCESS_INST_HISTORY_TYPE + "=" + entryType, page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), PROCESS_URI + "/" + PROCESS_INSTANCES_NODE_INSTANCES_GET_URI, valuesMap) + queryString, NodeInstanceList.class);
} else {
CommandScript script = new CommandScript(singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstanceFullHistoryByType", processInstanceId, entryType, 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();
}
Aggregations