Search in sources :

Example 36 with CaseFileInstance

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;
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) ClassObjectFilter(org.drools.core.ClassObjectFilter)

Example 37 with CaseFileInstance

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);
        }
    }
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) WorkflowProcessInstanceImpl(org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl) CaseService(org.jbpm.casemgmt.api.CaseService)

Example 38 with CaseFileInstance

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);
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) HashMap(java.util.HashMap) PropertyDamageReport(org.jbpm.casemgmt.demo.insurance.PropertyDamageReport)

Example 39 with CaseFileInstance

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());
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary) Document(org.jbpm.document.Document) DocumentImpl(org.jbpm.document.service.impl.DocumentImpl) Date(java.util.Date)

Example 40 with CaseFileInstance

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);
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) QueryFilter(org.kie.internal.query.QueryFilter) HashMap(java.util.HashMap) TaskSummary(org.kie.api.task.model.TaskSummary)

Aggregations

CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)121 HashMap (java.util.HashMap)95 Test (org.junit.Test)86 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)81 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)66 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)61 UserImpl (org.jbpm.services.task.impl.model.UserImpl)54 QueryContext (org.kie.api.runtime.query.QueryContext)46 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)44 CaseCommentNotFoundException (org.jbpm.casemgmt.api.CaseCommentNotFoundException)42 TaskSummary (org.kie.api.task.model.TaskSummary)40 AdHocFragmentNotFoundException (org.jbpm.casemgmt.api.AdHocFragmentNotFoundException)39 CaseActiveException (org.jbpm.casemgmt.api.CaseActiveException)39 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)39 QueryFilter (org.kie.internal.query.QueryFilter)26 ArrayList (java.util.ArrayList)21 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)20 Collection (java.util.Collection)17 List (java.util.List)17 Map (java.util.Map)16