mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 11:27:05 +00:00
Refactoring
This commit is contained in:
parent
6c6606cf91
commit
338894aa2c
@ -414,13 +414,10 @@ class MongoDBLocalStorage extends LocalStorage {
|
||||
val publicAccountsThatUserDoesNotHaveMoreThanAnon = ViewImpl.findAll(By(ViewImpl.isPublic_, true)).
|
||||
map{_.account.obj}.
|
||||
collect{case Full(a) => a.theAccount}.
|
||||
collect{case Full(a) => {
|
||||
collect{case Full(a)
|
||||
//Throw out those that are already counted in moreThanAnonAccounts
|
||||
if(moreThanAnonAccounts.exists(x => {
|
||||
(a.bankPermalink == x.bankPermalink) && (a.permalink.get == x.permalink)
|
||||
})) Empty
|
||||
else Full(Account.toBankAccount(a))
|
||||
}}.flatten
|
||||
if(!moreThanAnonAccounts.exists(x => sameAccount(a, x))) => Account.toBankAccount(a)
|
||||
}
|
||||
|
||||
moreThanAnonAccounts ++ publicAccountsThatUserDoesNotHaveMoreThanAnon
|
||||
}
|
||||
@ -428,6 +425,16 @@ class MongoDBLocalStorage extends LocalStorage {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an Account and BankAccount represent the same thing (to avoid converting between the two if
|
||||
* it's not required)
|
||||
*/
|
||||
private def sameAccount(account : Account, bankAccount : BankAccount) : Boolean = {
|
||||
//important: account.permalink.get (if you just use account.permalink it compares a StringField
|
||||
// to a String, which will always be false
|
||||
(account.bankPermalink == bankAccount.bankPermalink) && (account.permalink.get == bankAccount.permalink)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user
|
||||
* @return the bank accounts at @bank the @user can see (public + private if @user is Full, public if @user is Empty)
|
||||
@ -449,13 +456,10 @@ class MongoDBLocalStorage extends LocalStorage {
|
||||
val publicAccountsThatUserDoesNotHaveMoreThanAnon = ViewImpl.findAll(By(ViewImpl.isPublic_, true)).
|
||||
map{_.account.obj}.
|
||||
collect{case Full(a) if a.bank==bank.fullName => a.theAccount}. //throw out with the wrong bank
|
||||
collect{case Full(a) => {
|
||||
//Throw out those that are already counted in moreThanAnonAccounts
|
||||
if(moreThanAnonAccounts.exists(x => {
|
||||
(a.bankPermalink == x.bankPermalink) && (a.permalink.get == x.permalink)
|
||||
})) Empty
|
||||
else Full(Account.toBankAccount(a))
|
||||
}}.flatten
|
||||
collect{case Full(a)
|
||||
//Throw out those that are already counted in moreThanAnonAccounts
|
||||
if(!moreThanAnonAccounts.exists(x => sameAccount(a, x))) => Account.toBankAccount(a)
|
||||
}
|
||||
|
||||
moreThanAnonAccounts ++ publicAccountsThatUserDoesNotHaveMoreThanAnon
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user