@Override public ImmutableAccountData loadAccount(final Long recordId, final InternalTenantContext context) { final Account account = getAccountByRecordIdInternal(recordId, context); return account != null ? new DefaultImmutableAccountData(account) : null; } };
protected Account getAccountById(final UUID accountId, final InternalTenantContext context) throws AccountApiException { final Long recordId = nonEntityDao.retrieveRecordIdFromObject(accountId, ObjectType.ACCOUNT, recordIdCacheController); final Account account = getAccountByRecordIdInternal(recordId, context); if (account == null) { throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_ID, accountId); } accountCacheController.putIfAbsent(recordId, new DefaultImmutableAccountData(account)); return account; }
protected Account getAccountByKey(final String key, final InternalTenantContext context) throws AccountApiException { final AccountModelDao accountModelDao = accountDao.getAccountByKey(key, context); if (accountModelDao == null) { throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_KEY, key); } final Account account = new DefaultAccount(accountModelDao); final Long recordId = nonEntityDao.retrieveRecordIdFromObject(account.getId(), ObjectType.ACCOUNT, recordIdCacheController); accountCacheController.putIfAbsent(recordId, new DefaultImmutableAccountData(account)); return account; }
@Override public void create(final AccountModelDao entity, final InternalCallContext context) throws AccountApiException { // We don't enforce the created_date for the Account because it is extracted from context // so, if there is no referenceTime specified we have to set it from the InternalCallContext#created_date // if (entity.getReferenceTime() == null) { entity.setReferenceTime(context.getCreatedDate()); } final AccountModelDao refreshedEntity = transactionalSqlDao.execute(false, getCreateEntitySqlDaoTransactionWrapper(entity, context)); // Populate the caches only after the transaction has been committed, in case of rollbacks transactionalSqlDao.populateCaches(refreshedEntity); // Eagerly populate the account-immutable cache as well accountImmutableCacheController.putIfAbsent(refreshedEntity.getRecordId(), new DefaultImmutableAccountData(refreshedEntity)); }
@Override public ImmutableAccountData loadAccount(final Long recordId, final InternalTenantContext context) { final Account account = getAccountByRecordIdInternal(recordId, context); return account != null ? new DefaultImmutableAccountData(account) : null; } };
protected Account getAccountById(final UUID accountId, final InternalTenantContext context) throws AccountApiException { final Long recordId = nonEntityDao.retrieveRecordIdFromObject(accountId, ObjectType.ACCOUNT, recordIdCacheController); final Account account = getAccountByRecordIdInternal(recordId, context); if (account == null) { throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_ID, accountId); } accountCacheController.putIfAbsent(recordId, new DefaultImmutableAccountData(account)); return account; }
protected Account getAccountByKey(final String key, final InternalTenantContext context) throws AccountApiException { final AccountModelDao accountModelDao = accountDao.getAccountByKey(key, context); if (accountModelDao == null) { throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_KEY, key); } final Account account = new DefaultAccount(accountModelDao); final Long recordId = nonEntityDao.retrieveRecordIdFromObject(account.getId(), ObjectType.ACCOUNT, recordIdCacheController); accountCacheController.putIfAbsent(recordId, new DefaultImmutableAccountData(account)); return account; }
@Override public void create(final AccountModelDao entity, final InternalCallContext context) throws AccountApiException { // We don't enforce the created_date for the Account because it is extracted from context // so, if there is no referenceTime specified we have to set it from the InternalCallContext#created_date // if (entity.getReferenceTime() == null) { entity.setReferenceTime(context.getCreatedDate()); } final AccountModelDao refreshedEntity = transactionalSqlDao.execute(false, getCreateEntitySqlDaoTransactionWrapper(entity, context)); // Populate the caches only after the transaction has been committed, in case of rollbacks transactionalSqlDao.populateCaches(refreshedEntity); // Eagerly populate the account-immutable cache as well accountImmutableCacheController.putIfAbsent(refreshedEntity.getRecordId(), new DefaultImmutableAccountData(refreshedEntity)); }