From 37d471781f2351afd37616401aa64cbb1ce0b9ef Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 20 Jul 2020 17:19:19 +0200 Subject: [PATCH] Renamed id to technicalId and extracted createDefaultId() so that technicalId easier overridable in sub classes --- .../banking/persistence/LuceneBankingPersistence.kt | 6 +++--- .../net/dankito/banking/ui/model/AccountTransaction.kt | 8 ++++++-- .../kotlin/net/dankito/banking/ui/model/BankAccount.kt | 5 ++++- .../kotlin/net/dankito/banking/ui/model/Customer.kt | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/persistence/LuceneBankingPersistence/src/main/kotlin/net/dankito/banking/persistence/LuceneBankingPersistence.kt b/persistence/LuceneBankingPersistence/src/main/kotlin/net/dankito/banking/persistence/LuceneBankingPersistence.kt index 2a873d71..d45a211f 100644 --- a/persistence/LuceneBankingPersistence/src/main/kotlin/net/dankito/banking/persistence/LuceneBankingPersistence.kt +++ b/persistence/LuceneBankingPersistence/src/main/kotlin/net/dankito/banking/persistence/LuceneBankingPersistence.kt @@ -52,7 +52,7 @@ open class LuceneBankingPersistence( transactions.forEach { transaction -> writer.updateDocumentForNonNullFields( - IdFieldName, transaction.id, + IdFieldName, transaction.technicalId, *createFieldsForAccountTransaction(bankAccount, transaction).toTypedArray() ) } @@ -62,7 +62,7 @@ open class LuceneBankingPersistence( protected open fun createFieldsForAccountTransaction(bankAccount: BankAccount, transaction: AccountTransaction): List { return listOf( - fields.keywordField(BankAccountIdFieldName, bankAccount.id), + fields.keywordField(BankAccountIdFieldName, bankAccount.technicalId), fields.nullableFullTextSearchField(OtherPartyNameFieldName, transaction.otherPartyName, true), fields.fullTextSearchField(UsageFieldName, transaction.usage, true), fields.nullableFullTextSearchField(BookingTextFieldName, transaction.bookingText, true), @@ -92,7 +92,7 @@ open class LuceneBankingPersistence( protected open fun deleteAccountTransactions(bankAccounts: List) { val writer = getWriter() - val bankAccountIds = bankAccounts.map { it.id } + val bankAccountIds = bankAccounts.map { it.technicalId } writer.deleteDocumentsAndFlushChangesToDisk(BankAccountIdFieldName, *bankAccountIds.toTypedArray()) } diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt index 9182dac1..ddc5dd89 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/AccountTransaction.kt @@ -8,7 +8,7 @@ import net.dankito.utils.multiplatform.DateFormatStyle import net.dankito.utils.multiplatform.DateFormatter -//@JsonIdentityInfo(property = "id", generator = ObjectIdGenerators.PropertyGenerator::class) // to avoid stack overflow due to circular references +//@JsonIdentityInfo(property = "technicalId", generator = ObjectIdGenerators.PropertyGenerator::class) // to avoid stack overflow due to circular references open class AccountTransaction( open val bankAccount: BankAccount, open val amount: BigDecimal, @@ -72,11 +72,15 @@ open class AccountTransaction( 0, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, "", "", null, null, "", null) + open val technicalId: String = createDefaultId() + + protected fun createDefaultId() = + "${bankAccount.technicalId} ${IdDateFormat.format(bookingDate)} ${IdDateFormat.format(valueDate)} $amount $currency $unparsedUsage $otherPartyName $otherPartyBankCode $otherPartyAccountId" - open var id: String = "${bankAccount.id} ${IdDateFormat.format(bookingDate)} ${IdDateFormat.format(valueDate)} $amount $currency $unparsedUsage $otherPartyName $otherPartyBankCode $otherPartyAccountId" open val showOtherPartyName: Boolean get() = otherPartyName.isNullOrBlank() == false /* && type != "ENTGELTABSCHLUSS" && type != "AUSZAHLUNG" */ // TODO + open val usage: String get() = sepaUsage ?: unparsedUsage diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccount.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccount.kt index 7034c8d4..c2551c03 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccount.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/BankAccount.kt @@ -1,11 +1,14 @@ package net.dankito.banking.ui.model +//import com.fasterxml.jackson.annotation.JsonIdentityInfo +//import com.fasterxml.jackson.annotation.ObjectIdGenerators import net.dankito.utils.multiplatform.BigDecimal import net.dankito.utils.multiplatform.Date import net.dankito.utils.multiplatform.UUID import kotlin.jvm.JvmOverloads +//@JsonIdentityInfo(property = "technicalId", generator = ObjectIdGenerators.PropertyGenerator::class) // to avoid stack overflow due to circular references open class BankAccount @JvmOverloads constructor( open val customer: Customer, open val identifier: String, @@ -37,7 +40,7 @@ open class BankAccount @JvmOverloads constructor( : this(customer, identifier, "", null, null, "", balance, "EUR", type, productName) - open var id: String = UUID.random() + open var technicalId: String = UUID.random() open val displayName: String diff --git a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/Customer.kt b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/Customer.kt index e92845ce..911f25b6 100644 --- a/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/Customer.kt +++ b/ui/BankingUiCommon/src/commonMain/kotlin/net/dankito/banking/ui/model/Customer.kt @@ -10,7 +10,7 @@ import net.dankito.banking.ui.model.tan.TanProcedure import net.dankito.utils.multiplatform.UUID -//@JsonIdentityInfo(property = "id", generator = ObjectIdGenerators.PropertyGenerator::class) // to avoid stack overflow due to circular references +//@JsonIdentityInfo(property = "technicalId", generator = ObjectIdGenerators.PropertyGenerator::class) // to avoid stack overflow due to circular references open class Customer( open val bankCode: String, open val customerId: String, @@ -33,7 +33,7 @@ open class Customer( : this(bankCode, customerId, password, finTsServerAddress, "", "", "") - open var id: String = UUID.random() + open var technicalId: String = UUID.random() open var supportedTanProcedures: List = listOf()