Renamed id to technicalId and extracted createDefaultId() so that technicalId easier overridable in sub classes

This commit is contained in:
dankito 2020-07-20 17:19:19 +02:00
parent 0e194faee7
commit 37d471781f
4 changed files with 15 additions and 8 deletions

View File

@ -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<IndexableField?> {
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<BankAccount>) {
val writer = getWriter()
val bankAccountIds = bankAccounts.map { it.id }
val bankAccountIds = bankAccounts.map { it.technicalId }
writer.deleteDocumentsAndFlushChangesToDisk(BankAccountIdFieldName, *bankAccountIds.toTypedArray())
}

View File

@ -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

View File

@ -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

View File

@ -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<TanProcedure> = listOf()