public Long retrieveRecordIdFromObjectInTransaction(@Nullable final UUID objectId, final ObjectType objectType, @Nullable final CacheController<String, Long> cache, @Nullable final Handle handle) { if (objectId == null) { return null; } final TableName tableName = TableName.fromObjectType(objectType); Preconditions.checkNotNull(tableName, "%s is not a valid ObjectType", objectType); return withCachingObjectId.withCaching(new OperationRetrieval<Long>() { @Override public Long doRetrieve(final ObjectType objectType) { final NonEntitySqlDao inTransactionNonEntitySqlDao = handle == null ? dbRouter.onDemand(true) : SqlObjectBuilder.attach(handle, NonEntitySqlDao.class); return inTransactionNonEntitySqlDao.getRecordIdFromObject(objectId.toString(), tableName.getTableName()); } }, objectId.toString(), objectType, tableName, cache); }
@Override public UUID retrieveIdFromObjectInTransaction(final Long recordId, final ObjectType objectType, @Nullable final CacheController<String, UUID> cache, @Nullable final Handle handle) { if (objectType == ObjectType.TENANT && InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID.equals(recordId)) { return null; } final TableName tableName = TableName.fromObjectType(objectType); Preconditions.checkNotNull(tableName, "%s is not a valid ObjectType", objectType); return withCachingRecordId.withCaching(new OperationRetrieval<UUID>() { @Override public UUID doRetrieve(final ObjectType objectType) { final NonEntitySqlDao inTransactionNonEntitySqlDao = handle == null ? dbRouter.onDemand(true) : SqlObjectBuilder.attach(handle, NonEntitySqlDao.class); return inTransactionNonEntitySqlDao.getIdFromObject(recordId, tableName.getTableName()); } }, String.valueOf(recordId), objectType, tableName, cache); }
@Override public Long retrieveTenantRecordIdFromObjectInTransaction(@Nullable final UUID objectId, final ObjectType objectType, @Nullable final CacheController<String, Long> cache, @Nullable final Handle handle) { final TableName tableName = TableName.fromObjectType(objectType); Preconditions.checkNotNull(tableName, "%s is not a valid ObjectType", objectType); final String objectIdOrNull = objectId != null ? objectId.toString() : null; return withCachingObjectId.withCaching(new OperationRetrieval<Long>() { @Override public Long doRetrieve(final ObjectType objectType) { final NonEntitySqlDao inTransactionNonEntitySqlDao = handle == null ? dbRouter.onDemand(true) : SqlObjectBuilder.attach(handle, NonEntitySqlDao.class); switch (tableName) { case TENANT: // Explicit cast to Long to avoid NPE (unboxing to long) return objectId == null ? (Long) 0L : inTransactionNonEntitySqlDao.getTenantRecordIdFromTenant(objectIdOrNull); default: return inTransactionNonEntitySqlDao.getTenantRecordIdFromObjectOtherThanTenant(objectIdOrNull, tableName.getTableName()); } } }, objectIdOrNull, objectType, tableName, cache); }
@Override public Long retrieveAccountRecordIdFromObjectInTransaction(@Nullable final UUID objectId, final ObjectType objectType, @Nullable final CacheController<String, Long> cache, @Nullable final Handle handle) { final TableName tableName = TableName.fromObjectType(objectType); Preconditions.checkNotNull(tableName, "%s is not a valid ObjectType", objectType); final String objectIdOrNull = objectId != null ? objectId.toString() : null; return withCachingObjectId.withCaching(new OperationRetrieval<Long>() { @Override public Long doRetrieve(final ObjectType objectType) { final NonEntitySqlDao inTransactionNonEntitySqlDao = handle == null ? dbRouter.onDemand(true) : SqlObjectBuilder.attach(handle, NonEntitySqlDao.class); switch (tableName) { case TENANT: case TAG_DEFINITIONS: case TAG_DEFINITION_HISTORY: return null; case ACCOUNT: return inTransactionNonEntitySqlDao.getAccountRecordIdFromAccount(objectIdOrNull); default: return inTransactionNonEntitySqlDao.getAccountRecordIdFromObjectOtherThanAccount(objectIdOrNull, tableName.getTableName()); } } }, objectIdOrNull, objectType, tableName, cache); }
public Long retrieveRecordIdFromObjectInTransaction(@Nullable final UUID objectId, final ObjectType objectType, @Nullable final CacheController<String, Long> cache, @Nullable final Handle handle) { if (objectId == null) { return null; } final TableName tableName = TableName.fromObjectType(objectType); Preconditions.checkNotNull(tableName, "%s is not a valid ObjectType", objectType); return withCachingObjectId.withCaching(new OperationRetrieval<Long>() { @Override public Long doRetrieve(final ObjectType objectType) { final NonEntitySqlDao inTransactionNonEntitySqlDao = handle == null ? dbRouter.onDemand(true) : SqlObjectBuilder.attach(handle, NonEntitySqlDao.class); return inTransactionNonEntitySqlDao.getRecordIdFromObject(objectId.toString(), tableName.getTableName()); } }, objectId.toString(), objectType, tableName, cache); }
@Override public UUID retrieveIdFromObjectInTransaction(final Long recordId, final ObjectType objectType, @Nullable final CacheController<String, UUID> cache, @Nullable final Handle handle) { if (objectType == ObjectType.TENANT && InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID.equals(recordId)) { return null; } final TableName tableName = TableName.fromObjectType(objectType); Preconditions.checkNotNull(tableName, "%s is not a valid ObjectType", objectType); return withCachingRecordId.withCaching(new OperationRetrieval<UUID>() { @Override public UUID doRetrieve(final ObjectType objectType) { final NonEntitySqlDao inTransactionNonEntitySqlDao = handle == null ? dbRouter.onDemand(true) : SqlObjectBuilder.attach(handle, NonEntitySqlDao.class); return inTransactionNonEntitySqlDao.getIdFromObject(recordId, tableName.getTableName()); } }, String.valueOf(recordId), objectType, tableName, cache); }
@Override public Long retrieveTenantRecordIdFromObjectInTransaction(@Nullable final UUID objectId, final ObjectType objectType, @Nullable final CacheController<String, Long> cache, @Nullable final Handle handle) { final TableName tableName = TableName.fromObjectType(objectType); Preconditions.checkNotNull(tableName, "%s is not a valid ObjectType", objectType); final String objectIdOrNull = objectId != null ? objectId.toString() : null; return withCachingObjectId.withCaching(new OperationRetrieval<Long>() { @Override public Long doRetrieve(final ObjectType objectType) { final NonEntitySqlDao inTransactionNonEntitySqlDao = handle == null ? dbRouter.onDemand(true) : SqlObjectBuilder.attach(handle, NonEntitySqlDao.class); switch (tableName) { case TENANT: // Explicit cast to Long to avoid NPE (unboxing to long) return objectId == null ? (Long) 0L : inTransactionNonEntitySqlDao.getTenantRecordIdFromTenant(objectIdOrNull); default: return inTransactionNonEntitySqlDao.getTenantRecordIdFromObjectOtherThanTenant(objectIdOrNull, tableName.getTableName()); } } }, objectIdOrNull, objectType, tableName, cache); }
@Override public Long retrieveAccountRecordIdFromObjectInTransaction(@Nullable final UUID objectId, final ObjectType objectType, @Nullable final CacheController<String, Long> cache, @Nullable final Handle handle) { final TableName tableName = TableName.fromObjectType(objectType); Preconditions.checkNotNull(tableName, "%s is not a valid ObjectType", objectType); final String objectIdOrNull = objectId != null ? objectId.toString() : null; return withCachingObjectId.withCaching(new OperationRetrieval<Long>() { @Override public Long doRetrieve(final ObjectType objectType) { final NonEntitySqlDao inTransactionNonEntitySqlDao = handle == null ? dbRouter.onDemand(true) : SqlObjectBuilder.attach(handle, NonEntitySqlDao.class); switch (tableName) { case TENANT: case TAG_DEFINITIONS: case TAG_DEFINITION_HISTORY: return null; case ACCOUNT: return inTransactionNonEntitySqlDao.getAccountRecordIdFromAccount(objectIdOrNull); default: return inTransactionNonEntitySqlDao.getAccountRecordIdFromObjectOtherThanAccount(objectIdOrNull, tableName.getTableName()); } } }, objectIdOrNull, objectType, tableName, cache); }