Search in sources :

Example 1 with CaseInstanceList

use of org.kie.server.api.model.cases.CaseInstanceList in project droolsjbpm-integration by kiegroup.

the class CaseQueryResource method getCaseInstances.

@ApiOperation(value = "Returns cases instances with authentication checks.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = CaseInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_INSTANCES_JSON) })) })
@GET
@Path(CASE_ALL_INSTANCES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstances(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "data item name that case instances will be filtered by", required = false) @QueryParam("dataItemName") String dataItemName, @ApiParam(value = "data item value that case instances will be filtered by", required = false) @QueryParam("dataItemValue") String dataItemValue, @ApiParam(value = "case instance owner that case instances will be filtered by", required = false) @QueryParam("owner") String owner, @ApiParam(value = "optional case instance status (open, closed, canceled) - defaults ot open (1) only", required = false, allowableValues = "open,closed,cancelled") @QueryParam("status") List<String> status, @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, @ApiParam(value = "optional flag to load data when loading case instance", required = false) @QueryParam("withData") @DefaultValue("false") boolean withData) {
    return invokeCaseOperation(headers, "", null, (Variant v, String type, Header... customHeaders) -> {
        CaseInstanceList responseObject = null;
        if (dataItemName != null && !dataItemName.isEmpty() && dataItemValue != null && !dataItemValue.isEmpty()) {
            logger.debug("About to look for case instances by data item name {} and value {} with status {}", dataItemName, dataItemValue, status);
            responseObject = this.caseManagementRuntimeDataServiceBase.getCaseInstancesByCaseFileData(dataItemName, dataItemValue, status, page, pageSize, sort, sortOrder, withData);
        } else if (dataItemName != null && !dataItemName.isEmpty()) {
            logger.debug("About to look for case instances by data item name {} with status {}", dataItemName, status);
            responseObject = this.caseManagementRuntimeDataServiceBase.getCaseInstancesByCaseFileData(dataItemName, null, status, page, pageSize, sort, sortOrder, withData);
        } else if (owner != null && !owner.isEmpty()) {
            logger.debug("About to look for case instances owned by {} with status {}", owner, status);
            responseObject = this.caseManagementRuntimeDataServiceBase.getCaseInstancesOwnedBy(owner, status, page, pageSize, sort, sortOrder, withData);
        } else {
            logger.debug("About to look for case instances with status {}", status);
            responseObject = this.caseManagementRuntimeDataServiceBase.getCaseInstancesAnyRole(status, page, pageSize, sort, sortOrder, withData);
        }
        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) CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) 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 CaseInstanceList

use of org.kie.server.api.model.cases.CaseInstanceList in project droolsjbpm-integration by kiegroup.

the class CaseResource method getCaseInstancesByDefinition.

@ApiOperation(value = "Returns case instances for a specified case definition.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = CaseInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_INSTANCES_JSON) })) })
@GET
@Path(CASE_INSTANCES_BY_DEF_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstancesByDefinition(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that should be used to filter case instances", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "case definition id that should be used to filter case instances", required = true, example = "CASE-00000000001") @PathParam(CASE_DEF_ID) String caseDefId, @ApiParam(value = "optional case instance status (open, closed, canceled) - defaults ot open (1) only", required = false, allowableValues = "open,closed,cancelled") @QueryParam("status") List<String> status, @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, @ApiParam(value = "optional flag to load data when loading case instance", required = false) @QueryParam("withData") @DefaultValue("false") boolean withData) {
    return invokeCaseOperation(headers, containerId, null, (Variant v, String type, Header... customHeaders) -> {
        List<String> actualStatus = status;
        if (status == null || status.isEmpty()) {
            actualStatus = new ArrayList<String>();
            actualStatus.add(CaseStatus.OPEN.getName());
        }
        logger.debug("About to look for case instances with case definition id {} with status {}", caseDefId, actualStatus);
        CaseInstanceList responseObject = this.caseManagementRuntimeDataServiceBase.getCaseInstancesByDefinition(containerId, caseDefId, actualStatus, page, pageSize, sort, sortOrder, withData);
        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) CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) Header(org.kie.server.remote.rest.common.Header) 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 3 with CaseInstanceList

use of org.kie.server.api.model.cases.CaseInstanceList in project droolsjbpm-integration by kiegroup.

the class CaseResource method getCaseInstancesByContainer.

/*
     * basic queries through container
     */
@ApiOperation(value = "Returns case instances in a specified KIE container.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = CaseInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_INSTANCES_JSON) })) })
@GET
@Path(CASE_INSTANCES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstancesByContainer(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that should be used to filter case instances", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "optional case instance status (open, closed, canceled) - defaults ot open (1) only", required = false, allowableValues = "open,closed,cancelled") @QueryParam("status") List<String> status, @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, @ApiParam(value = "optional flag to load data when loading case instance", required = false) @QueryParam("withData") @DefaultValue("false") boolean withData) {
    return invokeCaseOperation(headers, containerId, null, (Variant v, String type, Header... customHeaders) -> {
        List<String> actualStatus = status;
        if (status == null || status.isEmpty()) {
            actualStatus = new ArrayList<String>();
            actualStatus.add(CaseStatus.OPEN.getName());
        }
        logger.debug("About to look for case instances in container {} with status {}", containerId, actualStatus);
        CaseInstanceList responseObject = this.caseManagementRuntimeDataServiceBase.getCaseInstancesByContainer(containerId, actualStatus, page, pageSize, sort, sortOrder, withData);
        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) CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) Header(org.kie.server.remote.rest.common.Header) 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 4 with CaseInstanceList

use of org.kie.server.api.model.cases.CaseInstanceList in project droolsjbpm-integration by kiegroup.

the class CaseManagementRuntimeDataServiceBase method getCaseInstances.

public CaseInstanceList getCaseInstances(List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder, boolean withData) {
    List<CaseStatus> caseStatus = safeCaseStatus(status);
    sort = safeCaseInstanceSort(sort);
    Collection<org.jbpm.casemgmt.api.model.instance.CaseInstance> caseInstanceDescs = caseRuntimeDataService.getCaseInstances(caseStatus, withData, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
    List<CaseInstance> caseInstances = ConvertUtils.transformCaseInstances(caseInstanceDescs);
    CaseInstanceList caseInstancesList = new CaseInstanceList(caseInstances);
    return caseInstancesList;
}
Also used : CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) CaseInstance(org.kie.server.api.model.cases.CaseInstance) CaseStatus(org.jbpm.casemgmt.api.model.CaseStatus)

Example 5 with CaseInstanceList

use of org.kie.server.api.model.cases.CaseInstanceList in project droolsjbpm-integration by kiegroup.

the class CaseManagementRuntimeDataServiceBase method getCaseInstancesOwnedBy.

public CaseInstanceList getCaseInstancesOwnedBy(String owner, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder, boolean withData) {
    List<CaseStatus> caseStatus = safeCaseStatus(status);
    owner = getUser(owner);
    sort = safeCaseInstanceSort(sort);
    Collection<org.jbpm.casemgmt.api.model.instance.CaseInstance> caseInstanceDescs = caseRuntimeDataService.getCaseInstancesOwnedBy(owner, caseStatus, withData, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
    List<CaseInstance> caseInstances = ConvertUtils.transformCaseInstances(caseInstanceDescs);
    CaseInstanceList caseInstancesList = new CaseInstanceList(caseInstances);
    return caseInstancesList;
}
Also used : CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) CaseInstance(org.kie.server.api.model.cases.CaseInstance) CaseStatus(org.jbpm.casemgmt.api.model.CaseStatus)

Aggregations

CaseInstanceList (org.kie.server.api.model.cases.CaseInstanceList)20 CaseInstance (org.kie.server.api.model.cases.CaseInstance)9 CaseStatus (org.jbpm.casemgmt.api.model.CaseStatus)7 HashMap (java.util.HashMap)6 GET (javax.ws.rs.GET)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 Variant (javax.ws.rs.core.Variant)6 CommandScript (org.kie.server.api.commands.CommandScript)6 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)6 KieServerCommand (org.kie.server.api.model.KieServerCommand)6 ServiceResponse (org.kie.server.api.model.ServiceResponse)6 ApiOperation (io.swagger.annotations.ApiOperation)5 ApiResponses (io.swagger.annotations.ApiResponses)5 Header (org.kie.server.remote.rest.common.Header)5 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)5 ArrayList (java.util.ArrayList)2 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)2 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)2 Consumes (javax.ws.rs.Consumes)1