Extracted DetailedBankInfo to be able to reduce .json file from 4,0 to 3,3 MB by leaving away unused checksumMethod and oldBankCode

This commit is contained in:
dankito 2020-09-16 22:33:35 +02:00
parent afc480453d
commit e5f661199b
5 changed files with 42 additions and 33 deletions

View File

@ -1,30 +1,25 @@
package net.dankito.banking.bankfinder
open class BankInfo(
val name: String,
val bankCode: String,
val bic: String,
val postalCode: String,
val city: String,
val checksumMethod: String,
val pinTanAddress: String?,
val pinTanVersion: String?,
val oldBankCode: String?
open class BankInfo constructor(
open val name: String,
open val bankCode: String,
open val bic: String,
open val postalCode: String,
open val city: String,
open val pinTanAddress: String?,
open val pinTanVersion: String?
) {
protected constructor() : this("", "", "", "", "", null, "") // for object deserializers
protected constructor() : this("", "", "", "", "", "", null, null, null) // for object deserializers
val supportsPinTan: Boolean
open val supportsPinTan: Boolean
get() = pinTanAddress.isNullOrEmpty() == false
val supportsFinTs3_0: Boolean
open val supportsFinTs3_0: Boolean
get() = pinTanVersion == "FinTS V3.0"
val isBankCodeDeleted: Boolean
get() = oldBankCode != null // TODO: this is not in all cases true, there are banks with new bank code which haven't been deleted
override fun toString(): String {
return "$bankCode $name $city"

View File

@ -0,0 +1,22 @@
package net.dankito.banking.bankfinder
open class DetailedBankInfo(
name: String,
bankCode: String,
bic: String,
postalCode: String,
city: String,
pinTanAddress: String?,
pinTanVersion: String?,
open val checksumMethod: String,
open val oldBankCode: String?
) : BankInfo(name, bankCode, bic, postalCode, city, pinTanAddress, pinTanVersion) {
protected constructor() : this("", "", "", "", "", null, "", "", null) // for object deserializers
open val isBankCodeDeleted: Boolean
get() = oldBankCode != null // TODO: this is not in all cases true, there are banks with new bank code which haven't been deleted
}

View File

@ -34,10 +34,8 @@ actual class BankListDeserializer {
bankInfoDict.getStringOrEmpty("bic"),
bankInfoDict.getStringOrEmpty("postalCode"),
bankInfoDict.getStringOrEmpty("city"),
bankInfoDict.getStringOrEmpty("checksumMethod"),
bankInfoDict.getString("pinTanAddress"),
bankInfoDict.getString("pinTanVersion"),
bankInfoDict.getString("oldBankCode")
bankInfoDict.getString("pinTanVersion")
)
}

View File

@ -1,8 +1,8 @@
package net.dankito.banking.banklistcreator.parser
import net.dankito.banking.bankfinder.DetailedBankInfo
import net.dankito.banking.banklistcreator.parser.model.BankCodeListEntry
import net.dankito.banking.banklistcreator.parser.model.ServerAddressesListEntry
import net.dankito.fints.model.BankInfo
import org.docx4j.openpackaging.packages.SpreadsheetMLPackage
import org.slf4j.LoggerFactory
import org.xlsx4j.org.apache.poi.ss.usermodel.DataFormatter
@ -23,7 +23,7 @@ open class DeutscheKreditwirtschaftBankListParser {
}
fun parse(bankListFile: File): List<BankInfo> {
fun parse(bankListFile: File): List<DetailedBankInfo> {
val xlsxPkg = SpreadsheetMLPackage.load(bankListFile)
val workbookPart = xlsxPkg.getWorkbookPart()
@ -50,7 +50,7 @@ open class DeutscheKreditwirtschaftBankListParser {
}
private fun mapBankCodeAndServerAddressesList(banks: List<BankCodeListEntry>,
serverAddresses: List<ServerAddressesListEntry>): List<BankInfo> {
serverAddresses: List<ServerAddressesListEntry>): List<DetailedBankInfo> {
val serverAddressesByBankCode = mutableMapOf<String, MutableList<ServerAddressesListEntry>>()
serverAddresses.forEach { serverAddress ->
@ -66,19 +66,19 @@ open class DeutscheKreditwirtschaftBankListParser {
}
private fun mapToBankInfo(bank: BankCodeListEntry,
serverAddressesByBankCode: Map<String, List<ServerAddressesListEntry>>): BankInfo {
serverAddressesByBankCode: Map<String, List<ServerAddressesListEntry>>): DetailedBankInfo {
val serverAddress = findServerAddress(bank, serverAddressesByBankCode)
return BankInfo(
return DetailedBankInfo(
bank.bankName,
bank.bankCode,
bank.bic,
bank.postalCode,
bank.city,
bank.checksumMethod,
serverAddress?.pinTanAddress,
serverAddress?.pinTanVersion,
bank.checksumMethod,
bank.oldBankCode
)
}

View File

@ -31,10 +31,8 @@ open class LuceneBankFinder(indexFolder: File) : BankFinderBase(), IBankFinder {
const val BankInfoCityIndexedFieldName = "city_indexed"
const val BankInfoCityStoredFieldName = "city_stored"
const val BankInfoPostalCodeFieldName = "postal_code"
const val BankInfoChecksumMethodFieldName = "checksum_method"
const val BankInfoPinTanServerAddressFieldName = "pin_tan_server_address"
const val BankInfoPinTanVersionFieldName = "pin_tan_version"
const val BankInfoOldBankCodeFieldName = "old_bank_code"
val bankInfoProperties = listOf(
PropertyDescription(PropertyType.String, BankInfoNameFieldName, BankInfo::name),
@ -42,10 +40,8 @@ open class LuceneBankFinder(indexFolder: File) : BankFinderBase(), IBankFinder {
PropertyDescription(PropertyType.String, BankInfoBicFieldName, BankInfo::bic),
PropertyDescription(PropertyType.String, BankInfoPostalCodeFieldName, BankInfo::postalCode),
PropertyDescription(PropertyType.String, BankInfoCityStoredFieldName, BankInfo::city),
PropertyDescription(PropertyType.String, BankInfoChecksumMethodFieldName, BankInfo::checksumMethod),
PropertyDescription(PropertyType.NullableString, BankInfoPinTanServerAddressFieldName, BankInfo::pinTanAddress),
PropertyDescription(PropertyType.NullableString, BankInfoPinTanVersionFieldName, BankInfo::pinTanVersion),
PropertyDescription(PropertyType.NullableString, BankInfoOldBankCodeFieldName, BankInfo::oldBankCode)
PropertyDescription(PropertyType.NullableString, BankInfoPinTanVersionFieldName, BankInfo::pinTanVersion)
)
@ -192,10 +188,8 @@ open class LuceneBankFinder(indexFolder: File) : BankFinderBase(), IBankFinder {
fields.storedField(BankInfoCityStoredFieldName, bank.city),
fields.storedField(BankInfoPostalCodeFieldName, bank.postalCode),
fields.storedField(BankInfoChecksumMethodFieldName, bank.checksumMethod),
fields.nullableStoredField(BankInfoPinTanServerAddressFieldName, bank.pinTanAddress),
fields.nullableStoredField(BankInfoPinTanVersionFieldName, bank.pinTanVersion),
fields.nullableStoredField(BankInfoOldBankCodeFieldName, bank.oldBankCode)
fields.nullableStoredField(BankInfoPinTanVersionFieldName, bank.pinTanVersion)
)
}