public HistoryEvent createActivityInstanceUpdateEvt(DelegateExecution execution, DelegateTask task) {
final ExecutionEntity executionEntity = (ExecutionEntity) execution;
// create event instance
HistoricActivityInstanceEventEntity evt = loadActivityInstanceEventEntity(executionEntity);
// initialize event
initActivityInstanceEvent(evt, executionEntity, HistoryEventTypes.ACTIVITY_INSTANCE_UPDATE);
// update task assignment
if(task != null) {
evt.setTaskId(task.getId());
evt.setTaskAssignee(task.getAssignee());
}
// update sub process reference
ExecutionEntity subProcessInstance = executionEntity.getSubProcessInstance();
if (subProcessInstance != null) {
evt.setCalledProcessInstanceId(subProcessInstance.getId());
}
return evt;
}