use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findProcessesById.
@Override
public List<ProcessDefinition> findProcessesById(String processId) {
ProcessDefinitionList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(PROCESS_ID, processId);
result = makeHttpGetRequestAndCreateCustomResponseWithHandleNotFound(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_DEFINITIONS_BY_ID_GET_URI, valuesMap), ProcessDefinitionList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessesById", new Object[] { processId })));
ServiceResponse<ProcessDefinitionList> response = (ServiceResponse<ProcessDefinitionList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getProcesses() != null) {
return Arrays.asList(result.getProcesses());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findProcesses.
@Override
public List<ProcessDefinition> findProcesses(String filter, Integer page, Integer pageSize, String sort, boolean sortOrder) {
ProcessDefinitionList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
String queryString = getPagingQueryString("?filter=" + filter + "&sort=" + sort + "&sortOrder=" + sortOrder, page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_DEFINITIONS_GET_URI, valuesMap) + queryString, ProcessDefinitionList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessesByFilter", new Object[] { filter, page, pageSize, sort, sortOrder })));
ServiceResponse<ProcessDefinitionList> response = (ServiceResponse<ProcessDefinitionList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getProcesses() != null) {
return Arrays.asList(result.getProcesses());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method getProcessesByFilter.
@ApiOperation(value = "Returns all process definitions.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = ProcessDefinitionList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_DEFS_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_DEFINITIONS_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessesByFilter(@Context HttpHeaders headers, @ApiParam(value = "process id or name to filter process definitions", required = false) @QueryParam("filter") String filter, @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, @ApiParam(value = "optional sort column, no default", required = false) @QueryParam("sort") String sort, @ApiParam(value = "optional sort direction (asc, desc) - defaults to asc", required = false) @QueryParam("sortOrder") @DefaultValue("true") boolean sortOrder) {
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
ProcessDefinitionList processDefinitionList = runtimeDataServiceBase.getProcessesByFilter(filter, page, pageSize, sort, sortOrder);
logger.debug("Returning result of process definition search: {}", processDefinitionList);
return createCorrectVariant(processDefinitionList, headers, Response.Status.OK, conversationIdHeader);
}
use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.
the class ProcessResource method getProcessesByDeploymentId.
@ApiOperation(value = "Returns a list of process definitions in a specified KIE container.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Container Id not found"), @ApiResponse(code = 200, response = ProcessDefinitionList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_DEFS_RESPONSE_JSON) })) })
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessesByDeploymentId(@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 = "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, @ApiParam(value = "optional sort column, no default", required = false) @QueryParam("sort") String sort, @ApiParam(value = "optional sort direction (asc, desc) - defaults to asc", required = false) @QueryParam("sortOrder") @DefaultValue("true") boolean sortOrder) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
ProcessDefinitionList processDefinitionList = runtimeDataServiceBase.getProcessesByDeploymentIdCheckContainer(containerId, page, pageSize, sort, sortOrder);
logger.debug("Returning result of process definition search: {}", processDefinitionList);
return createCorrectVariant(processDefinitionList, 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);
}
}
use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method getProcessesById.
@ApiOperation(value = "Returns all process definitions for a specified process.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = ProcessDefinitionList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_DEFS_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_DEFINITIONS_BY_ID_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessesById(@Context HttpHeaders headers, @ApiParam(value = "process id to load process definition", required = true) @PathParam(PROCESS_ID) String processId) {
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
ProcessDefinitionList processDefinitionList = runtimeDataServiceBase.getProcessesById(processId);
logger.debug("Returning result of process definition search: {}", processDefinitionList);
return createCorrectVariant(processDefinitionList, headers, Response.Status.OK, conversationIdHeader);
}
Aggregations