use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.
the class CaseQueryResource method getProcessDefinitionsByContainer.
@ApiOperation(value = "Returns processes associated with case definitions in a specified KIE container.")
@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(CASE_PROCESSES_BY_CONTAINER_INSTANCES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessDefinitionsByContainer(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that process definitions should be filtered by", 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) {
return invokeCaseOperation(headers, "", null, (Variant v, String type, Header... customHeaders) -> {
logger.debug("About to look for process definitions with container id {}", containerId);
ProcessDefinitionList responseObject = this.caseManagementRuntimeDataServiceBase.getProcessDefinitions(null, containerId, page, pageSize, sort, sortOrder);
logger.debug("Returning OK response with content '{}'", responseObject);
return createCorrectVariant(responseObject, headers, Response.Status.OK, customHeaders);
});
}
use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.
the class CaseQueryResource method getProcessDefinitions.
/*
* process definition methods
*/
@ApiOperation(value = "Returns a specified process associated with case definitions from all KIE containers.")
@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(CASE_ALL_PROCESSES_INSTANCES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessDefinitions(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "process definition id or name that process definitions will be filtered by", required = true) @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) {
return invokeCaseOperation(headers, "", null, (Variant v, String type, Header... customHeaders) -> {
logger.debug("About to look for process definitions with filter {}", filter);
ProcessDefinitionList responseObject = this.caseManagementRuntimeDataServiceBase.getProcessDefinitions(filter, null, page, pageSize, sort, sortOrder);
logger.debug("Returning OK response with content '{}'", responseObject);
return createCorrectVariant(responseObject, headers, Response.Status.OK, customHeaders);
});
}
use of org.kie.server.api.model.definition.ProcessDefinitionList in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findProcessesByContainerId.
@Override
public List<ProcessDefinition> findProcessesByContainerId(String containerId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
ProcessDefinitionList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
String queryString = getPagingQueryString("?sort=" + sort + "&sortOrder=" + sortOrder, page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponseWithHandleNotFound(build(loadBalancer.getUrl(), QUERY_URI + "/" + PROCESS_DEFINITIONS_BY_CONTAINER_ID_GET_URI, valuesMap) + queryString, ProcessDefinitionList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessesByDeploymentId", new Object[] { containerId, 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 getProcessesByDeploymentId.
@ApiOperation(value = "Returns all process definitions in a specified KIE container.")
@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_CONTAINER_ID_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessesByDeploymentId(@Context HttpHeaders headers, @ApiParam(value = "container id to filter process definitions", required = true) @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) {
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
ProcessDefinitionList processDefinitionList = runtimeDataServiceBase.getProcessesByDeploymentId(containerId, 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 ProcessServiceRestOnlyIntegrationTest method testProcessDefinitionWhichBelongsToAContainer.
@Test
public void testProcessDefinitionWhichBelongsToAContainer() {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(RestURI.CONTAINER_ID, CONTAINER_ID);
Response response = null;
try {
// find process definitions which belong to the given container
WebTarget clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI, valuesMap));
logger.debug("[GET] " + clientRequest.getUri());
response = clientRequest.request(getMediaType()).get();
Marshaller marshaller = MarshallerFactory.getMarshaller(marshallingFormat, Thread.currentThread().getContextClassLoader());
ProcessDefinitionList processDefinitionList = marshaller.unmarshall(response.readEntity(String.class), ProcessDefinitionList.class);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
// we didn't specify pageSize, so it will be 10 by default
assertThat(processDefinitionList.getItems()).hasSize(10);
response.close();
// find process definitions of non-existing container
valuesMap.clear();
valuesMap.put(RestURI.CONTAINER_ID, NON_EXISTING_CONTAINER_ID);
clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI, valuesMap));
logger.debug("[GET] " + clientRequest.getUri());
response = clientRequest.request(getMediaType()).get();
assertThat(response.getStatus()).isEqualTo(Response.Status.NOT_FOUND.getStatusCode());
assertThat(response.readEntity(String.class)).contains(NON_EXISTING_CONTAINER_ID);
} finally {
if (response != null) {
response.close();
}
}
}
Aggregations