Updated to new data model that their is now BankAccess.clientData and serializedClientData

This commit is contained in:
dankito 2024-10-15 19:48:56 +02:00
parent f547b76c7b
commit 1c7fa49de5
5 changed files with 12 additions and 10 deletions

View File

@ -31,7 +31,7 @@ interface BankingRepository {
suspend fun updateBank(bank: BankAccessEntity, loginName: String, password: String, bankName: String?) suspend fun updateBank(bank: BankAccessEntity, loginName: String, password: String, bankName: String?)
suspend fun updateBank(bank: BankAccessEntity, clientData: String?) suspend fun updateBank(bank: BankAccessEntity, serializedClientData: String?)
suspend fun updateAccount(account: BankAccountEntity, userSetDisplayName: String?, hideAccount: Boolean, includeInAutomaticAccountsUpdate: Boolean) suspend fun updateAccount(account: BankAccountEntity, userSetDisplayName: String?, hideAccount: Boolean, includeInAutomaticAccountsUpdate: Boolean)

View File

@ -55,7 +55,7 @@ class InMemoryBankingRepository(
// no-op // no-op
} }
override suspend fun updateBank(bank: BankAccessEntity, clientData: String?) { override suspend fun updateBank(bank: BankAccessEntity, serializedClientData: String?) {
// no-op // no-op
} }

View File

@ -95,9 +95,9 @@ open class SqliteBankingRepository : BankingRepository {
val tanMedia = getAllTanMedia().groupBy { it.bankId }.mapValues { it.value.toMutableList() } val tanMedia = getAllTanMedia().groupBy { it.bankId }.mapValues { it.value.toMutableList() }
val holdings = getAllHoldings().groupBy { it.accountId } val holdings = getAllHoldings().groupBy { it.accountId }
return bankQueries.getAllBanks { id, domesticBankCode, loginName, password, bankName, bic, customerName, userId, selectedTanMethodIdentifier, selectedTanMediumIdentifier, bankingGroup, serverAddress, countryCode, clientData, userSetDisplayName, displayIndex, iconUrl, wrongCredentialsEntered -> return bankQueries.getAllBanks { id, domesticBankCode, loginName, password, bankName, bic, customerName, userId, selectedTanMethodIdentifier, selectedTanMediumIdentifier, bankingGroup, serverAddress, countryCode, serializedClientData, userSetDisplayName, displayIndex, iconUrl, wrongCredentialsEntered ->
BankAccessEntity(id, domesticBankCode, loginName, password, bankName, bic, customerName, userId, getAccountsOfBank(id, bankAccounts, holdings), selectedTanMethodIdentifier, tanMethods[id] ?: mutableListOf(), selectedTanMediumIdentifier, tanMedia[id] ?: mutableListOf(), BankAccessEntity(id, domesticBankCode, loginName, password, bankName, bic, customerName, userId, getAccountsOfBank(id, bankAccounts, holdings), selectedTanMethodIdentifier, tanMethods[id] ?: mutableListOf(), selectedTanMediumIdentifier, tanMedia[id] ?: mutableListOf(),
bankingGroup?.let { BankingGroup.valueOf(it) }, serverAddress, countryCode, userSetDisplayName, displayIndex.toInt(), iconUrl, wrongCredentialsEntered, clientData) bankingGroup?.let { BankingGroup.valueOf(it) }, serverAddress, countryCode, userSetDisplayName, displayIndex.toInt(), iconUrl, wrongCredentialsEntered, null, serializedClientData)
}.executeAsList() }.executeAsList()
} }
@ -111,7 +111,7 @@ open class SqliteBankingRepository : BankingRepository {
return bankQueries.transactionWithResult { return bankQueries.transactionWithResult {
bankQueries.insertBank(bank.domesticBankCode, bank.loginName, bank.password, bank.bankName, bank.bic, bankQueries.insertBank(bank.domesticBankCode, bank.loginName, bank.password, bank.bankName, bank.bic,
bank.customerName, bank.userId, bank.selectedTanMethodIdentifier, bank.selectedTanMediumIdentifier, bank.customerName, bank.userId, bank.selectedTanMethodIdentifier, bank.selectedTanMediumIdentifier,
bank.bankingGroup?.name, bank.serverAddress, bank.countryCode, bank.clientData, bank.userSetDisplayName, bank.displayIndex.toLong(), bank.iconUrl, bank.wrongCredentialsEntered bank.bankingGroup?.name, bank.serverAddress, bank.countryCode, bank.serializedClientData, bank.userSetDisplayName, bank.displayIndex.toLong(), bank.iconUrl, bank.wrongCredentialsEntered
) )
val bankId = getLastInsertedId() // getLastInsertedId() / last_insert_rowid() has to be called in a transaction with the insert operation, otherwise it will not work val bankId = getLastInsertedId() // getLastInsertedId() / last_insert_rowid() has to be called in a transaction with the insert operation, otherwise it will not work
@ -141,10 +141,10 @@ open class SqliteBankingRepository : BankingRepository {
} }
} }
override suspend fun updateBank(bank: BankAccessEntity, clientData: String?) { override suspend fun updateBank(bank: BankAccessEntity, serializedClientData: String?) {
bankQueries.transaction { bankQueries.transaction {
if (clientData != null) { if (serializedClientData != null) {
bankQueries.updateBankClientData(clientData, bank.id) bankQueries.updateBankClientData(serializedClientData, bank.id)
} }
} }
} }

View File

@ -34,7 +34,8 @@ class BankAccessEntity(
iconUrl: String? = null, iconUrl: String? = null,
wrongCredentialsEntered: Boolean = false, wrongCredentialsEntered: Boolean = false,
clientData: String? = null clientData: Any? = null,
serializedClientData: String? = null
) : BankAccess(domesticBankCode, loginName, password, bankName, bic, customerName, userId, accounts, selectedTanMethodIdentifier, tanMethods, selectedTanMediumIdentifier, tanMedia, bankingGroup, serverAddress, countryCode) { ) : BankAccess(domesticBankCode, loginName, password, bankName, bic, customerName, userId, accounts, selectedTanMethodIdentifier, tanMethods, selectedTanMediumIdentifier, tanMedia, bankingGroup, serverAddress, countryCode) {
init { init {
@ -45,6 +46,7 @@ class BankAccessEntity(
this.wrongCredentialsEntered = wrongCredentialsEntered this.wrongCredentialsEntered = wrongCredentialsEntered
this.clientData = clientData this.clientData = clientData
this.serializedClientData = serializedClientData
} }

View File

@ -291,7 +291,7 @@ class BankingService(
bankingRepository.updateAccount(account, response.balance ?: account.balance, response.transactionsRetrievalTime, response.retrievedTransactionsFrom ?: account.retrievedTransactionsFrom) bankingRepository.updateAccount(account, response.balance ?: account.balance, response.transactionsRetrievalTime, response.retrievedTransactionsFrom ?: account.retrievedTransactionsFrom)
} }
bankingRepository.updateBank(bank, bank.clientData) bankingRepository.updateBank(bank, bank.serializedClientData)
notifyBanksListUpdated() // notify about updated values like account balance notifyBanksListUpdated() // notify about updated values like account balance
} catch (e: Throwable) { } catch (e: Throwable) {