From 73a542eccaceadf836ed3b3380883ab2c8bc102b Mon Sep 17 00:00:00 2001 From: Kristijan Mitrovic Date: Mon, 13 Apr 2020 16:07:27 +0200 Subject: [PATCH] Add DAO for new entity class and move anonymize method there --- .../dao/bill/AccountPaymentArchivedDAO.java | 37 +++++++++++++++++++ .../model/bill/AccountPaymentArchived.java | 10 ----- 2 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 bubble-server/src/main/java/bubble/dao/bill/AccountPaymentArchivedDAO.java diff --git a/bubble-server/src/main/java/bubble/dao/bill/AccountPaymentArchivedDAO.java b/bubble-server/src/main/java/bubble/dao/bill/AccountPaymentArchivedDAO.java new file mode 100644 index 00000000..43eb0052 --- /dev/null +++ b/bubble-server/src/main/java/bubble/dao/bill/AccountPaymentArchivedDAO.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2020 Bubble, Inc. All rights reserved. + * For personal (non-commercial) use, see license: https://bubblev.com/bubble-license/ + */ +package bubble.dao.bill; + +import bubble.model.bill.AccountPaymentArchived; +import lombok.NonNull; +import org.cobbzilla.wizard.dao.AbstractCRUDDAO; +import org.cobbzilla.wizard.dao.SqlViewSearchableDAO; +import org.hibernate.criterion.Order; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public class AccountPaymentArchivedDAO + extends AbstractCRUDDAO + implements SqlViewSearchableDAO { + + // newest first + @Override public Order getDefaultSortOrder() { return ORDER_CTIME_DESC; } + + @NonNull public List findByAccountName(@NonNull final String accountName) { + return findByField("accountName", accountName); + } + + /** + * Anonymize this object. This is needed when client requires and signs/waives his/her right to sue in the future. + */ + public void anonymizeForAccountName(@NonNull final String accountName) { + // TODO: what about paymentMethodMaskedInfo, bubblePlanName and billPeriodStart. Do those fields contain any + // user info and names set up by the user? + bulkUpdate(new String[] { "accountName", "accountPlanName" }, new String[] { "anonymous", "anonymized" }, + new String[] { "accountName" }, new String[] { accountName }); + } +} diff --git a/bubble-server/src/main/java/bubble/model/bill/AccountPaymentArchived.java b/bubble-server/src/main/java/bubble/model/bill/AccountPaymentArchived.java index edccbbed..34937418 100644 --- a/bubble-server/src/main/java/bubble/model/bill/AccountPaymentArchived.java +++ b/bubble-server/src/main/java/bubble/model/bill/AccountPaymentArchived.java @@ -106,14 +106,4 @@ public class AccountPaymentArchived extends IdentifiableBase { @ECSearchable @ECField(index=120, type=EntityFieldType.error) @Type(type=ENCRYPTED_STRING) @Column(updatable=false, columnDefinition="varchar(" + (10_000 + ENC_PAD) + ")") @JsonIgnore @Getter @Setter private String exception; - - /** - * Anonymize this object. This is needed when client requires and signs/waives his/her right to sue in the future. - */ - public AccountPaymentArchived anonymize() { - // TODO: what about paymentMethodMaskedInfo, bubblePlanName and billPeriodStart. Do those fields contain any - // user info and names set up by the user? - return this.setAccountName("anonymous") - .setAccountPlanName("anonymized"); - } }