use of org.kie.server.api.model.cases.CaseDefinitionList in project droolsjbpm-integration by kiegroup.
the class CaseManagementRuntimeDataServiceBase method getCaseDefinitions.
public CaseDefinitionList getCaseDefinitions(String filter, Integer page, Integer pageSize, String sort, boolean sortOrder) {
Collection<CaseDefinition> caseDescs = null;
sort = safeCaseDefinitionSort(sort);
if (filter != null && !filter.isEmpty()) {
caseDescs = caseRuntimeDataService.getCases(filter, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
} else {
caseDescs = caseRuntimeDataService.getCases(ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
}
List<org.kie.server.api.model.cases.CaseDefinition> cases = ConvertUtils.transformCases(caseDescs);
CaseDefinitionList caseList = new CaseDefinitionList(cases);
return caseList;
}
use of org.kie.server.api.model.cases.CaseDefinitionList in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method getCaseDefinitions.
@Override
public List<CaseDefinition> getCaseDefinitions(String filter, Integer page, Integer pageSize, String sort, boolean sortOrder) {
CaseDefinitionList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
String filterQueryString = "";
if (filter != null) {
filterQueryString = "?filter=" + emptyIfNull(filter);
}
String queryString = getPagingQueryString(filterQueryString, page, pageSize);
queryString = getSortingQueryString(queryString, sort, sortOrder);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_QUERY_URI, valuesMap) + queryString, CaseDefinitionList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseDefinitions", new Object[] { emptyIfNull(filter), page, pageSize, sort, sortOrder })));
ServiceResponse<CaseDefinitionList> response = (ServiceResponse<CaseDefinitionList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null) {
return list.getItems();
}
return Collections.emptyList();
}
use of org.kie.server.api.model.cases.CaseDefinitionList in project droolsjbpm-integration by kiegroup.
the class CaseQueryResource method getCaseDefinitions.
/*
* case definition methods
*/
@ApiOperation(value = "Returns a specified case definition from all KIE containers.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, message = "Successful response", response = CaseDefinitionList.class, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_DEFINITIONS_JSON) })) })
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseDefinitions(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "case definition id or name that case 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 case definitions with filter {}", filter);
CaseDefinitionList responseObject = this.caseManagementRuntimeDataServiceBase.getCaseDefinitions(filter, 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.cases.CaseDefinitionList in project droolsjbpm-integration by kiegroup.
the class CaseResource method getCaseDefinitionsByContainer.
@ApiOperation(value = "Returns case definitions in a specified KIE container.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = CaseDefinitionList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_DEFINITIONS_JSON) })) })
@GET
@Path(CASE_ALL_DEFINITIONS_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseDefinitionsByContainer(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that should be used to filter case definitions", 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, containerId, null, (Variant v, String type, Header... customHeaders) -> {
logger.debug("About to look for case definitions in container {}", containerId);
CaseDefinitionList responseObject = this.caseManagementRuntimeDataServiceBase.getCaseDefinitionsByContainer(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.cases.CaseDefinitionList in project droolsjbpm-integration by kiegroup.
the class CaseQueryResourceTest method testGetCaseDefinitions.
@Test
public void testGetCaseDefinitions() {
String filter = null;
Integer page = 0;
Integer pageSize = 10;
String sort = "CaseId";
boolean sortOrder = true;
when(runtimeDataService.getCaseDefinitions(filter, page, pageSize, sort, sortOrder)).thenReturn(new CaseDefinitionList());
caseQueryResource.getCaseDefinitions(httpHeaders, filter, page, pageSize, sort, sortOrder);
verify(kieServerRegistry).getContainer("");
verify(runtimeDataService).getCaseDefinitions(filter, page, pageSize, sort, sortOrder);
}
Aggregations