Search in sources :

Example 1 with HistoricScopeInstanceEvent

use of org.camunda.bpm.engine.impl.history.event.HistoricScopeInstanceEvent in project camunda-bpm-platform by camunda.

the class DbHistoryEventHandler method insertOrUpdate.

/**
 * general history event insert behavior
 */
protected void insertOrUpdate(HistoryEvent historyEvent) {
    final DbEntityManager dbEntityManager = getDbEntityManager();
    if (isInitialEvent(historyEvent)) {
        dbEntityManager.insert(historyEvent);
    } else {
        if (dbEntityManager.getCachedEntity(historyEvent.getClass(), historyEvent.getId()) == null) {
            if (historyEvent instanceof HistoricScopeInstanceEvent) {
                // if this is a scope, get start time from existing event in DB
                HistoricScopeInstanceEvent existingEvent = (HistoricScopeInstanceEvent) dbEntityManager.selectById(historyEvent.getClass(), historyEvent.getId());
                if (existingEvent != null) {
                    HistoricScopeInstanceEvent historicScopeInstanceEvent = (HistoricScopeInstanceEvent) historyEvent;
                    historicScopeInstanceEvent.setStartTime(existingEvent.getStartTime());
                }
            }
            if (historyEvent.getId() == null) {
            // dbSqlSession.insert(historyEvent);
            } else {
                dbEntityManager.merge(historyEvent);
            }
        }
    }
}
Also used : DbEntityManager(org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager) HistoricScopeInstanceEvent(org.camunda.bpm.engine.impl.history.event.HistoricScopeInstanceEvent)

Aggregations

DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)1 HistoricScopeInstanceEvent (org.camunda.bpm.engine.impl.history.event.HistoricScopeInstanceEvent)1