Search in sources :

Example 1 with ProcessService

use of org.jbpm.services.api.ProcessService in project jbpm by kiegroup.

the class NotifyParentCaseEventListener method notifyParentOnCompletion.

protected void notifyParentOnCompletion(CaseEvent event) {
    CaseFileInstanceImpl caseFileInstance = (CaseFileInstanceImpl) event.getCaseFile();
    if (caseFileInstance == null) {
        return;
    }
    if (caseFileInstance.getParentInstanceId() != null && caseFileInstance.getParentWorkItemId() != null) {
        logger.debug("Case {} has defined parent information instance {}, work item {}, going to notify it", event.getCaseId(), caseFileInstance.getParentInstanceId(), caseFileInstance.getParentWorkItemId());
        ProcessService processService = (ProcessService) ServiceRegistry.get().service(ServiceRegistry.PROCESS_SERVICE);
        Map<String, Object> results = new HashMap<>(caseFileInstance.getData());
        results.put("CaseId", event.getCaseId());
        processService.completeWorkItem(caseFileInstance.getParentWorkItemId(), results);
        logger.debug("Parent instance id {}, work item id {}, has been successfully notified about case {} completion", caseFileInstance.getParentInstanceId(), caseFileInstance.getParentWorkItemId(), event.getCaseId());
        caseFileInstance.setParentInstanceId(null);
        caseFileInstance.setParentWorkItemId(null);
    }
}
Also used : HashMap(java.util.HashMap) CaseFileInstanceImpl(org.jbpm.casemgmt.impl.model.instance.CaseFileInstanceImpl) ProcessService(org.jbpm.services.api.ProcessService)

Aggregations

HashMap (java.util.HashMap)1 CaseFileInstanceImpl (org.jbpm.casemgmt.impl.model.instance.CaseFileInstanceImpl)1 ProcessService (org.jbpm.services.api.ProcessService)1