Search in sources :

Example 1 with CaseEvent

use of org.jbpm.casemgmt.api.event.CaseEvent in project jbpm by kiegroup.

the class NotifyParentCaseEventListener method afterProcessCompleted.

@Override
public void afterProcessCompleted(ProcessCompletedEvent event) {
    CaseFileInstance caseFile = getCaseFile((KieSession) event.getKieRuntime());
    if (caseFile != null) {
        String caseId = ((WorkflowProcessInstanceImpl) event.getProcessInstance()).getCorrelationKey();
        if (caseFile.getCaseId().equals(caseId)) {
            logger.debug("Process instance {} that represents main case instance {} has completed/was aborted, notify parent if exists", event.getProcessInstance().getId(), caseId);
            CaseEvent caseEvent = null;
            if (event.getProcessInstance().getState() == ProcessInstance.STATE_COMPLETED) {
                caseEvent = new CaseCloseEvent(identityProvider.getName(), caseId, caseFile, "");
            } else {
                caseEvent = new CaseCancelEvent(identityProvider.getName(), caseId, caseFile, Arrays.asList(event.getProcessInstance().getId()));
            }
            notifyParentOnCompletion(caseEvent);
        }
    }
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CaseCancelEvent(org.jbpm.casemgmt.api.event.CaseCancelEvent) WorkflowProcessInstanceImpl(org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl) CaseEvent(org.jbpm.casemgmt.api.event.CaseEvent) CaseCloseEvent(org.jbpm.casemgmt.api.event.CaseCloseEvent)

Aggregations

CaseCancelEvent (org.jbpm.casemgmt.api.event.CaseCancelEvent)1 CaseCloseEvent (org.jbpm.casemgmt.api.event.CaseCloseEvent)1 CaseEvent (org.jbpm.casemgmt.api.event.CaseEvent)1 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)1 WorkflowProcessInstanceImpl (org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl)1