/** 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); } } } }
/** 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); } } } }
protected boolean isInitialEvent(HistoryEvent historyEvent) { String isInitialEvent = "isInitialEvent"; return Api.feature(DbHistoryEventHandler.class, isInitialEvent, HistoryEvent.class).isSupported() ? super.isInitialEvent(historyEvent): (Boolean) Api.feature(DbHistoryEventHandler.class, isInitialEvent, String.class).invoke(this, historyEvent.getEventType()); }
/** 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); } } } }