Search in sources :

Example 1 with ProcessNodeList

use of org.kie.server.api.model.admin.ProcessNodeList in project droolsjbpm-integration by kiegroup.

the class ProcessAdminResource method getNodes.

@ApiOperation(value = "Returns all nodes in a 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 = ProcessNodeList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_NODES_RESPONSE_JSON) })) })
@GET
@Path(NODES_PROCESS_INST_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getNodes(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that process instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of process instance that process nodes should be collected from", required = true, example = "123") @PathParam(PROCESS_INST_ID) Long processInstanceId) {
    Variant v = getVariant(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
        ProcessNodeList processNodeList = processAdminServiceBase.getProcessNodes(containerId, processInstanceId);
        return createCorrectVariant(processNodeList, 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);
    }
}
Also used : RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) Variant(javax.ws.rs.core.Variant) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) ProcessNodeList(org.kie.server.api.model.admin.ProcessNodeList) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) NodeInstanceNotFoundException(org.jbpm.services.api.NodeInstanceNotFoundException) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) ExecutionErrorNotFoundException(org.jbpm.services.api.admin.ExecutionErrorNotFoundException) NodeNotFoundException(org.jbpm.services.api.NodeNotFoundException) 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 2 with ProcessNodeList

use of org.kie.server.api.model.admin.ProcessNodeList in project droolsjbpm-integration by kiegroup.

the class ProcessAdminServicesClientImpl method getProcessNodes.

@Override
public List<ProcessNode> getProcessNodes(String containerId, Long processInstanceId) {
    ProcessNodeList result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(PROCESS_INST_ID, processInstanceId);
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_PROCESS_URI + "/" + NODES_PROCESS_INST_GET_URI, valuesMap), ProcessNodeList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("ProcessAdminService", "getProcessNodes", new Object[] { containerId, processInstanceId })));
        ServiceResponse<ProcessNodeList> response = (ServiceResponse<ProcessNodeList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null && result.getItems() != null) {
        return result.getItems();
    }
    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) ProcessNodeList(org.kie.server.api.model.admin.ProcessNodeList)

Example 3 with ProcessNodeList

use of org.kie.server.api.model.admin.ProcessNodeList in project droolsjbpm-integration by kiegroup.

the class ProcessAdminServiceBase method convertProcessNodes.

protected ProcessNodeList convertProcessNodes(Collection<ProcessNode> processNodes) {
    if (processNodes == null) {
        return new ProcessNodeList();
    }
    org.kie.server.api.model.admin.ProcessNode[] processNodesConverted = new org.kie.server.api.model.admin.ProcessNode[processNodes.size()];
    int index = 0;
    for (ProcessNode processNode : processNodes) {
        org.kie.server.api.model.admin.ProcessNode instance = convertProcessNode(processNode);
        processNodesConverted[index] = instance;
        index++;
    }
    return new ProcessNodeList(processNodesConverted);
}
Also used : ProcessNode(org.jbpm.services.api.admin.ProcessNode) ProcessNodeList(org.kie.server.api.model.admin.ProcessNodeList)

Example 4 with ProcessNodeList

use of org.kie.server.api.model.admin.ProcessNodeList in project droolsjbpm-integration by kiegroup.

the class ProcessAdminServiceBase method getProcessNodes.

public ProcessNodeList getProcessNodes(String containerId, Number processInstanceId) {
    logger.debug("About to get process nodes for process instance {} in container {}", processInstanceId, containerId);
    Collection<ProcessNode> processNodes = processInstanceAdminService.getProcessNodes(processInstanceId.longValue());
    logger.debug("Found process nodes {} for process instance {}", processNodes, processInstanceId);
    ProcessNodeList processNodeList = convertProcessNodes(processNodes);
    return processNodeList;
}
Also used : ProcessNode(org.jbpm.services.api.admin.ProcessNode) ProcessNodeList(org.kie.server.api.model.admin.ProcessNodeList)

Aggregations

ProcessNodeList (org.kie.server.api.model.admin.ProcessNodeList)4 ProcessNode (org.jbpm.services.api.admin.ProcessNode)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 HashMap (java.util.HashMap)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Variant (javax.ws.rs.core.Variant)1 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)1 NodeInstanceNotFoundException (org.jbpm.services.api.NodeInstanceNotFoundException)1 NodeNotFoundException (org.jbpm.services.api.NodeNotFoundException)1 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)1 ExecutionErrorNotFoundException (org.jbpm.services.api.admin.ExecutionErrorNotFoundException)1 CommandScript (org.kie.server.api.commands.CommandScript)1 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)1 KieServerCommand (org.kie.server.api.model.KieServerCommand)1 ServiceResponse (org.kie.server.api.model.ServiceResponse)1 Header (org.kie.server.remote.rest.common.Header)1 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)1