use of org.activiti.engine.impl.persistence.entity.EventLogEntryEntity in project Activiti by Activiti.
the class AbstractDatabaseEventLoggerEventHandler method createEventLogEntry.
protected EventLogEntryEntity createEventLogEntry(String type, String processDefinitionId, String processInstanceId, String executionId, String taskId, Map<String, Object> data) {
EventLogEntryEntity eventLogEntry = new EventLogEntryEntity();
eventLogEntry.setProcessDefinitionId(processDefinitionId);
eventLogEntry.setProcessInstanceId(processInstanceId);
eventLogEntry.setExecutionId(executionId);
eventLogEntry.setTaskId(taskId);
eventLogEntry.setType(type);
eventLogEntry.setTimeStamp(timeStamp);
putInMapIfNotNull(data, Fields.TIMESTAMP, timeStamp);
// Current user
String userId = Authentication.getAuthenticatedUserId();
if (userId != null) {
eventLogEntry.setUserId(userId);
putInMapIfNotNull(data, "userId", userId);
}
// Current tenant
if (!data.containsKey(Fields.TENANT_ID) && processDefinitionId != null) {
DeploymentCache<ProcessDefinitionEntity> processDefinitionCache = Context.getProcessEngineConfiguration().getProcessDefinitionCache();
if (processDefinitionCache != null) {
ProcessDefinitionEntity processDefinitionEntity = processDefinitionCache.get(processDefinitionId);
if (processDefinitionEntity != null && !ProcessEngineConfigurationImpl.NO_TENANT_ID.equals(processDefinitionEntity.getTenantId())) {
putInMapIfNotNull(data, Fields.TENANT_ID, processDefinitionEntity.getTenantId());
}
}
}
try {
eventLogEntry.setData(objectMapper.writeValueAsBytes(data));
} catch (Exception e) {
logger.warn("Could not serialize event data. Data will not be written to the database", e);
}
return eventLogEntry;
}
use of org.activiti.engine.impl.persistence.entity.EventLogEntryEntity in project Activiti by Activiti.
the class TestVariableEventListenerStore method onEvent.
@Override
public void onEvent(ActivitiEvent event) {
if (event instanceof ActivitiVariableEvent) {
eventsReceived.add(event);
EventLogEntryEntity eventLogEntry = new EventLogEntryEntity();
eventLogEntry.setProcessDefinitionId(event.getProcessDefinitionId());
eventLogEntry.setProcessInstanceId(event.getProcessInstanceId());
eventLogEntry.setExecutionId(event.getExecutionId());
eventLogEntry.setTaskId(((ActivitiVariableEvent) event).getTaskId());
eventLogEntry.setType(event.getType().name());
eventLogEntry.setTimeStamp(new Date());
CommandContext commandContext = Context.getCommandContext();
commandContext.getEventLogEntryEntityManager().insert(eventLogEntry);
}
}
Aggregations