Search in sources :

Example 1 with ActivitiEntityWithVariablesEvent

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);
}
Also used : ActivitiEntityWithVariablesEvent(org.activiti.engine.delegate.event.ActivitiEntityWithVariablesEvent) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) HashMap(java.util.HashMap)

Example 2 with ActivitiEntityWithVariablesEvent

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);
}
Also used : TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) ActivitiEntityWithVariablesEvent(org.activiti.engine.delegate.event.ActivitiEntityWithVariablesEvent) HashMap(java.util.HashMap)

Aggregations

HashMap (java.util.HashMap)2 ActivitiEntityWithVariablesEvent (org.activiti.engine.delegate.event.ActivitiEntityWithVariablesEvent)2 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)1 TaskEntity (org.activiti.engine.impl.persistence.entity.TaskEntity)1