use of org.kie.server.api.model.cases.CaseFileDataItemList in project droolsjbpm-integration by kiegroup.
the class CaseQueryResource method getCaseInstanceDataItems.
@ApiOperation(value = "Returns case file data items for a specified case instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = CaseFileDataItemList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_CASE_FILE_DATA_RESPONSE_JSON) })) })
@GET
@Path(CASE_FILE_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstanceDataItems(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "case instance identifier that data items should belong to", required = true, example = "CASE-0000000001") @PathParam(CASE_ID) String caseId, @ApiParam(value = "optionally filter by data item names", required = false) @QueryParam("name") List<String> names, @ApiParam(value = "optionally filter by data item types", required = false) @QueryParam("type") List<String> types, @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) {
return invokeCaseOperation(headers, "", caseId, (Variant v, String type, Header... customHeaders) -> {
logger.debug("About to load case file data items of case {}", caseId);
CaseFileDataItemList response = this.caseManagementRuntimeDataServiceBase.getCaseInstanceDataItems(caseId, names, types, page, pageSize);
logger.debug("Returning OK response with content '{}'", response);
return createCorrectVariant(response, headers, Response.Status.OK, customHeaders);
});
}
use of org.kie.server.api.model.cases.CaseFileDataItemList in project droolsjbpm-integration by kiegroup.
the class CaseManagementRuntimeDataServiceBase method getCaseInstanceDataItems.
public CaseFileDataItemList getCaseInstanceDataItems(String caseId, List<String> names, List<String> types, Integer page, Integer pageSize) {
Collection<CaseFileItem> caseFileItems = null;
if (!names.isEmpty()) {
caseFileItems = caseRuntimeDataService.getCaseInstanceDataItemsByName(caseId, names, ConvertUtils.buildQueryContext(page, pageSize));
} else if (!types.isEmpty()) {
caseFileItems = caseRuntimeDataService.getCaseInstanceDataItemsByType(caseId, types, ConvertUtils.buildQueryContext(page, pageSize));
} else {
caseFileItems = caseRuntimeDataService.getCaseInstanceDataItems(caseId, ConvertUtils.buildQueryContext(page, pageSize));
}
CaseFileDataItemList caseFileDataItemList = ConvertUtils.transformCaseFileDataItems(caseFileItems);
return caseFileDataItemList;
}
use of org.kie.server.api.model.cases.CaseFileDataItemList in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method internalGetCaseInstanceDataItems.
/*
* internal methods
*/
protected List<CaseFileDataItem> internalGetCaseInstanceDataItems(String caseId, List<String> names, List<String> types, Integer page, Integer pageSize) {
CaseFileDataItemList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CASE_ID, caseId);
String queryString = getPagingQueryString("", page, pageSize);
if (names != null && !names.isEmpty()) {
queryString = getAdditionalParams(queryString, "name", names);
} else if (types != null && !types.isEmpty()) {
queryString = getAdditionalParams(queryString, "type", types);
}
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_QUERY_URI + "/" + CASE_FILE_GET_URI, valuesMap) + queryString, CaseFileDataItemList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseInstanceDataItems", new Object[] { caseId, safeList(names), safeList(types), page, pageSize })));
ServiceResponse<CaseFileDataItemList> response = (ServiceResponse<CaseFileDataItemList>) 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.CaseFileDataItemList in project droolsjbpm-integration by kiegroup.
the class ConvertUtils method transformCaseFileDataItems.
public static CaseFileDataItemList transformCaseFileDataItems(Collection<CaseFileItem> caseFileItems) {
if (caseFileItems == null) {
return new CaseFileDataItemList(new CaseFileDataItem[0]);
}
List<CaseFileDataItem> caseFileDataItems = new ArrayList<CaseFileDataItem>(caseFileItems.size());
for (CaseFileItem item : caseFileItems) {
CaseFileDataItem caseFileDataItem = transformCaseFileDataItem(item);
caseFileDataItems.add(caseFileDataItem);
}
return new CaseFileDataItemList(caseFileDataItems);
}
Aggregations