Fixed that TanProcedures didn't get saved and restored
This commit is contained in:
parent
9c269ceb09
commit
820e271d1f
|
@ -64,12 +64,21 @@
|
|||
<attribute name="finTsServerAddress" attributeType="String"/>
|
||||
<attribute name="iconUrl" optional="YES" attributeType="String"/>
|
||||
<attribute name="password" attributeType="String"/>
|
||||
<attribute name="selectedTanProcedureCode" optional="YES" attributeType="String"/>
|
||||
<attribute name="userId" attributeType="String"/>
|
||||
<relationship name="accounts" toMany="YES" deletionRule="Cascade" destinationEntity="PersistedBankAccount" inverseName="customer" inverseEntity="PersistedBankAccount"/>
|
||||
<attribute name="userSetDisplayName" optional="YES" attributeType="String"/>
|
||||
<relationship name="accounts" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="PersistedBankAccount" inverseName="customer" inverseEntity="PersistedBankAccount"/>
|
||||
<relationship name="supportedTanProcedures" toMany="YES" deletionRule="Cascade" ordered="YES" destinationEntity="PersistedTanProcedure"/>
|
||||
</entity>
|
||||
<entity name="PersistedTanProcedure" representedClassName="PersistedTanProcedure" syncable="YES" codeGenerationType="class">
|
||||
<attribute name="bankInternalProcedureCode" attributeType="String"/>
|
||||
<attribute name="displayName" attributeType="String"/>
|
||||
<attribute name="type" attributeType="String"/>
|
||||
</entity>
|
||||
<elements>
|
||||
<element name="PersistedAccountTransaction" positionX="-36" positionY="45" width="128" height="553"/>
|
||||
<element name="PersistedBankAccount" positionX="-54" positionY="63" width="128" height="298"/>
|
||||
<element name="PersistedCustomer" positionX="-63" positionY="-18" width="128" height="193"/>
|
||||
<element name="PersistedBankAccount" positionX="-54" positionY="63" width="128" height="328"/>
|
||||
<element name="PersistedCustomer" positionX="-63" positionY="-18" width="128" height="253"/>
|
||||
<element name="PersistedTanProcedure" positionX="-54" positionY="135" width="128" height="88"/>
|
||||
</elements>
|
||||
</model>
|
|
@ -12,6 +12,8 @@ class Mapper {
|
|||
|
||||
private var mappedTransactions = [AccountTransaction:PersistedAccountTransaction]()
|
||||
|
||||
private var mappedTanProcedures = [TanProcedure:PersistedTanProcedure]()
|
||||
|
||||
|
||||
func map(_ customer: PersistedCustomer) -> Customer {
|
||||
let mapped = Customer(bankCode: map(customer.bankCode), customerId: map(customer.customerId), password: map(customer.password), finTsServerAddress: map(customer.finTsServerAddress), bankName: map(customer.bankName), bic: map(customer.bic), customerName: map(customer.customerName), userId: map(customer.userId), iconUrl: customer.iconUrl, accounts: [])
|
||||
|
@ -20,6 +22,9 @@ class Mapper {
|
|||
|
||||
mappedBanks[mapped] = customer
|
||||
|
||||
mapped.supportedTanProcedures = map(customer.supportedTanProcedures?.array as? [PersistedTanProcedure])
|
||||
mapped.selectedTanProcedure = mapped.supportedTanProcedures.first(where: { $0.bankInternalProcedureCode == customer.selectedTanProcedureCode })
|
||||
|
||||
return mapped
|
||||
}
|
||||
|
||||
|
@ -40,6 +45,9 @@ class Mapper {
|
|||
|
||||
mappedBanks[customer] = mapped
|
||||
|
||||
mapped.supportedTanProcedures = NSOrderedSet(array: map(customer.supportedTanProcedures, context))
|
||||
mapped.selectedTanProcedureCode = customer.selectedTanProcedure?.bankInternalProcedureCode
|
||||
|
||||
return mapped
|
||||
}
|
||||
|
||||
|
@ -188,6 +196,66 @@ class Mapper {
|
|||
}
|
||||
|
||||
|
||||
func map(_ tanProcedures: [PersistedTanProcedure]?) -> [TanProcedure] {
|
||||
return tanProcedures?.map { map($0) } ?? []
|
||||
}
|
||||
|
||||
func map(_ tanProcedure: PersistedTanProcedure) -> TanProcedure {
|
||||
let mapped = TanProcedure(
|
||||
displayName: map(tanProcedure.displayName),
|
||||
type: mapTanProcedureType(tanProcedure.type),
|
||||
bankInternalProcedureCode: map(tanProcedure.bankInternalProcedureCode)
|
||||
)
|
||||
|
||||
mappedTanProcedures[mapped] = tanProcedure
|
||||
|
||||
return mapped
|
||||
}
|
||||
|
||||
func map(_ tanProcedures: [TanProcedure], _ context: NSManagedObjectContext) -> [PersistedTanProcedure] {
|
||||
return tanProcedures.map { map($0, context) }
|
||||
}
|
||||
|
||||
func map(_ tanProcedure: TanProcedure, _ context: NSManagedObjectContext) -> PersistedTanProcedure {
|
||||
let mapped = mappedTanProcedures[tanProcedure] ?? PersistedTanProcedure(context: context)
|
||||
|
||||
mapped.displayName = tanProcedure.displayName
|
||||
mapped.type = tanProcedure.type.name
|
||||
mapped.bankInternalProcedureCode = tanProcedure.bankInternalProcedureCode
|
||||
|
||||
mappedTanProcedures[tanProcedure] = mapped
|
||||
|
||||
return mapped
|
||||
}
|
||||
|
||||
func mapTanProcedureType(_ type: String?) -> TanProcedureType {
|
||||
switch type {
|
||||
case TanProcedureType.entertan.name:
|
||||
return TanProcedureType.entertan
|
||||
case TanProcedureType.chiptanmanuell.name:
|
||||
return TanProcedureType.chiptanmanuell
|
||||
case TanProcedureType.chiptanflickercode.name:
|
||||
return TanProcedureType.chiptanflickercode
|
||||
case TanProcedureType.chiptanusb.name:
|
||||
return TanProcedureType.chiptanusb
|
||||
case TanProcedureType.chiptanqrcode.name:
|
||||
return TanProcedureType.chiptanqrcode
|
||||
case TanProcedureType.chiptanphototanmatrixcode.name:
|
||||
return TanProcedureType.chiptanphototanmatrixcode
|
||||
case TanProcedureType.smstan.name:
|
||||
return TanProcedureType.smstan
|
||||
case TanProcedureType.apptan.name:
|
||||
return TanProcedureType.apptan
|
||||
case TanProcedureType.phototan.name:
|
||||
return TanProcedureType.phototan
|
||||
case TanProcedureType.qrcode.name:
|
||||
return TanProcedureType.qrcode
|
||||
default:
|
||||
return TanProcedureType.entertan
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func map(_ date: Date?) -> CommonDate {
|
||||
if let date = date {
|
||||
return CommonDate(date: date)
|
||||
|
|
Loading…
Reference in New Issue