@Override public synchronized void setBlockingState( final BlockingState state, final Clock clock, final InternalCallContext context) { if (blockingStates.get(state.getBlockedId()) == null) { blockingStates.put(state.getBlockedId(), new ArrayList<BlockingState>()); } blockingStates.get(state.getBlockedId()).add(state); if (blockingStatesPerAccountRecordId.get(context.getAccountRecordId()) == null) { blockingStatesPerAccountRecordId.put( context.getAccountRecordId(), new ArrayList<BlockingState>()); } blockingStatesPerAccountRecordId.get(context.getAccountRecordId()).add(state); }
public RawUsageOptimizerResult getConsumableInArrearUsage( final LocalDate firstEventStartDate, final LocalDate targetDate, final Iterable<InvoiceItem> existingUsageItems, final Map<String, Usage> knownUsage, final InternalCallContext internalCallContext) { final LocalDate targetStartDate = config.getMaxRawUsagePreviousPeriod() > 0 ? getOptimizedRawUsageStartDate( firstEventStartDate, targetDate, existingUsageItems, knownUsage) : firstEventStartDate; log.info( "RawUsageOptimizer [accountRecordId = {}]: rawUsageStartDate = {}, (proposed) firstEventStartDate = {}", new Object[] { internalCallContext.getAccountRecordId(), targetStartDate, firstEventStartDate }); final List<RawUsage> rawUsageData = usageApi.getRawUsageForAccount(targetStartDate, targetDate, internalCallContext); return new RawUsageOptimizerResult(firstEventStartDate, targetStartDate, rawUsageData); }
@Override protected void postBusEventFromTransaction( final AccountModelDao account, final AccountModelDao savedAccount, final ChangeType changeType, final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory, final InternalCallContext context) throws BillingExceptionBase { // This is only called for the create call (see update below) switch (changeType) { case INSERT: break; default: return; } final Long recordId = entitySqlDaoWrapperFactory .become(AccountSqlDao.class) .getRecordId(savedAccount.getId().toString(), context); // We need to re-hydrate the callcontext with the account record id final InternalCallContext rehydratedContext = internalCallContextFactory.createInternalCallContext(recordId, context); final AccountCreationInternalEvent creationEvent = new DefaultAccountCreationEvent( new DefaultAccountData(savedAccount), savedAccount.getId(), rehydratedContext.getAccountRecordId(), rehydratedContext.getTenantRecordId(), rehydratedContext.getUserToken()); try { eventBus.postFromTransaction( creationEvent, entitySqlDaoWrapperFactory.getHandle().getConnection()); } catch (final EventBusException e) { log.warn("Failed to post account creation event for accountId='{}'", savedAccount.getId(), e); } }