Browse Source

Store archived payment info on account deletion

tags/v0.10.5
Kristijan Mitrovic 4 years ago
parent
commit
dd70fb2406
3 changed files with 17 additions and 11 deletions
  1. +4
    -0
      bubble-server/src/main/java/bubble/dao/account/AccountDAO.java
  2. +11
    -0
      bubble-server/src/main/java/bubble/dao/bill/AccountPaymentArchivedDAO.java
  3. +2
    -11
      bubble-server/src/main/java/bubble/model/bill/AccountPaymentArchived.java

+ 4
- 0
bubble-server/src/main/java/bubble/dao/account/AccountDAO.java View File

@@ -8,6 +8,7 @@ import bubble.cloud.CloudServiceDriver;
import bubble.cloud.compute.ComputeNodeSizeType; import bubble.cloud.compute.ComputeNodeSizeType;
import bubble.dao.account.message.AccountMessageDAO; import bubble.dao.account.message.AccountMessageDAO;
import bubble.dao.app.*; import bubble.dao.app.*;
import bubble.dao.bill.AccountPaymentArchivedDAO;
import bubble.dao.bill.BillDAO; import bubble.dao.bill.BillDAO;
import bubble.dao.cloud.AnsibleRoleDAO; import bubble.dao.cloud.AnsibleRoleDAO;
import bubble.dao.cloud.BubbleDomainDAO; import bubble.dao.cloud.BubbleDomainDAO;
@@ -349,6 +350,9 @@ public class AccountDAO extends AbstractCRUDDAO<Account> implements SqlViewSearc
// stash the deletion policy for later use, the policy object will be deleted in deleteDependencies // stash the deletion policy for later use, the policy object will be deleted in deleteDependencies
final var deletionPolicy = policyDAO.findSingleByAccount(uuid).getDeletionPolicy(); final var deletionPolicy = policyDAO.findSingleByAccount(uuid).getDeletionPolicy();


// archive all payment data for the account
configuration.getBean(AccountPaymentArchivedDAO.class).createForAccount(uuid);

log.info("delete: starting to delete account-dependent objects - " + currentThread().getName()); log.info("delete: starting to delete account-dependent objects - " + currentThread().getName());
configuration.deleteDependencies(account); configuration.deleteDependencies(account);
log.info("delete: finished deleting account-dependent objects - " + currentThread().getName()); log.info("delete: finished deleting account-dependent objects - " + currentThread().getName());


+ 11
- 0
bubble-server/src/main/java/bubble/dao/bill/AccountPaymentArchivedDAO.java View File

@@ -22,4 +22,15 @@ public class AccountPaymentArchivedDAO
public AccountPaymentArchived findByAccountUuid(@NonNull final String accountUuid) { public AccountPaymentArchived findByAccountUuid(@NonNull final String accountUuid) {
return findByUniqueField("accountUuid", accountUuid); return findByUniqueField("accountUuid", accountUuid);
} }

@NonNull public AccountPaymentArchived createForAccount(@NonNull final String accountUuid) {
final var allBills = getConfiguration().getBean(BillDAO.class).findByAccount(accountUuid);
final var allPayments = getConfiguration().getBean(AccountPaymentDAO.class).findByAccount(accountUuid);
final var allMethods = getConfiguration().getBean(AccountPaymentMethodDAO.class).findByAccount(accountUuid);

return create(new AccountPaymentArchived().setAccountUuid(accountUuid)
.setBills(allBills)
.setPayments(allPayments)
.setPaymentMethods(allMethods));
}
} }

+ 2
- 11
bubble-server/src/main/java/bubble/model/bill/AccountPaymentArchived.java View File

@@ -6,7 +6,7 @@ package bubble.model.bill;


import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter; import lombok.Getter;
import lombok.NonNull;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.cobbzilla.wizard.model.IdentifiableBase; import org.cobbzilla.wizard.model.IdentifiableBase;
@@ -25,18 +25,9 @@ import static org.cobbzilla.wizard.model.crypto.EncryptedTypes.ENCRYPTED_STRING;


@ECType(root=true) @ECTypeCreate(method="DISABLED") @ECType(root=true) @ECTypeCreate(method="DISABLED")
@ECTypeURIs(listFields={"accountName", "paymentMethodMaskedInfo", "amount"}) @ECTypeURIs(listFields={"accountName", "paymentMethodMaskedInfo", "amount"})
@Entity @Accessors(chain=true)
@Entity @Accessors(chain=true) @NoArgsConstructor
public class AccountPaymentArchived extends IdentifiableBase { public class AccountPaymentArchived extends IdentifiableBase {


public AccountPaymentArchived(@NonNull final String accountUuid, @NonNull final List<Bill> bills,
@NonNull final List<AccountPayment> payments,
@NonNull final List<AccountPaymentMethod> paymentMethods) {
this.setAccountUuid(accountUuid)
.setBills(bills)
.setPayments(payments)
.setPaymentMethods(paymentMethods);
}

@ECSearchable @ECField(index=10, type=EntityFieldType.opaque_string) @ECSearchable @ECField(index=10, type=EntityFieldType.opaque_string)
@ECIndex(unique=true) @Column(updatable=false, length=UUID_MAXLEN) @ECIndex(unique=true) @Column(updatable=false, length=UUID_MAXLEN)
@Getter @Setter private String accountUuid; @Getter @Setter private String accountUuid;


Loading…
Cancel
Save