Search in sources :

Example 1 with CaseMilestoneList

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

the class CaseManagementRuntimeDataServiceBase method getMilestones.

public CaseMilestoneList getMilestones(String containerId, String caseId, boolean achievedOnly, Integer page, Integer pageSize) {
    Collection<CaseMilestoneInstance> caseMilestones = caseRuntimeDataService.getCaseInstanceMilestones(caseId, achievedOnly, ConvertUtils.buildQueryContext(page, pageSize));
    List<CaseMilestone> milestones = ConvertUtils.transformMilestones(caseMilestones);
    CaseMilestoneList milestoneList = new CaseMilestoneList(milestones);
    return milestoneList;
}
Also used : CaseMilestoneInstance(org.jbpm.casemgmt.api.model.instance.CaseMilestoneInstance) CaseMilestone(org.kie.server.api.model.cases.CaseMilestone) CaseMilestoneList(org.kie.server.api.model.cases.CaseMilestoneList)

Example 2 with CaseMilestoneList

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

the class CaseServicesClientImpl method getMilestones.

@Override
public List<CaseMilestone> getMilestones(String containerId, String caseId, boolean achievedOnly, Integer page, Integer pageSize) {
    CaseMilestoneList list = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(CASE_ID, caseId);
        String queryString = getPagingQueryString("?achievedOnly=" + achievedOnly, page, pageSize);
        list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_MILESTONES_GET_URI, valuesMap) + queryString, CaseMilestoneList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getMilestones", new Object[] { containerId, caseId, achievedOnly, page, pageSize })));
        ServiceResponse<CaseMilestoneList> response = (ServiceResponse<CaseMilestoneList>) 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) CaseMilestoneList(org.kie.server.api.model.cases.CaseMilestoneList) CommandScript(org.kie.server.api.commands.CommandScript)

Example 3 with CaseMilestoneList

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

the class CaseResource method getCaseInstanceMilestones.

@ApiOperation(value = "Returns milestones for a specified case instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Case instance not found"), @ApiResponse(code = 200, response = CaseMilestoneList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_MILESTONES_JSON) })) })
@GET
@Path(CASE_MILESTONES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstanceMilestones(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that case instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the case instance", required = true, example = "CASE-00000000001") @PathParam(CASE_ID) String caseId, @ApiParam(value = "optional flag that allows to control which milestones to load - achieved only or actives ones too, defaults to true", required = false) @QueryParam("achievedOnly") @DefaultValue("true") boolean achievedOnly, @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, containerId, caseId, (Variant v, String type, Header... customHeaders) -> {
        logger.debug("About to look for milestones in case {} achieved only = {}", caseId, achievedOnly);
        CaseMilestoneList responseObject = this.caseManagementRuntimeDataServiceBase.getMilestones(containerId, caseId, achievedOnly, page, pageSize);
        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) CaseMilestoneList(org.kie.server.api.model.cases.CaseMilestoneList) 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)

Aggregations

CaseMilestoneList (org.kie.server.api.model.cases.CaseMilestoneList)3 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)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 CaseMilestoneInstance (org.jbpm.casemgmt.api.model.instance.CaseMilestoneInstance)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 CaseMilestone (org.kie.server.api.model.cases.CaseMilestone)1 Header (org.kie.server.remote.rest.common.Header)1 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)1