Search in sources :

Example 1 with CaseAdHocFragmentList

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

the class CaseResource method getCaseInstanceAdHocFragments.

@ApiOperation(value = "Returns ad hoc fragments 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 = CaseAdHocFragmentList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_ADHOC_FRAGMENTS_JSON) })) })
@GET
@Path(CASE_AD_HOC_FRAGMENTS_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstanceAdHocFragments(@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) {
    return invokeCaseOperation(headers, containerId, caseId, (Variant v, String type, Header... customHeaders) -> {
        logger.debug("About to look for adhoc fragments in case {}", caseId);
        CaseAdHocFragmentList responseObject = this.caseManagementRuntimeDataServiceBase.getAdHocFragments(containerId, caseId);
        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) CaseAdHocFragmentList(org.kie.server.api.model.cases.CaseAdHocFragmentList) 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 CaseAdHocFragmentList

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

the class CaseServicesClientImpl method getAdHocFragments.

@Override
public List<CaseAdHocFragment> getAdHocFragments(String containerId, String caseId) {
    CaseAdHocFragmentList list = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(CASE_ID, caseId);
        list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_AD_HOC_FRAGMENTS_GET_URI, valuesMap), CaseAdHocFragmentList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getAdHocFragments", new Object[] { containerId, caseId })));
        ServiceResponse<CaseAdHocFragmentList> response = (ServiceResponse<CaseAdHocFragmentList>) 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) CaseAdHocFragmentList(org.kie.server.api.model.cases.CaseAdHocFragmentList) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 3 with CaseAdHocFragmentList

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

the class CaseManagementRuntimeDataServiceBase method getAdHocFragments.

public CaseAdHocFragmentList getAdHocFragments(String containerId, String caseId) {
    Collection<AdHocFragment> caseAdHocFragments = caseRuntimeDataService.getAdHocFragmentsForCase(caseId);
    List<CaseAdHocFragment> caseAdHoc = caseAdHocFragments.stream().map(adf -> CaseAdHocFragment.builder().name(adf.getName()).type(adf.getType()).build()).collect(toList());
    CaseAdHocFragmentList adHocFragmentList = new CaseAdHocFragmentList(caseAdHoc);
    return adHocFragmentList;
}
Also used : CaseDefinitionList(org.kie.server.api.model.cases.CaseDefinitionList) TaskSummary(org.kie.api.task.model.TaskSummary) CaseInstanceCustomVarsList(org.kie.server.api.model.cases.CaseInstanceCustomVarsList) CaseUserTaskWithVariablesList(org.kie.server.api.model.cases.CaseUserTaskWithVariablesList) CaseDefinition(org.jbpm.casemgmt.api.model.CaseDefinition) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) KieServerConstants(org.kie.server.api.KieServerConstants) CaseStage(org.kie.server.api.model.cases.CaseStage) ProcessInstanceList(org.kie.server.api.model.instance.ProcessInstanceList) MarshallerHelper(org.kie.server.services.impl.marshal.MarshallerHelper) CaseFileDataItemList(org.kie.server.api.model.cases.CaseFileDataItemList) ConvertUtils.convertToServiceApiQueryParam(org.kie.server.services.casemgmt.ConvertUtils.convertToServiceApiQueryParam) CaseInstance(org.kie.server.api.model.cases.CaseInstance) ArrayList(java.util.ArrayList) CaseRuntimeDataService(org.jbpm.casemgmt.api.CaseRuntimeDataService) TASK_ATTR_OWNER(org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_OWNER) CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) CaseStageInstance(org.jbpm.casemgmt.api.model.instance.CaseStageInstance) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) Arrays.asList(java.util.Arrays.asList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessDefinitionList(org.kie.server.api.model.definition.ProcessDefinitionList) CaseStageList(org.kie.server.api.model.cases.CaseStageList) NodeInstanceList(org.kie.server.api.model.instance.NodeInstanceList) CaseMilestoneInstance(org.jbpm.casemgmt.api.model.instance.CaseMilestoneInstance) TASK_ATTR_NAME(org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_NAME) IdentityProvider(org.kie.internal.identity.IdentityProvider) CaseMilestone(org.kie.server.api.model.cases.CaseMilestone) ConvertUtils.convertToCaseInstanceCustomVarsList(org.kie.server.services.casemgmt.ConvertUtils.convertToCaseInstanceCustomVarsList) CaseMilestoneList(org.kie.server.api.model.cases.CaseMilestoneList) NodeInstance(org.kie.server.api.model.instance.NodeInstance) TASK_ATTR_STATUS(org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_STATUS) Collection(java.util.Collection) QueryContext(org.kie.api.runtime.query.QueryContext) SearchQueryFilterSpec(org.kie.server.api.model.definition.SearchQueryFilterSpec) AdvanceCaseRuntimeDataService(org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService) KieServerRegistry(org.kie.server.services.api.KieServerRegistry) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc) CaseFileItem(org.jbpm.casemgmt.api.model.CaseFileItem) List(java.util.List) CaseAdHocFragmentList(org.kie.server.api.model.cases.CaseAdHocFragmentList) Collectors.toList(java.util.stream.Collectors.toList) CaseAdHocFragment(org.kie.server.api.model.cases.CaseAdHocFragment) CaseStatus(org.jbpm.casemgmt.api.model.CaseStatus) AdHocFragment(org.jbpm.casemgmt.api.model.AdHocFragment) Status(org.kie.api.task.model.Status) ContainerLocatorProvider(org.kie.server.services.impl.locator.ContainerLocatorProvider) CaseAdHocFragmentList(org.kie.server.api.model.cases.CaseAdHocFragmentList) CaseAdHocFragment(org.kie.server.api.model.cases.CaseAdHocFragment) CaseAdHocFragment(org.kie.server.api.model.cases.CaseAdHocFragment) AdHocFragment(org.jbpm.casemgmt.api.model.AdHocFragment)

Aggregations

CaseAdHocFragmentList (org.kie.server.api.model.cases.CaseAdHocFragmentList)3 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)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 AdvanceCaseRuntimeDataService (org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService)1 TASK_ATTR_NAME (org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_NAME)1 TASK_ATTR_OWNER (org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_OWNER)1 TASK_ATTR_STATUS (org.jbpm.casemgmt.api.AdvanceCaseRuntimeDataService.TASK_ATTR_STATUS)1 CaseRuntimeDataService (org.jbpm.casemgmt.api.CaseRuntimeDataService)1 AdHocFragment (org.jbpm.casemgmt.api.model.AdHocFragment)1 CaseDefinition (org.jbpm.casemgmt.api.model.CaseDefinition)1