Skip to content

Commit

Permalink
jaxrs: Change all models and api to use UUID instaed of string for Ki…
Browse files Browse the repository at this point in the history
…ll Bill ids 😅
  • Loading branch information
sbrossie committed Mar 10, 2018
1 parent c76bcaf commit d9565d5
Show file tree
Hide file tree
Showing 60 changed files with 645 additions and 736 deletions.
Expand Up @@ -30,18 +30,17 @@
@ApiModel(value="AccountEmail")
public class AccountEmailJson extends JsonBase {

@ApiModelProperty(dataType = "java.util.UUID")
private final String accountId;
private final UUID accountId;
@ApiModelProperty(required = true)
private final String email;

@JsonCreator
public AccountEmailJson(@JsonProperty("accountId") final String accountId, @JsonProperty("email") final String email) {
public AccountEmailJson(@JsonProperty("accountId") final UUID accountId, @JsonProperty("email") final String email) {
this.accountId = accountId;
this.email = email;
}

public String getAccountId() {
public UUID getAccountId() {
return accountId;
}

Expand All @@ -54,7 +53,7 @@ public AccountEmail toAccountEmail(final UUID accountEmailId) {
return new AccountEmail() {
@Override
public UUID getAccountId() {
return UUID.fromString(accountId);
return accountId;
}

@Override
Expand Down
Expand Up @@ -41,8 +41,7 @@
@ApiModel(value="Account")
public class AccountJson extends JsonBase {

@ApiModelProperty(dataType = "java.util.UUID")
private final String accountId;
private final UUID accountId;
private final String externalKey;
private final BigDecimal accountCBA;
private final BigDecimal accountBalance;
Expand All @@ -51,11 +50,9 @@ public class AccountJson extends JsonBase {
private final String email;
private final Integer billCycleDayLocal;
private final String currency;
@ApiModelProperty(dataType = "java.util.UUID")
private final String parentAccountId;
private final UUID parentAccountId;
private final Boolean isPaymentDelegatedToParent;
@ApiModelProperty(dataType = "java.util.UUID")
private final String paymentMethodId;
private final UUID paymentMethodId;
private final DateTime referenceTime;
private final String timeZone;
private final String address1;
Expand All @@ -75,16 +72,16 @@ public AccountJson(final Account account, final BigDecimal accountBalance, final
super(toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForAccount()));
this.accountCBA = accountCBA;
this.accountBalance = accountBalance;
this.accountId = account.getId().toString();
this.accountId = account.getId();
this.externalKey = account.getExternalKey();
this.name = account.getName();
this.firstNameLength = account.getFirstNameLength();
this.email = account.getEmail();
this.billCycleDayLocal = account.getBillCycleDayLocal();
this.currency = account.getCurrency() != null ? account.getCurrency().toString() : null;
this.parentAccountId = account.getParentAccountId() != null ? account.getParentAccountId().toString() : null;
this.parentAccountId = account.getParentAccountId();
this.isPaymentDelegatedToParent = account.isPaymentDelegatedToParent();
this.paymentMethodId = account.getPaymentMethodId() != null ? account.getPaymentMethodId().toString() : null;
this.paymentMethodId = account.getPaymentMethodId();
this.referenceTime = account.getReferenceTime();
this.timeZone = account.getTimeZone() != null ? account.getTimeZone().toString() : null;
this.address1 = account.getAddress1();
Expand All @@ -102,16 +99,16 @@ public AccountJson(final Account account, final BigDecimal accountBalance, final
}

@JsonCreator
public AccountJson(@JsonProperty("accountId") final String accountId,
public AccountJson(@JsonProperty("accountId") final UUID accountId,
@JsonProperty("name") final String name,
@JsonProperty("firstNameLength") final Integer firstNameLength,
@JsonProperty("externalKey") final String externalKey,
@JsonProperty("email") final String email,
@JsonProperty("billCycleDayLocal") final Integer billCycleDayLocal,
@JsonProperty("currency") final String currency,
@JsonProperty("parentAccountId") final String parentAccountId,
@JsonProperty("parentAccountId") final UUID parentAccountId,
@JsonProperty("isPaymentDelegatedToParent") final Boolean isPaymentDelegatedToParent,
@JsonProperty("paymentMethodId") final String paymentMethodId,
@JsonProperty("paymentMethodId") final UUID paymentMethodId,
@JsonProperty("referenceTime") final DateTime referenceTime,
@JsonProperty("timeZone") final String timeZone,
@JsonProperty("address1") final String address1,
Expand Down Expand Up @@ -207,11 +204,7 @@ public Boolean isNotifiedForInvoices() {

@Override
public UUID getPaymentMethodId() {
if (Strings.emptyToNull(paymentMethodId) == null) {
return null;
} else {
return UUID.fromString(paymentMethodId);
}
return paymentMethodId;
}

@Override
Expand Down Expand Up @@ -281,11 +274,7 @@ public String getAddress1() {

@Override
public UUID getParentAccountId() {
if (Strings.emptyToNull(parentAccountId) == null) {
return null;
} else {
return UUID.fromString(parentAccountId);
}
return parentAccountId;
}

@Override
Expand Down Expand Up @@ -332,7 +321,7 @@ public BigDecimal getAccountBalance() {
return accountBalance;
}

public String getAccountId() {
public UUID getAccountId() {
return accountId;
}

Expand Down Expand Up @@ -364,7 +353,7 @@ public String getCurrency() {
return currency;
}

public String getParentAccountId() {
public UUID getParentAccountId() {
return parentAccountId;
}

Expand All @@ -373,7 +362,7 @@ public Boolean isPaymentDelegatedToParent() {
return isPaymentDelegatedToParent;
}

public String getPaymentMethodId() {
public UUID getPaymentMethodId() {
return paymentMethodId;
}

Expand Down
Expand Up @@ -36,8 +36,7 @@
@ApiModel(value="BlockingState")
public class BlockingStateJson extends JsonBase {

@ApiModelProperty(dataType = "java.util.UUID")
private final String blockedId;
private final UUID blockedId;
private final String stateName;
private final String service;
private final Boolean blockChange;
Expand All @@ -47,7 +46,7 @@ public class BlockingStateJson extends JsonBase {
private final BlockingStateType type;

@JsonCreator
public BlockingStateJson(@JsonProperty("blockedId") final String blockedId,
public BlockingStateJson(@JsonProperty("blockedId") final UUID blockedId,
@JsonProperty("stateName") final String stateName,
@JsonProperty("service") final String service,
@JsonProperty("blockChange") final Boolean blockChange,
Expand All @@ -68,7 +67,7 @@ public BlockingStateJson(@JsonProperty("blockedId") final String blockedId,
}

public BlockingStateJson(final BlockingState input, final AccountAuditLogs accountAuditLogs) {
this(input.getBlockedId().toString(),
this(input.getBlockedId(),
input.getStateName(),
input.getService(),
input.isBlockChange(),
Expand All @@ -80,7 +79,7 @@ public BlockingStateJson(final BlockingState input, final AccountAuditLogs accou
}


public String getBlockedId() {
public UUID getBlockedId() {
return blockedId;
}

Expand Down
20 changes: 10 additions & 10 deletions jaxrs/src/main/java/org/killbill/billing/jaxrs/json/BundleJson.java
Expand Up @@ -20,6 +20,7 @@

import java.util.LinkedList;
import java.util.List;
import java.util.UUID;

import javax.annotation.Nullable;

Expand All @@ -37,17 +38,16 @@
@ApiModel(value="Bundle")
public class BundleJson extends JsonBase {

@ApiModelProperty(dataType = "java.util.UUID", required = true)
private final String accountId;
@ApiModelProperty(dataType = "java.util.UUID")
private final String bundleId;
@ApiModelProperty(required = true)
private final UUID accountId;
private final UUID bundleId;
private final String externalKey;
private final List<SubscriptionJson> subscriptions;
private final BundleTimelineJson timeline;

@JsonCreator
public BundleJson(@JsonProperty("accountId") @Nullable final String accountId,
@JsonProperty("bundleId") @Nullable final String bundleId,
public BundleJson(@JsonProperty("accountId") @Nullable final UUID accountId,
@JsonProperty("bundleId") @Nullable final UUID bundleId,
@JsonProperty("externalKey") @Nullable final String externalKey,
@JsonProperty("subscriptions") @Nullable final List<SubscriptionJson> subscriptions,
@JsonProperty("timeline") @Nullable final BundleTimelineJson timeline,
Expand All @@ -62,8 +62,8 @@ public BundleJson(@JsonProperty("accountId") @Nullable final String accountId,

public BundleJson(final SubscriptionBundle bundle, @Nullable final Currency currency, @Nullable final AccountAuditLogs accountAuditLogs) throws CatalogApiException {
super(toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForBundle(bundle.getId())));
this.accountId = bundle.getAccountId().toString();
this.bundleId = bundle.getId().toString();
this.accountId = bundle.getAccountId();
this.bundleId = bundle.getId();
this.externalKey = bundle.getExternalKey();
this.subscriptions = new LinkedList<SubscriptionJson>();
for (final Subscription subscription : bundle.getSubscriptions()) {
Expand All @@ -78,11 +78,11 @@ public List<SubscriptionJson> getSubscriptions() {
return subscriptions;
}

public String getAccountId() {
public UUID getAccountId() {
return accountId;
}

public String getBundleId() {
public UUID getBundleId() {
return bundleId;
}

Expand Down
Expand Up @@ -18,6 +18,7 @@

import java.util.LinkedList;
import java.util.List;
import java.util.UUID;

import javax.annotation.Nullable;

Expand All @@ -34,16 +35,14 @@
@ApiModel(value="BundleTimeline")
public class BundleTimelineJson extends JsonBase {

@ApiModelProperty(dataType = "java.util.UUID")
private final String accountId;
@ApiModelProperty(dataType = "java.util.UUID")
private final String bundleId;
private final UUID accountId;
private final UUID bundleId;
private final String externalKey;
private final List<EventSubscriptionJson> events;

@JsonCreator
public BundleTimelineJson(@JsonProperty("accountId") @Nullable final String accountId,
@JsonProperty("bundleId") @Nullable final String bundleId,
public BundleTimelineJson(@JsonProperty("accountId") @Nullable final UUID accountId,
@JsonProperty("bundleId") @Nullable final UUID bundleId,
@JsonProperty("externalKey") @Nullable final String externalKey,
@JsonProperty("events") @Nullable final List<EventSubscriptionJson> events,
@JsonProperty("auditLogs") @Nullable final List<AuditLogJson> auditLogs) {
Expand All @@ -56,8 +55,8 @@ public BundleTimelineJson(@JsonProperty("accountId") @Nullable final String acco

public BundleTimelineJson(final SubscriptionBundleTimeline bundleTimeline, @Nullable final AccountAuditLogs accountAuditLogs) {
super(toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForBundle(bundleTimeline.getBundleId())));
this.accountId = bundleTimeline.getAccountId().toString();
this.bundleId = bundleTimeline.getBundleId().toString();
this.accountId = bundleTimeline.getAccountId();
this.bundleId = bundleTimeline.getBundleId();
this.externalKey = bundleTimeline.getExternalKey();

this.events = new LinkedList<EventSubscriptionJson>();
Expand All @@ -66,11 +65,11 @@ public BundleTimelineJson(final SubscriptionBundleTimeline bundleTimeline, @Null
}
}

public String getAccountId() {
public UUID getAccountId() {
return accountId;
}

public String getBundleId() {
public UUID getBundleId() {
return bundleId;
}

Expand Down
20 changes: 10 additions & 10 deletions jaxrs/src/main/java/org/killbill/billing/jaxrs/json/CreditJson.java
Expand Up @@ -18,6 +18,7 @@

import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;

import javax.annotation.Nullable;

Expand All @@ -37,23 +38,22 @@ public class CreditJson extends JsonBase {

@ApiModelProperty(required = true)
private final BigDecimal creditAmount;
@ApiModelProperty(dataType = "java.util.UUID")
private final String invoiceId;
private final UUID invoiceId;
private final String invoiceNumber;
private final LocalDate effectiveDate;
@ApiModelProperty(dataType = "java.util.UUID", required = true)
private final String accountId;
@ApiModelProperty(required = true)
private final UUID accountId;
private final String description;
private final String currency;


@JsonCreator
public CreditJson(@JsonProperty("creditAmount") final BigDecimal creditAmount,
@JsonProperty("currency") final String currency,
@JsonProperty("invoiceId") final String invoiceId,
@JsonProperty("invoiceId") final UUID invoiceId,
@JsonProperty("invoiceNumber") final String invoiceNumber,
@JsonProperty("effectiveDate") final LocalDate effectiveDate,
@JsonProperty("accountId") final String accountId,
@JsonProperty("accountId") final UUID accountId,
@JsonProperty("description") final String description,
@JsonProperty("auditLogs") @Nullable final List<AuditLogJson> auditLogs) {
super(auditLogs);
Expand All @@ -68,10 +68,10 @@ public CreditJson(@JsonProperty("creditAmount") final BigDecimal creditAmount,

public CreditJson(final Invoice invoice, final InvoiceItem credit, final List<AuditLog> auditLogs) {
super(toAuditLogJson(auditLogs));
this.accountId = toString(credit.getAccountId());
this.accountId = credit.getAccountId();
this.creditAmount = credit.getAmount();
this.currency = credit.getCurrency().name();
this.invoiceId = toString(credit.getInvoiceId());
this.invoiceId = credit.getInvoiceId();
this.invoiceNumber = invoice.getInvoiceNumber().toString();
this.effectiveDate = credit.getStartDate();
this.description = credit.getDescription();
Expand All @@ -85,7 +85,7 @@ public BigDecimal getCreditAmount() {
return creditAmount;
}

public String getInvoiceId() {
public UUID getInvoiceId() {
return invoiceId;
}

Expand All @@ -97,7 +97,7 @@ public LocalDate getEffectiveDate() {
return effectiveDate;
}

public String getAccountId() {
public UUID getAccountId() {
return accountId;
}

Expand Down

0 comments on commit d9565d5

Please sign in to comment.