use of org.activiti.engine.delegate.event.ActivitiEntityWithVariablesEvent in project Activiti by Activiti.
the class ProcessInstanceStartedEventHandler method generateEventLogEntry.
@Override
public EventLogEntryEntity generateEventLogEntry(CommandContext commandContext) {
ActivitiEntityWithVariablesEvent eventWithVariables = (ActivitiEntityWithVariablesEvent) event;
ExecutionEntity processInstanceEntity = (ExecutionEntity) eventWithVariables.getEntity();
Map<String, Object> data = new HashMap<String, Object>();
putInMapIfNotNull(data, Fields.ID, processInstanceEntity.getId());
putInMapIfNotNull(data, Fields.BUSINESS_KEY, processInstanceEntity.getBusinessKey());
putInMapIfNotNull(data, Fields.PROCESS_DEFINITION_ID, processInstanceEntity.getProcessDefinitionId());
putInMapIfNotNull(data, Fields.NAME, processInstanceEntity.getName());
putInMapIfNotNull(data, Fields.CREATE_TIME, timeStamp);
if (eventWithVariables.getVariables() != null && !eventWithVariables.getVariables().isEmpty()) {
Map<String, Object> variableMap = new HashMap<String, Object>();
for (Object variableName : eventWithVariables.getVariables().keySet()) {
putInMapIfNotNull(variableMap, (String) variableName, eventWithVariables.getVariables().get(variableName));
}
putInMapIfNotNull(data, Fields.VARIABLES, variableMap);
}
return createEventLogEntry(TYPE, processInstanceEntity.getProcessDefinitionId(), processInstanceEntity.getId(), null, null, data);
}
use of org.activiti.engine.delegate.event.ActivitiEntityWithVariablesEvent in project Activiti by Activiti.
the class TaskCompletedEventHandler method generateEventLogEntry.
@Override
public EventLogEntryEntity generateEventLogEntry(CommandContext commandContext) {
ActivitiEntityWithVariablesEvent eventWithVariables = (ActivitiEntityWithVariablesEvent) event;
TaskEntity task = (TaskEntity) eventWithVariables.getEntity();
Map<String, Object> data = handleCommonTaskFields(task);
long duration = timeStamp.getTime() - task.getCreateTime().getTime();
putInMapIfNotNull(data, Fields.DURATION, duration);
if (eventWithVariables.getVariables() != null && !eventWithVariables.getVariables().isEmpty()) {
Map<String, Object> variableMap = new HashMap<String, Object>();
for (Object variableName : eventWithVariables.getVariables().keySet()) {
putInMapIfNotNull(variableMap, (String) variableName, eventWithVariables.getVariables().get(variableName));
}
if (eventWithVariables.isLocalScope()) {
putInMapIfNotNull(data, Fields.LOCAL_VARIABLES, variableMap);
} else {
putInMapIfNotNull(data, Fields.VARIABLES, variableMap);
}
}
return createEventLogEntry(task.getProcessDefinitionId(), task.getProcessInstanceId(), task.getExecutionId(), task.getId(), data);
}
Aggregations