use of org.jbpm.casemgmt.api.model.instance.CaseFileInstance in project jbpm by kiegroup.
the class StartProcessSLAViolationListener method getCaseFile.
protected CaseFileInstance getCaseFile(KieSession ksession) {
Collection<? extends Object> caseFiles = ksession.getObjects(new ClassObjectFilter(CaseFileInstance.class));
if (caseFiles.size() == 0) {
return null;
}
CaseFileInstance caseFile = (CaseFileInstance) caseFiles.iterator().next();
return caseFile;
}
use of org.jbpm.casemgmt.api.model.instance.CaseFileInstance in project jbpm by kiegroup.
the class StartProcessSLAViolationListener method afterSLAViolated.
@Override
public void afterSLAViolated(SLAViolatedEvent event) {
CaseFileInstance caseFile = getCaseFile((KieSession) event.getKieRuntime());
if (caseFile != null) {
String caseId = ((WorkflowProcessInstanceImpl) event.getProcessInstance()).getCorrelationKey();
if (caseFile.getCaseId().equals(caseId)) {
logger.debug("Case instance {} has SLA violation, escalating starting new process instance for {}", caseId, processId);
CaseService caseService = (CaseService) ServiceRegistry.get().service(ServiceRegistry.CASE_SERVICE);
Long slaViolationProcessInstanceId = caseService.addDynamicSubprocess(caseId, processId, null);
logger.debug("Process instance with id {} was created to handle SLA violation for case {}", slaViolationProcessInstanceId, caseId);
}
}
}
use of org.jbpm.casemgmt.api.model.instance.CaseFileInstance in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method provideAndAssertPropertyDamageReport.
protected void provideAndAssertPropertyDamageReport(Long taskId) {
PropertyDamageReport damageReport = new PropertyDamageReport("Car is completely destroyed", 1000.0);
Map<String, Object> params = new HashMap<>();
params.put("propertyDamageReport_", damageReport);
userTaskService.completeAutoProgress(taskId, "john", params);
// property damage report should be stored in case file data
CaseFileInstance caseFile = caseService.getCaseFileInstance(CAR_INS_CASE_ID);
assertNotNull(caseFile);
PropertyDamageReport casePropertyDamageReport = (PropertyDamageReport) caseFile.getData("propertyDamageReport");
assertNotNull(casePropertyDamageReport);
}
use of org.jbpm.casemgmt.api.model.instance.CaseFileInstance in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method attachAndAssertPoliceReport.
protected void attachAndAssertPoliceReport() {
caseService.triggerAdHocFragment(CAR_INS_CASE_ID, "Submit police report", null);
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertNotNull(tasks);
assertEquals(2, tasks.size());
assertTask(tasks.get(0), null, "Submit police report", Status.Ready);
assertTask(tasks.get(1), null, "File property damage claim", Status.Ready);
byte[] docContent = "police report content".getBytes();
DocumentImpl document = new DocumentImpl(UUID.randomUUID().toString(), "car-accident-police-report.txt", docContent.length, new Date());
document.setContent(docContent);
Map<String, Object> params = new HashMap<>();
params.put("policeReport_", document);
userTaskService.completeAutoProgress(tasks.get(0).getId(), "john", params);
// police report should be stored in case file data
CaseFileInstance caseFile = caseService.getCaseFileInstance(CAR_INS_CASE_ID);
assertNotNull(caseFile);
Document policeReport = (Document) caseFile.getData("policeReport");
assertNotNull(policeReport);
assertEquals("car-accident-police-report.txt", policeReport.getName());
}
use of org.jbpm.casemgmt.api.model.instance.CaseFileInstance in project jbpm by kiegroup.
the class CarInsuranceClaimCaseTest method assertAndProvideAdditionalDetails.
protected void assertAndProvideAdditionalDetails() {
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter());
assertNotNull(tasks);
assertEquals(1, tasks.size());
assertTask(tasks.get(0), "john", "Please provide additional details", Status.Reserved);
long taskId = tasks.get(0).getId();
Map<String, Object> inputs = userTaskService.getTaskInputContentByTaskId(taskId);
assertNotNull(inputs);
assertEquals("How did it happen?", inputs.get("reason"));
Map<String, Object> params = new HashMap<>();
params.put("caseFile_answer", "It just happened in a split second, don't remember anything else");
userTaskService.completeAutoProgress(taskId, "john", params);
CaseFileInstance caseFile = caseService.getCaseFileInstance(CAR_INS_CASE_ID);
assertNotNull(caseFile);
String answer = (String) caseFile.getData("answer");
assertNotNull(answer);
assertEquals("It just happened in a split second, don't remember anything else", answer);
}
Aggregations