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:
parent
afc480453d
commit
e5f661199b
|
@ -1,30 +1,25 @@
|
||||||
package net.dankito.banking.bankfinder
|
package net.dankito.banking.bankfinder
|
||||||
|
|
||||||
|
|
||||||
open class BankInfo(
|
open class BankInfo constructor(
|
||||||
val name: String,
|
open val name: String,
|
||||||
val bankCode: String,
|
open val bankCode: String,
|
||||||
val bic: String,
|
open val bic: String,
|
||||||
val postalCode: String,
|
open val postalCode: String,
|
||||||
val city: String,
|
open val city: String,
|
||||||
val checksumMethod: String,
|
open val pinTanAddress: String?,
|
||||||
val pinTanAddress: String?,
|
open val pinTanVersion: String?
|
||||||
val pinTanVersion: String?,
|
|
||||||
val oldBankCode: 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
|
get() = pinTanAddress.isNullOrEmpty() == false
|
||||||
|
|
||||||
val supportsFinTs3_0: Boolean
|
open val supportsFinTs3_0: Boolean
|
||||||
get() = pinTanVersion == "FinTS V3.0"
|
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 {
|
override fun toString(): String {
|
||||||
return "$bankCode $name $city"
|
return "$bankCode $name $city"
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
}
|
|
@ -34,10 +34,8 @@ actual class BankListDeserializer {
|
||||||
bankInfoDict.getStringOrEmpty("bic"),
|
bankInfoDict.getStringOrEmpty("bic"),
|
||||||
bankInfoDict.getStringOrEmpty("postalCode"),
|
bankInfoDict.getStringOrEmpty("postalCode"),
|
||||||
bankInfoDict.getStringOrEmpty("city"),
|
bankInfoDict.getStringOrEmpty("city"),
|
||||||
bankInfoDict.getStringOrEmpty("checksumMethod"),
|
|
||||||
bankInfoDict.getString("pinTanAddress"),
|
bankInfoDict.getString("pinTanAddress"),
|
||||||
bankInfoDict.getString("pinTanVersion"),
|
bankInfoDict.getString("pinTanVersion")
|
||||||
bankInfoDict.getString("oldBankCode")
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package net.dankito.banking.banklistcreator.parser
|
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.BankCodeListEntry
|
||||||
import net.dankito.banking.banklistcreator.parser.model.ServerAddressesListEntry
|
import net.dankito.banking.banklistcreator.parser.model.ServerAddressesListEntry
|
||||||
import net.dankito.fints.model.BankInfo
|
|
||||||
import org.docx4j.openpackaging.packages.SpreadsheetMLPackage
|
import org.docx4j.openpackaging.packages.SpreadsheetMLPackage
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import org.xlsx4j.org.apache.poi.ss.usermodel.DataFormatter
|
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 xlsxPkg = SpreadsheetMLPackage.load(bankListFile)
|
||||||
|
|
||||||
val workbookPart = xlsxPkg.getWorkbookPart()
|
val workbookPart = xlsxPkg.getWorkbookPart()
|
||||||
|
@ -50,7 +50,7 @@ open class DeutscheKreditwirtschaftBankListParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mapBankCodeAndServerAddressesList(banks: List<BankCodeListEntry>,
|
private fun mapBankCodeAndServerAddressesList(banks: List<BankCodeListEntry>,
|
||||||
serverAddresses: List<ServerAddressesListEntry>): List<BankInfo> {
|
serverAddresses: List<ServerAddressesListEntry>): List<DetailedBankInfo> {
|
||||||
|
|
||||||
val serverAddressesByBankCode = mutableMapOf<String, MutableList<ServerAddressesListEntry>>()
|
val serverAddressesByBankCode = mutableMapOf<String, MutableList<ServerAddressesListEntry>>()
|
||||||
serverAddresses.forEach { serverAddress ->
|
serverAddresses.forEach { serverAddress ->
|
||||||
|
@ -66,19 +66,19 @@ open class DeutscheKreditwirtschaftBankListParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mapToBankInfo(bank: BankCodeListEntry,
|
private fun mapToBankInfo(bank: BankCodeListEntry,
|
||||||
serverAddressesByBankCode: Map<String, List<ServerAddressesListEntry>>): BankInfo {
|
serverAddressesByBankCode: Map<String, List<ServerAddressesListEntry>>): DetailedBankInfo {
|
||||||
|
|
||||||
val serverAddress = findServerAddress(bank, serverAddressesByBankCode)
|
val serverAddress = findServerAddress(bank, serverAddressesByBankCode)
|
||||||
|
|
||||||
return BankInfo(
|
return DetailedBankInfo(
|
||||||
bank.bankName,
|
bank.bankName,
|
||||||
bank.bankCode,
|
bank.bankCode,
|
||||||
bank.bic,
|
bank.bic,
|
||||||
bank.postalCode,
|
bank.postalCode,
|
||||||
bank.city,
|
bank.city,
|
||||||
bank.checksumMethod,
|
|
||||||
serverAddress?.pinTanAddress,
|
serverAddress?.pinTanAddress,
|
||||||
serverAddress?.pinTanVersion,
|
serverAddress?.pinTanVersion,
|
||||||
|
bank.checksumMethod,
|
||||||
bank.oldBankCode
|
bank.oldBankCode
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,8 @@ open class LuceneBankFinder(indexFolder: File) : BankFinderBase(), IBankFinder {
|
||||||
const val BankInfoCityIndexedFieldName = "city_indexed"
|
const val BankInfoCityIndexedFieldName = "city_indexed"
|
||||||
const val BankInfoCityStoredFieldName = "city_stored"
|
const val BankInfoCityStoredFieldName = "city_stored"
|
||||||
const val BankInfoPostalCodeFieldName = "postal_code"
|
const val BankInfoPostalCodeFieldName = "postal_code"
|
||||||
const val BankInfoChecksumMethodFieldName = "checksum_method"
|
|
||||||
const val BankInfoPinTanServerAddressFieldName = "pin_tan_server_address"
|
const val BankInfoPinTanServerAddressFieldName = "pin_tan_server_address"
|
||||||
const val BankInfoPinTanVersionFieldName = "pin_tan_version"
|
const val BankInfoPinTanVersionFieldName = "pin_tan_version"
|
||||||
const val BankInfoOldBankCodeFieldName = "old_bank_code"
|
|
||||||
|
|
||||||
val bankInfoProperties = listOf(
|
val bankInfoProperties = listOf(
|
||||||
PropertyDescription(PropertyType.String, BankInfoNameFieldName, BankInfo::name),
|
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, BankInfoBicFieldName, BankInfo::bic),
|
||||||
PropertyDescription(PropertyType.String, BankInfoPostalCodeFieldName, BankInfo::postalCode),
|
PropertyDescription(PropertyType.String, BankInfoPostalCodeFieldName, BankInfo::postalCode),
|
||||||
PropertyDescription(PropertyType.String, BankInfoCityStoredFieldName, BankInfo::city),
|
PropertyDescription(PropertyType.String, BankInfoCityStoredFieldName, BankInfo::city),
|
||||||
PropertyDescription(PropertyType.String, BankInfoChecksumMethodFieldName, BankInfo::checksumMethod),
|
|
||||||
PropertyDescription(PropertyType.NullableString, BankInfoPinTanServerAddressFieldName, BankInfo::pinTanAddress),
|
PropertyDescription(PropertyType.NullableString, BankInfoPinTanServerAddressFieldName, BankInfo::pinTanAddress),
|
||||||
PropertyDescription(PropertyType.NullableString, BankInfoPinTanVersionFieldName, BankInfo::pinTanVersion),
|
PropertyDescription(PropertyType.NullableString, BankInfoPinTanVersionFieldName, BankInfo::pinTanVersion)
|
||||||
PropertyDescription(PropertyType.NullableString, BankInfoOldBankCodeFieldName, BankInfo::oldBankCode)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,10 +188,8 @@ open class LuceneBankFinder(indexFolder: File) : BankFinderBase(), IBankFinder {
|
||||||
|
|
||||||
fields.storedField(BankInfoCityStoredFieldName, bank.city),
|
fields.storedField(BankInfoCityStoredFieldName, bank.city),
|
||||||
fields.storedField(BankInfoPostalCodeFieldName, bank.postalCode),
|
fields.storedField(BankInfoPostalCodeFieldName, bank.postalCode),
|
||||||
fields.storedField(BankInfoChecksumMethodFieldName, bank.checksumMethod),
|
|
||||||
fields.nullableStoredField(BankInfoPinTanServerAddressFieldName, bank.pinTanAddress),
|
fields.nullableStoredField(BankInfoPinTanServerAddressFieldName, bank.pinTanAddress),
|
||||||
fields.nullableStoredField(BankInfoPinTanVersionFieldName, bank.pinTanVersion),
|
fields.nullableStoredField(BankInfoPinTanVersionFieldName, bank.pinTanVersion)
|
||||||
fields.nullableStoredField(BankInfoOldBankCodeFieldName, bank.oldBankCode)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue