@Override public Account createAccount(final AccountData data, final CallContext context) throws AccountApiException { // Not transactional, but there is a db constraint on that column if (data.getExternalKey() != null && getIdFromKey(data.getExternalKey(), context) != null) { throw new AccountApiException(ErrorCode.ACCOUNT_ALREADY_EXISTS, data.getExternalKey()); } final InternalCallContext internalContext = internalCallContextFactory.createInternalCallContextWithoutAccountRecordId(context); if (data.getParentAccountId() != null) { // verify that parent account exists if parentAccountId is not null final ImmutableAccountData immutableAccountData = immutableAccountInternalApi.getImmutableAccountDataById(data.getParentAccountId(), internalContext); if (immutableAccountData == null) { throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_ID, data.getParentAccountId()); } } final AccountModelDao account = new AccountModelDao(data); if (null != account.getExternalKey() && account.getExternalKey().length() > 255) { throw new AccountApiException(ErrorCode.EXTERNAL_KEY_LIMIT_EXCEEDED); } accountDao.create(account, internalCallContextFactory.createInternalCallContextWithoutAccountRecordId(context)); return new DefaultAccount(account); }
public AccountModelDao(final UUID id, @Nullable final DateTime createdDate, @Nullable final DateTime updatedDate, final AccountData account, final boolean withDefaults) { this(id, createdDate, updatedDate, account.getExternalKey(), account.getEmail(), account.getName(), account.getFirstNameLength(), account.getCurrency(), account.getParentAccountId(), account.isPaymentDelegatedToParent(), MoreObjects.firstNonNull(account.getBillCycleDayLocal(), DEFAULT_BILLING_CYCLE_DAY_LOCAL), account.getPaymentMethodId(), account.getReferenceTime() != null ? account.getReferenceTime() : createdDate, account.getTimeZone(), account.getLocale(), account.getAddress1(), account.getAddress2(), account.getCompanyName(), account.getCity(), account.getStateOrProvince(), account.getCountry(), account.getPostalCode(), account.getPhone(), account.getNotes(), account.isMigrated(), withDefaults); }
public DefaultMutableAccountData(final AccountData accountData) { this.externalKey = accountData.getExternalKey(); this.email = accountData.getEmail(); this.name = accountData.getName(); this.firstNameLength = accountData.getFirstNameLength(); this.currency = accountData.getCurrency(); this.parentAccountId = accountData.getParentAccountId(); this.isPaymentDelegatedToParent = accountData.isPaymentDelegatedToParent(); this.billCycleDayLocal = accountData.getBillCycleDayLocal() == null ? DEFAULT_BILLING_CYCLE_DAY_LOCAL : accountData.getBillCycleDayLocal(); this.paymentMethodId = accountData.getPaymentMethodId(); this.referenceTime = accountData.getReferenceTime(); this.timeZone = accountData.getTimeZone(); this.locale = accountData.getLocale(); this.address1 = accountData.getAddress1(); this.address2 = accountData.getAddress2(); this.companyName = accountData.getCompanyName(); this.city = accountData.getCity(); this.stateOrProvince = accountData.getStateOrProvince(); this.country = accountData.getCountry(); this.postalCode = accountData.getPostalCode(); this.phone = accountData.getPhone(); this.notes = accountData.getNotes(); this.isMigrated = accountData.isMigrated(); }
data.getFirstNameLength(), data.getCurrency(), data.getParentAccountId(), data.isPaymentDelegatedToParent(), data.getBillCycleDayLocal(),
this.country(data.getCountry()); this.currency(data.getCurrency()); this.parentAccountId(data.getParentAccountId()); this.isPaymentDelegatedToParent(data.isPaymentDelegatedToParent()); this.email(data.getEmail());
@Override public Account createAccount(final AccountData data, final CallContext context) throws AccountApiException { // Not transactional, but there is a db constraint on that column if (data.getExternalKey() != null && getIdFromKey(data.getExternalKey(), context) != null) { throw new AccountApiException(ErrorCode.ACCOUNT_ALREADY_EXISTS, data.getExternalKey()); } final InternalCallContext internalContext = internalCallContextFactory.createInternalCallContextWithoutAccountRecordId(context); if (data.getParentAccountId() != null) { // verify that parent account exists if parentAccountId is not null final ImmutableAccountData immutableAccountData = immutableAccountInternalApi.getImmutableAccountDataById(data.getParentAccountId(), internalContext); if (immutableAccountData == null) { throw new AccountApiException(ErrorCode.ACCOUNT_DOES_NOT_EXIST_FOR_ID, data.getParentAccountId()); } } final AccountModelDao account = new AccountModelDao(data); if (null != account.getExternalKey() && account.getExternalKey().length() > 255) { throw new AccountApiException(ErrorCode.EXTERNAL_KEY_LIMIT_EXCEEDED); } accountDao.create(account, internalCallContextFactory.createInternalCallContextWithoutAccountRecordId(context)); return new DefaultAccount(account); }
public AccountModelDao(final UUID id, @Nullable final DateTime createdDate, @Nullable final DateTime updatedDate, final AccountData account, final boolean withDefaults) { this(id, createdDate, updatedDate, account.getExternalKey(), account.getEmail(), account.getName(), account.getFirstNameLength(), account.getCurrency(), account.getParentAccountId(), account.isPaymentDelegatedToParent(), MoreObjects.firstNonNull(account.getBillCycleDayLocal(), DEFAULT_BILLING_CYCLE_DAY_LOCAL), account.getPaymentMethodId(), account.getReferenceTime() != null ? account.getReferenceTime() : createdDate, account.getTimeZone(), account.getLocale(), account.getAddress1(), account.getAddress2(), account.getCompanyName(), account.getCity(), account.getStateOrProvince(), account.getCountry(), account.getPostalCode(), account.getPhone(), account.getNotes(), account.isMigrated(), withDefaults); }
public DefaultMutableAccountData(final AccountData accountData) { this.externalKey = accountData.getExternalKey(); this.email = accountData.getEmail(); this.name = accountData.getName(); this.firstNameLength = accountData.getFirstNameLength(); this.currency = accountData.getCurrency(); this.parentAccountId = accountData.getParentAccountId(); this.isPaymentDelegatedToParent = accountData.isPaymentDelegatedToParent(); this.billCycleDayLocal = accountData.getBillCycleDayLocal() == null ? DEFAULT_BILLING_CYCLE_DAY_LOCAL : accountData.getBillCycleDayLocal(); this.paymentMethodId = accountData.getPaymentMethodId(); this.referenceTime = accountData.getReferenceTime(); this.timeZone = accountData.getTimeZone(); this.locale = accountData.getLocale(); this.address1 = accountData.getAddress1(); this.address2 = accountData.getAddress2(); this.companyName = accountData.getCompanyName(); this.city = accountData.getCity(); this.stateOrProvince = accountData.getStateOrProvince(); this.country = accountData.getCountry(); this.postalCode = accountData.getPostalCode(); this.phone = accountData.getPhone(); this.notes = accountData.getNotes(); this.isMigrated = accountData.isMigrated(); }
data.getFirstNameLength(), data.getCurrency(), data.getParentAccountId(), data.isPaymentDelegatedToParent(), data.getBillCycleDayLocal(),
this.country(data.getCountry()); this.currency(data.getCurrency()); this.parentAccountId(data.getParentAccountId()); this.isPaymentDelegatedToParent(data.isPaymentDelegatedToParent()); this.email(data.getEmail());