Search in sources :

Example 1 with CaseFileDataItemList

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);
    });
}
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) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) CaseFileDataItemList(org.kie.server.api.model.cases.CaseFileDataItemList) 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 CaseFileDataItemList

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;
}
Also used : CaseFileDataItemList(org.kie.server.api.model.cases.CaseFileDataItemList) CaseFileItem(org.jbpm.casemgmt.api.model.CaseFileItem)

Example 3 with 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();
}
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) CaseFileDataItemList(org.kie.server.api.model.cases.CaseFileDataItemList) CommandScript(org.kie.server.api.commands.CommandScript)

Example 4 with CaseFileDataItemList

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);
}
Also used : ArrayList(java.util.ArrayList) CaseFileDataItemList(org.kie.server.api.model.cases.CaseFileDataItemList) CaseFileDataItem(org.kie.server.api.model.cases.CaseFileDataItem) CaseFileItem(org.jbpm.casemgmt.api.model.CaseFileItem)

Aggregations

CaseFileDataItemList (org.kie.server.api.model.cases.CaseFileDataItemList)4 CaseFileItem (org.jbpm.casemgmt.api.model.CaseFileItem)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 ArrayList (java.util.ArrayList)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 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 CaseFileDataItem (org.kie.server.api.model.cases.CaseFileDataItem)1 Header (org.kie.server.remote.rest.common.Header)1 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)1 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)1 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)1