@Override public EntityHistoryModelDao<M, E> map(final int index, final ResultSet r, final StatementContext ctx) throws SQLException { final UUID id = getUUID(r, "id"); final long targetRecordId = r.getLong("target_record_id"); final String changeType = r.getString("change_type"); final DateTime createdDate = getDateTime(r, "created_date"); // preserve history record id, as it is needed to reference it with audit log final long historyRecordId = r.getLong("history_record_id"); final M entityModelDao = entityMapper.map(index, r, ctx); // Hack -- remove the id as it is the history id, not the entity id ((EntityModelDaoBase) entityModelDao).setId(null); // Hack -- similarly, populate the right record_id ((EntityModelDaoBase) entityModelDao).setRecordId(targetRecordId); // Hack -- account is special if (entityModelDao.getAccountRecordId() == null) { ((EntityModelDaoBase) entityModelDao).setAccountRecordId(targetRecordId); } return new EntityHistoryModelDao(id, entityModelDao, targetRecordId, ChangeType.valueOf(changeType), historyRecordId, createdDate); } }
public static void populateCaches(final CacheControllerDispatcher cacheControllerDispatcher, final EntityModelDao model) { final CacheController<String, Long> cacheRecordId = cacheControllerDispatcher.getCacheController(CacheType.RECORD_ID); cacheRecordId.putIfAbsent(getKey(model.getId().toString(), CacheType.RECORD_ID, model.getTableName()), model.getRecordId()); final CacheController<String, UUID> cacheObjectId = cacheControllerDispatcher.getCacheController(CacheType.OBJECT_ID); cacheObjectId.putIfAbsent(getKey(model.getRecordId().toString(), CacheType.OBJECT_ID, model.getTableName()), model.getId()); if (model.getTenantRecordId() != null) { final CacheController<String, Long> cacheTenantRecordId = cacheControllerDispatcher.getCacheController(CacheType.TENANT_RECORD_ID); cacheTenantRecordId.putIfAbsent(getKey(model.getId().toString(), CacheType.TENANT_RECORD_ID, model.getTableName()), model.getTenantRecordId()); } if (model.getAccountRecordId() != null) { final CacheController<String, Long> cacheAccountRecordId = cacheControllerDispatcher.getCacheController(CacheType.ACCOUNT_RECORD_ID); cacheAccountRecordId.putIfAbsent(getKey(model.getId().toString(), CacheType.ACCOUNT_RECORD_ID, model.getTableName()), model.getAccountRecordId()); } }
@Override public EntityHistoryModelDao<M, E> map(final int index, final ResultSet r, final StatementContext ctx) throws SQLException { final UUID id = getUUID(r, "id"); final long targetRecordId = r.getLong("target_record_id"); final String changeType = r.getString("change_type"); final DateTime createdDate = getDateTime(r, "created_date"); // preserve history record id, as it is needed to reference it with audit log final long historyRecordId = r.getLong("history_record_id"); final M entityModelDao = entityMapper.map(index, r, ctx); // Hack -- remove the id as it is the history id, not the entity id ((EntityModelDaoBase) entityModelDao).setId(null); // Hack -- similarly, populate the right record_id ((EntityModelDaoBase) entityModelDao).setRecordId(targetRecordId); // Hack -- account is special if (entityModelDao.getAccountRecordId() == null) { ((EntityModelDaoBase) entityModelDao).setAccountRecordId(targetRecordId); } return new EntityHistoryModelDao(id, entityModelDao, targetRecordId, ChangeType.valueOf(changeType), historyRecordId, createdDate); } }
public static void populateCaches(final CacheControllerDispatcher cacheControllerDispatcher, final EntityModelDao model) { final CacheController<String, Long> cacheRecordId = cacheControllerDispatcher.getCacheController(CacheType.RECORD_ID); cacheRecordId.putIfAbsent(getKey(model.getId().toString(), CacheType.RECORD_ID, model.getTableName()), model.getRecordId()); final CacheController<String, UUID> cacheObjectId = cacheControllerDispatcher.getCacheController(CacheType.OBJECT_ID); cacheObjectId.putIfAbsent(getKey(model.getRecordId().toString(), CacheType.OBJECT_ID, model.getTableName()), model.getId()); if (model.getTenantRecordId() != null) { final CacheController<String, Long> cacheTenantRecordId = cacheControllerDispatcher.getCacheController(CacheType.TENANT_RECORD_ID); cacheTenantRecordId.putIfAbsent(getKey(model.getId().toString(), CacheType.TENANT_RECORD_ID, model.getTableName()), model.getTenantRecordId()); } if (model.getAccountRecordId() != null) { final CacheController<String, Long> cacheAccountRecordId = cacheControllerDispatcher.getCacheController(CacheType.ACCOUNT_RECORD_ID); cacheAccountRecordId.putIfAbsent(getKey(model.getId().toString(), CacheType.ACCOUNT_RECORD_ID, model.getTableName()), model.getAccountRecordId()); } }