Search in sources :

Example 1 with NodeInstanceList

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();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList)

Example 2 with NodeInstanceList

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);
}
Also used : Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 3 with NodeInstanceList

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;
}
Also used : NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) NodeInstance(org.kie.server.api.model.instance.NodeInstance) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList)

Example 4 with NodeInstanceList

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");
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) RequestInfoInstanceList(org.kie.server.api.model.instance.RequestInfoInstanceList) KieServerInfo(org.kie.server.api.model.KieServerInfo) ProcessDefinition(org.kie.server.api.model.definition.ProcessDefinition) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList) SolverInstanceList(org.kie.server.api.model.instance.SolverInstanceList) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) ServiceResponse(org.kie.server.api.model.ServiceResponse) DocumentInstance(org.kie.server.api.model.instance.DocumentInstance)

Example 5 with NodeInstanceList

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();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList)

Aggregations

NodeInstanceList (org.kie.server.api.model.instance.NodeInstanceList)20 HashMap (java.util.HashMap)11 ServiceResponse (org.kie.server.api.model.ServiceResponse)11 CommandScript (org.kie.server.api.commands.CommandScript)10 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)10 KieServerCommand (org.kie.server.api.model.KieServerCommand)10 ApiOperation (io.swagger.annotations.ApiOperation)4 ApiResponses (io.swagger.annotations.ApiResponses)4 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)4 Header (org.kie.server.remote.rest.common.Header)4 Variant (javax.ws.rs.core.Variant)3 NodeInstance (org.kie.server.api.model.instance.NodeInstance)3 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)3 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)3 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)2 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)2 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)2