public InternalCallContext createInternalCallContext(final Long tenantRecordId, final Long accountRecordId, final InternalCallContext context) { return new InternalCallContext(tenantRecordId, accountRecordId, context.getUserToken(), context.getCreatedBy(), context.getCallOrigin(), context.getContextUserType(), context.getReasonCode(), context.getComments(), context.getCreatedDate(), context.getUpdatedDate()); }
@Override public TenantContext createTenantContext(final UUID tenantId) { return new DefaultTenantContext(tenantId); }
public BlockingStateModelDao(final BlockingState src, final InternalCallContext context) { this(src, context.getCreatedDate(), context.getUpdatedDate()); }
private OverdueChangeInternalEvent createOverdueEvent(final Account overdueable, final String previousOverdueStateName, final String nextOverdueStateName, final boolean isBlockedBilling, final boolean isUnblockedBilling, final InternalCallContext context) throws BlockingApiException { return new DefaultOverdueChangeEvent(overdueable.getId(), previousOverdueStateName, nextOverdueStateName, isBlockedBilling, isUnblockedBilling, context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken()); }
@Override public Void withHandle(final Handle handle) throws Exception { handle.execute("drop table if exists " + tableNameA); handle.execute("create table " + tableNameA + "(record_id int(11) unsigned not null auto_increment," + "a_column char default 'a'," + "account_record_id int(11) unsigned not null," + "tenant_record_id int(11) unsigned default 0," + "primary key(record_id));"); handle.execute("drop table if exists " + tableNameB); handle.execute("create table " + tableNameB + "(record_id int(11) unsigned not null auto_increment," + "b_column char default 'b'," + "account_record_id int(11) unsigned not null," + "tenant_record_id int(11) unsigned default 0," + "primary key(record_id));"); handle.execute("insert into " + tableNameA + " (account_record_id, tenant_record_id) values (?, ?)", internalCallContext.getAccountRecordId(), internalCallContext.getTenantRecordId()); handle.execute("insert into " + tableNameB + " (account_record_id, tenant_record_id) values (?, ?)", internalCallContext.getAccountRecordId(), internalCallContext.getTenantRecordId()); // Add row in accounts table handle.execute("insert into accounts (record_id, id, email, name, first_name_length, is_notified_for_invoices, created_date, created_by, updated_date, updated_by, tenant_record_id) " + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", internalCallContext.getAccountRecordId(), accountId, accountEmail, accountName, firstNameLength, isNotifiedForInvoices, createdDate, createdBy, updatedDate, updatedBy, internalCallContext.getTenantRecordId()); return null; } });
protected TenantContext buildTenantContext(final InternalTenantContext context) { return context.toTenantContext(nonEntityDao.retrieveIdFromObject(context.getTenantRecordId(), ObjectType.TENANT)); }
@Override public InvoiceItemModelDao inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception { final InvoiceItemModelDao invoiceItemAdjustment = invoiceDaoHelper.createAdjustmentItem(entitySqlDaoWrapperFactory, invoiceId, invoiceItemId, positiveAdjAmount, currency, effectiveDate, context); invoiceDaoHelper.insertItem(entitySqlDaoWrapperFactory, invoiceItemAdjustment, context); cbaDao.doCBAComplexity(accountId, entitySqlDaoWrapperFactory, context); notifyBusOfInvoiceAdjustment(entitySqlDaoWrapperFactory, invoiceId, accountId, context.getUserToken(), context); return invoiceItemAdjustment; } });
public InternalTenantContext createInternalTenantContext(final UUID accountId, final InternalTenantContext context) { final Long tenantRecordId = context.getTenantRecordId(); final Long accountRecordId = getAccountRecordId(accountId, ObjectType.ACCOUNT); return new InternalTenantContext(tenantRecordId, accountRecordId); }
@Override public void addTag(final UUID objectId, final ObjectType objectType, final UUID tagDefinitionId, final InternalCallContext context) throws TagApiException { final TagModelDao tag = new TagModelDao(context.getCreatedDate(), tagDefinitionId, objectId, objectType); tagDao.create(tag, context); }
@Override public CallContext createCallContext(@Nullable final UUID tenantId, final String userName, final CallOrigin callOrigin, final UserType userType, final String reasonCode, final String comment, final UUID userToken) { return new DefaultCallContext(tenantId, userName, callOrigin, userType, reasonCode, comment, userToken, clock); }
/** * Create an internal tenant callcontext * * @param tenantRecordId tenant_record_id (cannot be null) * @param accountRecordId account_record_id (cannot be null for INSERT operations) * @return internal tenant callcontext */ public InternalTenantContext createInternalTenantContext(final Long tenantRecordId, @Nullable final Long accountRecordId) { //Preconditions.checkNotNull(tenantRecordId, "tenantRecordId cannot be null"); return new InternalTenantContext(tenantRecordId, accountRecordId); }
/** * Create an internal call callcontext without populating the account record id * <p/> * This is used for update/delete operations - we don't need the account id in that case - and * also when we don't have an account_record_id column (e.g. tenants, tag_definitions) * * @param context original call callcontext * @return internal call callcontext */ public InternalCallContext createInternalCallContext(final CallContext context) { // If tenant id is null, this will default to the default tenant record id (multi-tenancy disabled) final Long tenantRecordId = getTenantRecordId(context); return new InternalCallContext(tenantRecordId, null, context); }
public InternalCallContext createInternalCallContext(final Long accountRecordId, final InternalCallContext context) { return new InternalCallContext(context.getTenantRecordId(), accountRecordId, context.getUserToken(), context.getCreatedBy(), context.getCallOrigin(), context.getContextUserType(), context.getReasonCode(), context.getComments(), context.getCreatedDate(), context.getUpdatedDate()); }
private void recordFutureNotificationFromTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> transactionalDao, final DateTime effectiveDate, final NotificationEvent notificationKey, final InternalCallContext context) { try { final NotificationQueue subscriptionEventQueue = notificationQueueService.getNotificationQueue(DefaultSubscriptionBaseService.SUBSCRIPTION_SERVICE_NAME, DefaultSubscriptionBaseService.NOTIFICATION_QUEUE_NAME); subscriptionEventQueue.recordFutureNotificationFromTransaction(null, effectiveDate, notificationKey, context.getUserToken(), context.getAccountRecordId(), context.getTenantRecordId()); } catch (NoSuchNotificationQueue e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }
private TenantContext buildTenantContext(final InternalTenantContext context) { return context.toTenantContext(nonEntityDao.retrieveIdFromObject(context.getTenantRecordId(), ObjectType.TENANT)); }
@Override public CallContext createCallContext(@Nullable final UUID tenantId, final String userName, final CallOrigin callOrigin, final UserType userType, @Nullable final UUID userToken) { return new DefaultCallContext(tenantId, userName, callOrigin, userType, userToken, clock); }
public InternalTenantContext createInternalTenantContext(final UUID accountId, final TenantContext context) { final Long tenantRecordId = getTenantRecordId(context); final Long accountRecordId = getAccountRecordId(accountId, ObjectType.ACCOUNT); return new InternalTenantContext(tenantRecordId, accountRecordId); }
private InternalCallContext createInternalCallContext(@Nullable final Long tenantRecordId, final Long accountRecordId, final String userName, final CallOrigin callOrigin, final UserType userType, @Nullable final UUID userToken, @Nullable final String reasonCode, @Nullable final String comment, final DateTime createdDate, final DateTime updatedDate) { //Preconditions.checkNotNull(accountRecordId, "accountRecordId cannot be null"); final Long nonNulTenantRecordId = Objects.firstNonNull(tenantRecordId, INTERNAL_TENANT_RECORD_ID); return new InternalCallContext(nonNulTenantRecordId, accountRecordId, userToken, userName, callOrigin, userType, reasonCode, comment, createdDate, updatedDate); }
private void verifyInternalCallContext(final InternalCallContext context) { Assert.assertEquals(context.getCallOrigin(), callContext.getCallOrigin()); Assert.assertEquals(context.getComments(), callContext.getComments()); Assert.assertEquals(context.getCreatedDate(), callContext.getCreatedDate()); Assert.assertEquals(context.getReasonCode(), callContext.getReasonCode()); Assert.assertEquals(context.getUpdatedDate(), callContext.getUpdatedDate()); Assert.assertEquals(context.getCreatedBy(), callContext.getUserName()); Assert.assertEquals(context.getUserToken(), callContext.getUserToken()); Assert.assertEquals(context.getContextUserType(), callContext.getUserType()); // Our test callcontext doesn't have a tenant id Assert.assertEquals(context.getTenantRecordId(), (Long) InternalCallContextFactory.INTERNAL_TENANT_RECORD_ID); } }
@Override public Tenant getTenantById(final UUID id) throws TenantApiException { // TODO - API cleanup? final TenantModelDao tenant = tenantDao.getById(id, new InternalTenantContext(null, null)); if (tenant == null) { throw new TenantApiException(ErrorCode.TENANT_DOES_NOT_EXIST_FOR_ID, id); } return new DefaultTenant(tenant); }