Source:
protected static void populateEventWithCurrentContext(ActivitiEventImpl event) { if (event instanceof ActivitiEntityEvent) { Object persistedObject = ((ActivitiEntityEvent) event).getEntity(); if (persistedObject instanceof Job) { event.setExecutionId(((Job) persistedObject).getExecutionId()); event.setProcessInstanceId(((Job) persistedObject).getProcessInstanceId()); event.setProcessDefinitionId(((Job) persistedObject).getProcessDefinitionId()); } else if (persistedObject instanceof DelegateExecution) { event.setExecutionId(((DelegateExecution) persistedObject).getId()); event.setProcessInstanceId(((DelegateExecution) persistedObject).getProcessInstanceId()); event.setProcessDefinitionId(((DelegateExecution) persistedObject).getProcessDefinitionId()); } else if (persistedObject instanceof IdentityLinkEntity) { IdentityLinkEntity idLink = (IdentityLinkEntity) persistedObject; if (idLink.getProcessDefinitionId() != null) { event.setProcessDefinitionId(idLink.getProcessDefId()); } else if (idLink.getProcessInstance() != null) { event.setProcessDefinitionId(idLink.getProcessInstance().getProcessDefinitionId()); event.setProcessInstanceId(idLink.getProcessInstanceId()); event.setExecutionId(idLink.getProcessInstanceId()); } else if (idLink.getTask() != null) { event.setProcessDefinitionId(idLink.getTask().getProcessDefinitionId()); event.setProcessInstanceId(idLink.getTask().getProcessInstanceId()); event.setExecutionId(idLink.getTask().getExecutionId()); } } else if (persistedObject instanceof Task) { event.setProcessInstanceId(((Task) persistedObject).getProcessInstanceId()); event.setExecutionId(((Task) persistedObject).getExecutionId()); event.setProcessDefinitionId(((Task) persistedObject).getProcessDefinitionId()); ((ActivitiEntityEventImpl)event).setReason(TerminateEndEventActivityBehavior.createDeleteReason(null)); } else if (persistedObject instanceof ProcessDefinition) { event.setProcessDefinitionId(((ProcessDefinition) persistedObject).getId()); } } }

Target:
protected static void populateEventWithCurrentContext(ActivitiEventImpl event) { if (event instanceof ActivitiEntityEvent) { Object persistedObject = ((ActivitiEntityEvent) event).getEntity(); if (persistedObject instanceof Job) { event.setExecutionId(((Job) persistedObject).getExecutionId()); event.setProcessInstanceId(((Job) persistedObject).getProcessInstanceId()); event.setProcessDefinitionId(((Job) persistedObject).getProcessDefinitionId()); } else if (persistedObject instanceof DelegateExecution) { event.setExecutionId(((DelegateExecution) persistedObject).getId()); event.setProcessInstanceId(((DelegateExecution) persistedObject).getProcessInstanceId()); event.setProcessDefinitionId(((DelegateExecution) persistedObject).getProcessDefinitionId()); } else if (persistedObject instanceof IdentityLinkEntity) { IdentityLinkEntity idLink = (IdentityLinkEntity) persistedObject; if (idLink.getProcessDefinitionId() != null) { event.setProcessDefinitionId(idLink.getProcessDefId()); } else if (idLink.getProcessInstance() != null) { event.setProcessDefinitionId(idLink.getProcessInstance().getProcessDefinitionId()); event.setProcessInstanceId(idLink.getProcessInstanceId()); event.setExecutionId(idLink.getProcessInstanceId()); } else if (idLink.getTask() != null) { event.setProcessDefinitionId(idLink.getTask().getProcessDefinitionId()); event.setProcessInstanceId(idLink.getTask().getProcessInstanceId()); event.setExecutionId(idLink.getTask().getExecutionId()); } } else if (persistedObject instanceof Task) { event.setProcessInstanceId(((Task) persistedObject).getProcessInstanceId()); event.setExecutionId(((Task) persistedObject).getExecutionId()); event.setProcessDefinitionId(((Task) persistedObject).getProcessDefinitionId()); } else if (persistedObject instanceof ProcessDefinition) { event.setProcessDefinitionId(((ProcessDefinition) persistedObject).getId()); } } }