use of org.kie.server.api.model.cases.CaseDefinition in project droolsjbpm-integration by kiegroup.
the class CaseResource method getCaseDefinitionsByDefinition.
@ApiOperation(value = "Returns information about a specified case definition.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = CaseDefinition.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_DEFINITION_JSON) })) })
@GET
@Path(CASE_DEFINITIONS_BY_ID_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseDefinitionsByDefinition(@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 = "case definition id that should be loaded", required = true, example = "CASE-00000000001") @PathParam(CASE_DEF_ID) String caseDefId) {
return invokeCaseOperation(headers, containerId, null, (Variant v, String type, Header... customHeaders) -> {
logger.debug("About to look for case definition with id {} in container {}", caseDefId, containerId);
try {
CaseDefinition responseObject = this.caseManagementRuntimeDataServiceBase.getCaseDefinition(containerId, caseDefId);
logger.debug("Returning OK response with content '{}'", responseObject);
return createCorrectVariant(responseObject, headers, Response.Status.OK, customHeaders);
} catch (IllegalStateException e) {
return notFound(MessageFormat.format(CASE_DEFINITION_NOT_FOUND, caseDefId, containerId), v, customHeaders);
}
});
}
use of org.kie.server.api.model.cases.CaseDefinition in project droolsjbpm-integration by kiegroup.
the class CaseRuntimeDataServiceIntegrationTest method testGetCaseDefinition.
@Test
public void testGetCaseDefinition() {
CaseDefinition hrCase = caseClient.getCaseDefinition(CONTAINER_ID, CASE_HR_DEF_ID);
assertHrCaseDefinition(hrCase);
}
use of org.kie.server.api.model.cases.CaseDefinition in project droolsjbpm-integration by kiegroup.
the class CarInsuranceClaimCaseIntegrationTest method carInsuranceClaimCaseTriggerInStage.
private void carInsuranceClaimCaseTriggerInStage(boolean useExistingStageId, boolean useExistingAdHocName) throws Exception {
// start case with users assigned to roles
String caseId = startCarInsuranceClaimCase(USER_YODA, USER_JOHN);
// let's verify case is created
assertCaseInstance(caseId);
// let's look at what stages are active
assertBuildClaimReportStage(caseId);
// since the first task assigned to insured is with auto start it should be already active
// the same task can be claimed by insuranceRepresentative in case claim is reported over phone
long taskId = assertBuildClaimReportAvailableForBothRoles(USER_YODA, USER_JOHN);
// let's provide claim report with initial data
// claim report should be stored in case file data
provideAndAssertClaimReport(caseId, taskId, USER_YODA);
// now we have another task for insured to provide property damage report
taskId = assertPropertyDamageReportAvailableForBothRoles(USER_YODA, USER_JOHN);
// let's provide the property damage report
provideAndAssertPropertyDamageReport(caseId, taskId, USER_YODA);
// let's complete the stage by explicitly stating that claimReport is done
caseClient.putCaseInstanceData(CONTAINER_ID, caseId, "claimReportDone", Boolean.TRUE);
// we should be in another stage - Claim assessment
assertClaimAssesmentStage(caseId);
// let's trigger claim offer calculation
CaseDefinition definition = caseClient.getCaseDefinition(CONTAINER_ID, CLAIM_CASE_DEF_ID);
CaseStageDefinition stage = definition.getCaseStages().stream().filter(s -> s.getName().equals("Claim assesment")).findFirst().get();
List<Integer> activeStatusList = Collections.singletonList(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE);
if (!useExistingStageId) {
String stageId = "non existing stage id";
Assertions.assertThatExceptionOfType(KieServicesException.class).isThrownBy(() -> caseClient.triggerAdHocFragmentInStage(CONTAINER_ID, caseId, stageId, "Calculate claim", null)).withMessageContaining("No stage found with id " + stageId);
// there should be still process instances for the case
Collection<ProcessInstance> caseProcesInstances = caseClient.getProcessInstances(CONTAINER_ID, caseId, activeStatusList, 0, 10);
assertEquals(1, caseProcesInstances.size());
} else if (!useExistingAdHocName) {
String adHocName = "non existing ad hoc fragment";
Assertions.assertThatExceptionOfType(KieServicesException.class).isThrownBy(() -> caseClient.triggerAdHocFragmentInStage(CONTAINER_ID, caseId, stage.getIdentifier(), adHocName, null)).withMessageContaining("AdHoc fragment '" + adHocName + "' not found in case " + caseId + " and stage " + stage.getIdentifier());
// there should be still process instances for the case
Collection<ProcessInstance> caseProcesInstances = caseClient.getProcessInstances(CONTAINER_ID, caseId, activeStatusList, 0, 10);
assertEquals(1, caseProcesInstances.size());
} else {
caseClient.triggerAdHocFragmentInStage(CONTAINER_ID, caseId, stage.getIdentifier(), "Calculate claim", null);
// now we have another task for insured as claim was calculated
// let's accept the calculated claim
assertAndAcceptClaimOffer(USER_YODA);
// there should be no process instances for the case
Collection<ProcessInstance> caseProcesInstances = caseClient.getProcessInstances(CONTAINER_ID, caseId, activeStatusList, 0, 10);
assertEquals(0, caseProcesInstances.size());
}
}
use of org.kie.server.api.model.cases.CaseDefinition in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method getCaseDefinition.
@Override
public CaseDefinition getCaseDefinition(String containerId, String caseDefinitionId) {
CaseDefinition result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(CASE_DEF_ID, caseDefinitionId);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_DEFINITIONS_BY_ID_GET_URI, valuesMap), CaseDefinition.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseDefinition", new Object[] { containerId, caseDefinitionId })));
ServiceResponse<CaseDefinition> response = (ServiceResponse<CaseDefinition>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
return result;
}
Aggregations