Search in sources :

Example 1 with CaseDefinitionList

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

Example 2 with CaseDefinitionList

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

Example 3 with CaseDefinitionList

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);
    });
}
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) CaseDefinitionList(org.kie.server.api.model.cases.CaseDefinitionList) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 4 with CaseDefinitionList

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);
    });
}
Also used : 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) CaseDefinitionList(org.kie.server.api.model.cases.CaseDefinitionList) 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 5 with CaseDefinitionList

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);
}
Also used : CaseDefinitionList(org.kie.server.api.model.cases.CaseDefinitionList) Test(org.junit.Test)

Aggregations

CaseDefinitionList (org.kie.server.api.model.cases.CaseDefinitionList)7 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 HashMap (java.util.HashMap)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 Variant (javax.ws.rs.core.Variant)2 CaseDefinition (org.jbpm.casemgmt.api.model.CaseDefinition)2 CommandScript (org.kie.server.api.commands.CommandScript)2 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)2 KieServerCommand (org.kie.server.api.model.KieServerCommand)2 ServiceResponse (org.kie.server.api.model.ServiceResponse)2 Header (org.kie.server.remote.rest.common.Header)2 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)2 Path (javax.ws.rs.Path)1 Test (org.junit.Test)1 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)1 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)1