mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 17:17:09 +00:00
remove duplicate method create Account Holder and added some comments
This commit is contained in:
parent
4e27c10a11
commit
e5bc5fa1f7
@ -24,13 +24,11 @@ object AccountHolders extends SimpleInjector {
|
||||
trait AccountHolders {
|
||||
def getAccountHolders(bankId: BankId, accountId: AccountId): Set[User]
|
||||
def getAccountsHeld(bankId: BankId, user: User): Set[BankIdAccountId]
|
||||
def createAccountHolder(userId: Long, bankId: String, accountId: String): Boolean
|
||||
def getOrCreateAccountHolder(user: User, bankAccountUID :BankIdAccountId): Box[MapperAccountHolders] //There is no AccountHolder trait, database structure different with view
|
||||
def bulkDeleteAllAccountHolders(): Box[Boolean]
|
||||
}
|
||||
|
||||
class RemotedataAccountHoldersCaseClasses {
|
||||
case class createAccountHolder(userId: Long, bankId: String, accountId: String)
|
||||
case class getAccountHolders(bankId: BankId, accountId: AccountId)
|
||||
case class getAccountsHeld(bankId: BankId, user: User)
|
||||
case class getOrCreateAccountHolder(user: User, bankAccountUID :BankIdAccountId)
|
||||
|
||||
@ -30,25 +30,12 @@ object MapperAccountHolders extends MapperAccountHolders with AccountHolders wit
|
||||
|
||||
override def dbIndexes = Index(accountBankPermalink, accountPermalink) :: Nil
|
||||
|
||||
def createAccountHolder(userId: Long, bankId: String, accountId: String): Boolean = {
|
||||
val holder = MapperAccountHolders.create
|
||||
.accountBankPermalink(bankId)
|
||||
.accountPermalink(accountId)
|
||||
.user(userId)
|
||||
.saveMe
|
||||
if(holder.saved_?)
|
||||
true
|
||||
else
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
//Note, this method, will not check the existing of bankAccount, any value of BankIdAccountId
|
||||
//Can create the MapperAccountHolders.
|
||||
def getOrCreateAccountHolder(user: User, bankIdAccountId :BankIdAccountId): Box[MapperAccountHolders] ={
|
||||
|
||||
val mapperAccountHolder = MapperAccountHolders.find(
|
||||
By(MapperAccountHolders.user, user.resourceUserId.value),
|
||||
By(MapperAccountHolders.user, user.userPrimaryId.value),
|
||||
By(MapperAccountHolders.accountBankPermalink, bankIdAccountId.bankId.value),
|
||||
By(MapperAccountHolders.accountPermalink, bankIdAccountId.accountId.value)
|
||||
)
|
||||
@ -64,7 +51,7 @@ object MapperAccountHolders extends MapperAccountHolders with AccountHolders wit
|
||||
val holder: MapperAccountHolders = MapperAccountHolders.create
|
||||
.accountBankPermalink(bankIdAccountId.bankId.value)
|
||||
.accountPermalink(bankIdAccountId.accountId.value)
|
||||
.user(user.resourceUserId.value)
|
||||
.user(user.userPrimaryId.value)
|
||||
.saveMe
|
||||
logger.debug(
|
||||
s"getOrCreateAccountHolder--> create account holder: $holder"
|
||||
|
||||
@ -221,7 +221,7 @@ object JSONFactory_UKOpenBanking_200 {
|
||||
accounts.map(account => BalanceJsonUKV200(
|
||||
AccountId = account.accountId.value,
|
||||
Amount = AmountOfMoneyJsonV121(account.currency, account.balance.toString()),
|
||||
CreditDebitIndicator = account.owners.headOption.getOrElse(null).name,
|
||||
CreditDebitIndicator = account.userOwners.headOption.getOrElse(null).name,
|
||||
Type = "Credit",
|
||||
DateTime = null,
|
||||
CreditLine = List(CreditLineJson(
|
||||
|
||||
@ -101,9 +101,9 @@ object OpenIdConnect extends OBPRestHelper with MdcLoggable {
|
||||
userEmail <- tryo{(json_user \ "email").extractOrElse[String]("")}
|
||||
auth_user: AuthUser <- AuthUser.find(By(AuthUser.email, userEmail))
|
||||
resource_user: ResourceUser <- User.findResourceUserByResourceUserId(auth_user.user.get)
|
||||
if emailVerified && resource_user.resourceUserId.value > 0
|
||||
if emailVerified && resource_user.userPrimaryId.value > 0
|
||||
} yield {
|
||||
saveAuthorizationToken(accessToken, accessToken, resource_user.resourceUserId.value)
|
||||
saveAuthorizationToken(accessToken, accessToken, resource_user.userPrimaryId.value)
|
||||
httpCode = 200
|
||||
message= String.format("oauth_token=%s&oauth_token_secret=%s", accessToken, accessToken)
|
||||
val headers = ("Content-type" -> "application/x-www-form-urlencoded") :: Nil
|
||||
|
||||
@ -530,7 +530,7 @@ trait APIMethods121 {
|
||||
for {
|
||||
u <- cc.user ?~ UserNotLoggedIn
|
||||
account <- BankAccount(bankId, accountId) ?~! BankAccountNotFound
|
||||
_ <- booleanToBox(u.hasOwnerViewAccess(BankIdAccountId(account.bankId, account.accountId)), UserNoOwnerView +"userId : " + u.resourceUserId + ". account : " + accountId)
|
||||
_ <- booleanToBox(u.hasOwnerViewAccess(BankIdAccountId(account.bankId, account.accountId)), UserNoOwnerView +"userId : " + u.userPrimaryId + ". account : " + accountId)
|
||||
views <- Full(Views.views.vend.viewsForAccount(BankIdAccountId(account.bankId, account.accountId)))
|
||||
} yield {
|
||||
val viewsJSON = JSONFactory.createViewsJSON(views)
|
||||
@ -1864,7 +1864,7 @@ trait APIMethods121 {
|
||||
addCorpLocation <- Box(metadata.addCorporateLocation) ?~ {"the view " + viewId + "does not allow adding a corporate location"}
|
||||
corpLocationJson <- tryo{(json.extract[CorporateLocationJSON])} ?~ {InvalidJsonFormat}
|
||||
correctCoordinates <- checkIfLocationPossible(corpLocationJson.corporate_location.latitude, corpLocationJson.corporate_location.longitude)
|
||||
added <- Counterparties.counterparties.vend.addCorporateLocation(other_account_id, u.resourceUserId, (now:TimeSpan), corpLocationJson.corporate_location.longitude, corpLocationJson.corporate_location.latitude) ?~ {"Corporate Location cannot be deleted"}
|
||||
added <- Counterparties.counterparties.vend.addCorporateLocation(other_account_id, u.userPrimaryId, (now:TimeSpan), corpLocationJson.corporate_location.longitude, corpLocationJson.corporate_location.latitude) ?~ {"Corporate Location cannot be deleted"}
|
||||
if(added)
|
||||
} yield {
|
||||
val successJson = SuccessMessage("corporate location added")
|
||||
@ -1908,7 +1908,7 @@ trait APIMethods121 {
|
||||
addCorpLocation <- Box(metadata.addCorporateLocation) ?~ {"the view " + viewId + "does not allow updating a corporate location"}
|
||||
corpLocationJson <- tryo{(json.extract[CorporateLocationJSON])} ?~ {InvalidJsonFormat}
|
||||
correctCoordinates <- checkIfLocationPossible(corpLocationJson.corporate_location.latitude, corpLocationJson.corporate_location.longitude)
|
||||
updated <- Counterparties.counterparties.vend.addCorporateLocation(other_account_id, u.resourceUserId, (now:TimeSpan), corpLocationJson.corporate_location.longitude, corpLocationJson.corporate_location.latitude) ?~ {"Corporate Location cannot be updated"}
|
||||
updated <- Counterparties.counterparties.vend.addCorporateLocation(other_account_id, u.userPrimaryId, (now:TimeSpan), corpLocationJson.corporate_location.longitude, corpLocationJson.corporate_location.latitude) ?~ {"Corporate Location cannot be updated"}
|
||||
if(updated)
|
||||
} yield {
|
||||
val successJson = SuccessMessage("corporate location updated")
|
||||
@ -1995,7 +1995,7 @@ trait APIMethods121 {
|
||||
physicalLocationJson <- tryo{(json.extract[PhysicalLocationJSON])} ?~ {InvalidJsonFormat}
|
||||
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
|
||||
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
|
||||
added <- Counterparties.counterparties.vend.addPhysicalLocation(other_account_id, u.resourceUserId, (now:TimeSpan), physicalLocationJson.physical_location.longitude, physicalLocationJson.physical_location.latitude) ?~ {"Physical Location cannot be added"}
|
||||
added <- Counterparties.counterparties.vend.addPhysicalLocation(other_account_id, u.userPrimaryId, (now:TimeSpan), physicalLocationJson.physical_location.longitude, physicalLocationJson.physical_location.latitude) ?~ {"Physical Location cannot be added"}
|
||||
if(added)
|
||||
} yield {
|
||||
val successJson = SuccessMessage("physical location added")
|
||||
@ -2040,7 +2040,7 @@ trait APIMethods121 {
|
||||
physicalLocationJson <- tryo{(json.extract[PhysicalLocationJSON])} ?~ {InvalidJsonFormat}
|
||||
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
|
||||
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
|
||||
updated <- Counterparties.counterparties.vend.addPhysicalLocation(other_account_id, u.resourceUserId, (now:TimeSpan), physicalLocationJson.physical_location.longitude, physicalLocationJson.physical_location.latitude) ?~ {"Physical Location cannot be updated"}
|
||||
updated <- Counterparties.counterparties.vend.addPhysicalLocation(other_account_id, u.userPrimaryId, (now:TimeSpan), physicalLocationJson.physical_location.longitude, physicalLocationJson.physical_location.latitude) ?~ {"Physical Location cannot be updated"}
|
||||
if(updated)
|
||||
} yield {
|
||||
val successJson = SuccessMessage("physical location updated")
|
||||
@ -2413,7 +2413,7 @@ trait APIMethods121 {
|
||||
commentJson <- tryo{json.extract[PostTransactionCommentJSON]} ?~ {InvalidJsonFormat}
|
||||
metadata <- moderatedTransactionMetadata(bankId, accountId, viewId, transactionId, Full(u), Some(cc))
|
||||
addCommentFunc <- Box(metadata.addComment) ?~ { s"$NoViewPermission can_add_comment. Current ViewId($viewId)" }
|
||||
postedComment <- addCommentFunc(u.resourceUserId, viewId, commentJson.value, now)
|
||||
postedComment <- addCommentFunc(u.userPrimaryId, viewId, commentJson.value, now)
|
||||
} yield {
|
||||
successJsonResponse(Extraction.decompose(JSONFactory.createTransactionCommentJSON(postedComment)),201)
|
||||
}
|
||||
@ -2525,7 +2525,7 @@ trait APIMethods121 {
|
||||
tagJson <- tryo{json.extract[PostTransactionTagJSON]} ?~ { s"$InvalidJsonFormat Check your Post Json Body." }
|
||||
metadata <- moderatedTransactionMetadata(bankId, accountId, viewId, transactionId, Full(u), Some(cc))
|
||||
addTagFunc <- Box(metadata.addTag) ?~ { s"$NoViewPermission can_add_tag. Current ViewId($viewId)" }
|
||||
postedTag <- addTagFunc(u.resourceUserId, viewId, tagJson.value, now)
|
||||
postedTag <- addTagFunc(u.userPrimaryId, viewId, tagJson.value, now)
|
||||
} yield {
|
||||
successJsonResponse(Extraction.decompose(JSONFactory.createTransactionTagJSON(postedTag)), 201)
|
||||
}
|
||||
@ -2637,7 +2637,7 @@ trait APIMethods121 {
|
||||
metadata <- moderatedTransactionMetadata(bankId, accountId, viewId, transactionId, Full(u), Some(cc))
|
||||
addImageFunc <- Box(metadata.addImage) ?~ { s"$NoViewPermission can_add_image. Current ViewId($viewId)" }
|
||||
url <- tryo{new URL(imageJson.URL)} ?~! s"$InvalidUrl Could not parse url string as a valid URL"
|
||||
postedImage <- addImageFunc(u.resourceUserId, viewId, imageJson.label, now, url.toString)
|
||||
postedImage <- addImageFunc(u.userPrimaryId, viewId, imageJson.label, now, url.toString)
|
||||
} yield {
|
||||
successJsonResponse(Extraction.decompose(JSONFactory.createTransactionImageJSON(postedImage)),201)
|
||||
}
|
||||
@ -2753,7 +2753,7 @@ trait APIMethods121 {
|
||||
addWhereTag <- Box(metadata.addWhereTag) ?~ { s"$NoViewPermission can_add_where_tag. Current ViewId($viewId)" }
|
||||
whereJson <- tryo{(json.extract[PostTransactionWhereJSON])} ?~ {InvalidJsonFormat}
|
||||
correctCoordinates <- checkIfLocationPossible(whereJson.where.latitude, whereJson.where.longitude)
|
||||
if(addWhereTag(u.resourceUserId, viewId, now, whereJson.where.longitude, whereJson.where.latitude))
|
||||
if(addWhereTag(u.userPrimaryId, viewId, now, whereJson.where.longitude, whereJson.where.latitude))
|
||||
} yield {
|
||||
val successJson = SuccessMessage("where tag added")
|
||||
successJsonResponse(Extraction.decompose(successJson), 201)
|
||||
@ -2797,7 +2797,7 @@ trait APIMethods121 {
|
||||
addWhereTag <- Box(metadata.addWhereTag) ?~ { s"$NoViewPermission can_add_where_tag. Current ViewId($viewId)" }
|
||||
whereJson <- tryo{(json.extract[PostTransactionWhereJSON])} ?~ {InvalidJsonFormat}
|
||||
correctCoordinates <- checkIfLocationPossible(whereJson.where.latitude, whereJson.where.longitude)
|
||||
if(addWhereTag(u.resourceUserId, viewId, now, whereJson.where.longitude, whereJson.where.latitude))
|
||||
if(addWhereTag(u.userPrimaryId, viewId, now, whereJson.where.longitude, whereJson.where.latitude))
|
||||
} yield {
|
||||
val successJson = SuccessMessage("where tag updated")
|
||||
successJsonResponse(Extraction.decompose(successJson))
|
||||
|
||||
@ -124,7 +124,7 @@ trait APIMethods220 {
|
||||
for {
|
||||
u <- cc.user ?~ UserNotLoggedIn
|
||||
account <- BankAccount(bankId, accountId) ?~! BankAccountNotFound
|
||||
_ <- booleanToBox(u.hasOwnerViewAccess(BankIdAccountId(account.bankId, account.accountId)), UserNoOwnerView +"userId : " + u.resourceUserId + ". account : " + accountId)
|
||||
_ <- booleanToBox(u.hasOwnerViewAccess(BankIdAccountId(account.bankId, account.accountId)), UserNoOwnerView +"userId : " + u.userPrimaryId + ". account : " + accountId)
|
||||
views <- Full(Views.views.vend.viewsForAccount(BankIdAccountId(account.bankId, account.accountId)))
|
||||
} yield {
|
||||
val viewsJSON = JSONFactory220.createViewsJSON(views)
|
||||
|
||||
@ -680,7 +680,7 @@ object JSONFactory220{
|
||||
def createUserCustomerViewJsonV220(user: ResourceUser, customer: Customer, view: View): CustomerViewJsonV220 = {
|
||||
|
||||
var basicUser = BasicUserJsonV220(
|
||||
user_id = user.resourceUserId.toString,
|
||||
user_id = user.userPrimaryId.toString,
|
||||
email = user.email.get,
|
||||
provider_id = user.idGivenByProvider,
|
||||
provider = user.provider,
|
||||
|
||||
@ -116,7 +116,7 @@ trait APIMethods300 {
|
||||
account <- Future { BankAccount(bankId, accountId, callContext) } map {
|
||||
x => fullBoxOrException(x ~> APIFailureNewStyle(BankAccountNotFound, 400, callContext.map(_.toLight)))
|
||||
} map { unboxFull(_) }
|
||||
_ <- Helper.booleanToFuture(failMsg = UserNoOwnerView +"userId : " + u.resourceUserId + ". account : " + accountId) {
|
||||
_ <- Helper.booleanToFuture(failMsg = UserNoOwnerView +"userId : " + u.userPrimaryId + ". account : " + accountId){
|
||||
u.hasOwnerViewAccess(BankIdAccountId(account.bankId, account.accountId))
|
||||
}
|
||||
} yield {
|
||||
|
||||
@ -1099,11 +1099,6 @@ trait Connector extends MdcLoggable{
|
||||
accountRoutingAddress: String
|
||||
): Box[BankAccount] = Failure(NotImplemented + currentMethodName)
|
||||
|
||||
//sets a user as an account owner/holder
|
||||
def setAccountHolder(bankAccountUID: BankIdAccountId, user: User): Unit = {
|
||||
AccountHolders.accountHolders.vend.createAccountHolder(user.resourceUserId.value, bankAccountUID.bankId.value, bankAccountUID.accountId.value)
|
||||
}
|
||||
|
||||
/**
|
||||
* sets a user as an account owner/holder, this maybe duplicated with
|
||||
* @ setAccountHolder(bankAccountUID: BankAccountUID, user: User)
|
||||
@ -1113,13 +1108,14 @@ trait Connector extends MdcLoggable{
|
||||
* @param accountId
|
||||
* @param account_owners
|
||||
*/
|
||||
@deprecated("we create new code.model.dataAccess.AuthUser.updateUserAccountViews for June2017 connector, try to use new instead of this","11 September 2018")
|
||||
def setAccountHolder(owner : String, bankId: BankId, accountId: AccountId, account_owners: List[String]) : Unit = {
|
||||
// if (account_owners.contains(owner)) { // No need for now, fix it later
|
||||
val resourceUserOwner = Users.users.vend.getUserByUserName(owner)
|
||||
resourceUserOwner match {
|
||||
case Full(owner) => {
|
||||
if ( ! accountOwnerExists(owner, bankId, accountId).openOrThrowException(attemptedToOpenAnEmptyBox)) {
|
||||
val holder = AccountHolders.accountHolders.vend.createAccountHolder(owner.resourceUserId.value, bankId.value, accountId.value)
|
||||
val holder = AccountHolders.accountHolders.vend.getOrCreateAccountHolder(owner, BankIdAccountId(bankId, accountId))
|
||||
logger.debug(s"Connector.setAccountHolder create account holder: $holder")
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
|
||||
Views.views.vend.addPermission(v.uid, user)
|
||||
//logger.info(s"------------> updated view ${v.uid} for resourceuser ${user} and account ${acc}")
|
||||
})
|
||||
existing_views.filterNot(_.users.contains(user.resourceUserId)).foreach (v => {
|
||||
existing_views.filterNot(_.users.contains(user.userPrimaryId)).foreach (v => {
|
||||
Views.views.vend.addPermission(v.uid, user)
|
||||
//logger.info(s"------------> added resourceuser ${user} to view ${v.uid} for account ${acc}")
|
||||
})
|
||||
@ -821,11 +821,6 @@ object KafkaMappedConnector extends Connector with KafkaHelper with MdcLoggable
|
||||
|
||||
}
|
||||
|
||||
//sets a user as an account owner/holder
|
||||
override def setAccountHolder(bankAccountUID: BankIdAccountId, user: User): Unit = {
|
||||
AccountHolders.accountHolders.vend.createAccountHolder(user.resourceUserId.value, bankAccountUID.bankId.value, bankAccountUID.accountId.value)
|
||||
}
|
||||
|
||||
private def createAccountIfNotExisting(bankId: BankId, accountId: AccountId, accountNumber: String,
|
||||
accountType: String, accountLabel: String, currency: String,
|
||||
balanceInSmallestCurrencyUnits: Long, accountHolderName: String) : BankAccount = {
|
||||
|
||||
@ -355,7 +355,7 @@ object KafkaMappedConnector_JVMcompatible extends Connector with KafkaHelper wit
|
||||
//3 get all the existing views.
|
||||
existingViewsNotBelongtoTheUser <- tryo {
|
||||
Views.views.vend.viewsForAccount(BankIdAccountId(BankId(acc.bankId), AccountId(acc.accountId)))
|
||||
.filterNot(_.users.contains(user.resourceUserId))
|
||||
.filterNot(_.users.contains(user.userPrimaryId))
|
||||
}
|
||||
} yield {
|
||||
//4 set Account link to User
|
||||
|
||||
@ -175,7 +175,7 @@ object ObpJvmMappedConnector extends Connector with MdcLoggable {
|
||||
Views.views.vend.addPermission(v.uid, user)
|
||||
logger.info(s"------------> updated view ${v.uid} for resourceuser ${user} and account ${acc}")
|
||||
})
|
||||
existing_views.filterNot(_.users.contains(user.resourceUserId)).foreach (v => {
|
||||
existing_views.filterNot(_.users.contains(user.userPrimaryId)).foreach (v => {
|
||||
Views.views.vend.addPermission(v.uid, user)
|
||||
logger.info(s"------------> added resourceuser ${user} to view ${v.uid} for account ${acc}")
|
||||
})
|
||||
|
||||
@ -228,7 +228,7 @@ trait KafkaMappedConnector_vMar2017 extends Connector with KafkaHelper with MdcL
|
||||
Views.views.vend.addPermission(v.uid, user)
|
||||
logger.info(s"------------> updated view ${v.uid} for resourceuser ${user} and account ${acc}")
|
||||
})
|
||||
existing_views.filterNot(_.users.contains(user.resourceUserId)).foreach (v => {
|
||||
existing_views.filterNot(_.users.contains(user.userPrimaryId)).foreach (v => {
|
||||
Views.views.vend.addPermission(v.uid, user)
|
||||
logger.info(s"------------> added resourceuser ${user} to view ${v.uid} for account ${acc}")
|
||||
})
|
||||
@ -1444,10 +1444,6 @@ trait KafkaMappedConnector_vMar2017 extends Connector with KafkaHelper with MdcL
|
||||
|
||||
}
|
||||
|
||||
//sets a user as an account owner/holder
|
||||
override def setAccountHolder(bankAccountUID: BankIdAccountId, user: User): Unit = {
|
||||
AccountHolders.accountHolders.vend.createAccountHolder(user.resourceUserId.value, bankAccountUID.bankId.value, bankAccountUID.accountId.value)
|
||||
}
|
||||
|
||||
private def createAccountIfNotExisting(bankId: BankId, accountId: AccountId, accountNumber: String,
|
||||
accountType: String, accountLabel: String, currency: String,
|
||||
|
||||
@ -11,7 +11,7 @@ object MappedCustomerMessageProvider extends CustomerMessageProvider {
|
||||
|
||||
override def getMessages(user: User, bankId : BankId): List[CustomerMessage] = {
|
||||
MappedCustomerMessage.findAll(
|
||||
By(MappedCustomerMessage.user, user.resourceUserId.value),
|
||||
By(MappedCustomerMessage.user, user.userPrimaryId.value),
|
||||
By(MappedCustomerMessage.bank, bankId.value),
|
||||
OrderBy(MappedCustomerMessage.updatedAt, Descending))
|
||||
}
|
||||
@ -22,7 +22,7 @@ object MappedCustomerMessageProvider extends CustomerMessageProvider {
|
||||
.mFromDepartment(fromDepartment)
|
||||
.mFromPerson(fromPerson)
|
||||
.mMessage(message)
|
||||
.user(user.resourceUserId.value)
|
||||
.user(user.userPrimaryId.value)
|
||||
.bank(bankId.value).save()
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ object MappedMeetingProvider extends MeetingProvider {
|
||||
val createdMeeting = MappedMeeting.create
|
||||
.mBankId(bankId.value.toString)
|
||||
//.mStaffUserId(staffUser.apiId.value)
|
||||
.mCustomerUserId(customerUser.resourceUserId.value)
|
||||
.mCustomerUserId(customerUser.userPrimaryId.value)
|
||||
.mProviderId(providerId)
|
||||
.mPurposeId(purposeId)
|
||||
.mWhen(when)
|
||||
|
||||
@ -23,7 +23,7 @@ object Comments extends SimpleInjector {
|
||||
trait Comments {
|
||||
|
||||
def getComments(bankId : BankId, accountId : AccountId, transactionId : TransactionId)(viewId : ViewId) : List[Comment]
|
||||
def addComment(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserId, viewId : ViewId, text : String, datePosted : Date) : Box[Comment]
|
||||
def addComment(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserPrimaryId, viewId : ViewId, text : String, datePosted : Date) : Box[Comment]
|
||||
//TODO: should commentId be unique among all comments, removing the need for the other parameters?
|
||||
def deleteComment(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(commentId : String) : Box[Boolean]
|
||||
def bulkDeleteComments(bankId: BankId, accountId: AccountId) : Boolean
|
||||
@ -32,7 +32,7 @@ trait Comments {
|
||||
|
||||
class RemotedataCommentsCaseClasses {
|
||||
case class getComments(bankId : BankId, accountId : AccountId, transactionId : TransactionId, viewId : ViewId)
|
||||
case class addComment(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserId, viewId : ViewId, text : String, datePosted : Date)
|
||||
case class addComment(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserPrimaryId, viewId : ViewId, text : String, datePosted : Date)
|
||||
case class deleteComment(bankId : BankId, accountId : AccountId, transactionId: TransactionId, commentId : String)
|
||||
case class bulkDeleteComments(bankId: BankId, accountId: AccountId)
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ object MappedComments extends Comments {
|
||||
}
|
||||
}
|
||||
|
||||
override def addComment(bankId: BankId, accountId: AccountId, transactionId: TransactionId)(userId: UserId, viewId: ViewId, text: String, datePosted: Date): Box[Comment] = {
|
||||
override def addComment(bankId: BankId, accountId: AccountId, transactionId: TransactionId)(userId: UserPrimaryId, viewId: ViewId, text: String, datePosted: Date): Box[Comment] = {
|
||||
val metadateViewId = Views.views.vend.getMetadataViewId(BankIdAccountId(bankId, accountId), viewId)
|
||||
tryo {
|
||||
MappedComment.create
|
||||
|
||||
@ -16,7 +16,7 @@ private object MongoTransactionComments extends Comments {
|
||||
def getComments(bankId : BankId, accountId : AccountId, transactionId : TransactionId)(viewId : ViewId) : List[Comment] = {
|
||||
OBPComment.findAll(bankId, accountId, transactionId, viewId)
|
||||
}
|
||||
def addComment(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserId, viewId : ViewId, text : String, datePosted : Date) : Box[Comment] = {
|
||||
def addComment(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserPrimaryId, viewId : ViewId, text : String, datePosted : Date) : Box[Comment] = {
|
||||
OBPComment.createRecord.userId(userId.value).
|
||||
transactionId(transactionId.value).
|
||||
accountId(accountId.value).
|
||||
|
||||
@ -69,8 +69,8 @@ trait Counterparties {
|
||||
def addImageURL(counterpartyId : String, imageUrl: String): Box[Boolean]
|
||||
def addOpenCorporatesURL(counterpartyId : String, imageUrl: String): Box[Boolean]
|
||||
def addMoreInfo(counterpartyId : String, moreInfo: String): Box[Boolean]
|
||||
def addPhysicalLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean]
|
||||
def addCorporateLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean]
|
||||
def addPhysicalLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean]
|
||||
def addCorporateLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean]
|
||||
def deletePhysicalLocation(counterpartyId : String): Box[Boolean]
|
||||
def deleteCorporateLocation(counterpartyId : String): Box[Boolean]
|
||||
def getCorporateLocation(counterpartyId : String): Box[GeoTag]
|
||||
@ -170,9 +170,9 @@ class RemotedataCounterpartiesCaseClasses {
|
||||
|
||||
case class addMoreInfo(counterpartyId : String, moreInfo: String)
|
||||
|
||||
case class addPhysicalLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double)
|
||||
case class addPhysicalLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double)
|
||||
|
||||
case class addCorporateLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double)
|
||||
case class addCorporateLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double)
|
||||
|
||||
case class deletePhysicalLocation(counterpartyId : String)
|
||||
|
||||
|
||||
@ -267,11 +267,11 @@ object MapperCounterparties extends Counterparties with MdcLoggable {
|
||||
getCounterpartyMetadata(counterpartyId).map(_.moreInfo(moreInfo).save())
|
||||
}
|
||||
|
||||
override def addPhysicalLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] = {
|
||||
override def addPhysicalLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] = {
|
||||
getCounterpartyMetadata(counterpartyId).map(_.setPhysicalLocation(userId, datePosted, longitude, latitude))
|
||||
}
|
||||
|
||||
override def addCorporateLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] = {
|
||||
override def addCorporateLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] = {
|
||||
getCounterpartyMetadata(counterpartyId).map(_.setCorporateLocation(userId, datePosted, longitude, latitude))
|
||||
}
|
||||
|
||||
@ -330,7 +330,7 @@ class MappedCounterpartyMetadata extends CounterpartyMetadata with LongKeyedMapp
|
||||
}.getOrElse(false)
|
||||
|
||||
private def setWhere(whereTag : Box[MappedCounterpartyWhereTag])
|
||||
(userId: UserId, datePosted : Date, longitude : Double, latitude : Double) : Box[MappedCounterpartyWhereTag] = {
|
||||
(userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double) : Box[MappedCounterpartyWhereTag] = {
|
||||
val toUpdate = whereTag match {
|
||||
case Full(c) => c
|
||||
case _ => MappedCounterpartyWhereTag.create
|
||||
@ -346,14 +346,14 @@ class MappedCounterpartyMetadata extends CounterpartyMetadata with LongKeyedMapp
|
||||
}
|
||||
}
|
||||
|
||||
def setCorporateLocation(userId: UserId, datePosted : Date, longitude : Double, latitude : Double) : Boolean = {
|
||||
def setCorporateLocation(userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double) : Boolean = {
|
||||
//save where tag
|
||||
val savedWhere = setWhere(corporateLocation.obj)(userId, datePosted, longitude, latitude)
|
||||
//set where tag for counterparty
|
||||
savedWhere.map(location => trySave{corporateLocation(location)}).getOrElse(false)
|
||||
}
|
||||
|
||||
def setPhysicalLocation(userId: UserId, datePosted : Date, longitude : Double, latitude : Double) : Boolean = {
|
||||
def setPhysicalLocation(userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double) : Boolean = {
|
||||
//save where tag
|
||||
val savedWhere = setWhere(physicalLocation.obj)(userId, datePosted, longitude, latitude)
|
||||
//set where tag for counterparty
|
||||
@ -373,8 +373,8 @@ class MappedCounterpartyMetadata extends CounterpartyMetadata with LongKeyedMapp
|
||||
physicalLocation.obj
|
||||
override def getUrl: String = url.get
|
||||
|
||||
override val addPhysicalLocation: (UserId, Date, Double, Double) => Boolean = setPhysicalLocation _
|
||||
override val addCorporateLocation: (UserId, Date, Double, Double) => Boolean = setCorporateLocation _
|
||||
override val addPhysicalLocation: (UserPrimaryId, Date, Double, Double) => Boolean = setPhysicalLocation _
|
||||
override val addCorporateLocation: (UserPrimaryId, Date, Double, Double) => Boolean = setCorporateLocation _
|
||||
override val addPrivateAlias: (String) => Boolean = (x) =>
|
||||
trySave{privateAlias(x)}
|
||||
override val addURL: (String) => Boolean = (x) =>
|
||||
|
||||
@ -143,8 +143,8 @@ object MongoCounterparties extends Counterparties with MdcLoggable {
|
||||
override def addImageURL(counterpartyId : String, imageUrl: String): Box[Boolean] = ???
|
||||
override def addOpenCorporatesURL(counterpartyId : String, url: String): Box[Boolean] = ???
|
||||
override def addMoreInfo(counterpartyId : String, moreInfo: String): Box[Boolean] = ???
|
||||
override def addPhysicalLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] = ???
|
||||
override def addCorporateLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] = ???
|
||||
override def addPhysicalLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] = ???
|
||||
override def addCorporateLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] = ???
|
||||
override def deletePhysicalLocation(counterpartyId : String): Box[Boolean] = ???
|
||||
override def deleteCorporateLocation(counterpartyId : String): Box[Boolean] = ???
|
||||
override def getCorporateLocation(counterpartyId : String): Box[GeoTag] = ???
|
||||
|
||||
@ -5,7 +5,7 @@ import code.util.Helper
|
||||
import net.liftweb.mongodb.record.{BsonMetaRecord, BsonRecord, MongoMetaRecord, MongoRecord}
|
||||
import net.liftweb.mongodb.record.field.ObjectIdPk
|
||||
import net.liftweb.record.field.StringField
|
||||
import code.model.{CounterpartyMetadata, UserId, ViewId, GeoTag}
|
||||
import code.model.{CounterpartyMetadata, UserPrimaryId, ViewId, GeoTag}
|
||||
//TODO: this should be private
|
||||
class Metadata private() extends CounterpartyMetadata with MongoRecord[Metadata] with ObjectIdPk[Metadata] {
|
||||
import net.liftweb.mongodb.record.field.BsonRecordField
|
||||
@ -32,7 +32,7 @@ class Metadata private() extends CounterpartyMetadata with MongoRecord[Metadata]
|
||||
object corporateLocation extends BsonRecordField(this, OBPGeoTag)
|
||||
object physicalLocation extends BsonRecordField(this, OBPGeoTag)
|
||||
|
||||
def addCorporateLocationFn(userId: UserId, datePosted : Date, longitude : Double, latitude : Double) : Boolean = {
|
||||
def addCorporateLocationFn(userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double) : Boolean = {
|
||||
val newTag = OBPGeoTag.createRecord.
|
||||
userId(userId.value).
|
||||
date(datePosted).
|
||||
@ -48,7 +48,7 @@ class Metadata private() extends CounterpartyMetadata with MongoRecord[Metadata]
|
||||
true
|
||||
}
|
||||
|
||||
def addPhysicalLocationFn(userId: UserId, datePosted : Date, longitude : Double, latitude : Double) : Boolean = {
|
||||
def addPhysicalLocationFn(userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double) : Boolean = {
|
||||
val newTag = OBPGeoTag.createRecord.
|
||||
userId(userId.value).
|
||||
date(datePosted).
|
||||
@ -95,8 +95,8 @@ class Metadata private() extends CounterpartyMetadata with MongoRecord[Metadata]
|
||||
//so we a true
|
||||
true
|
||||
})
|
||||
override val addPhysicalLocation: (UserId, Date, Double, Double) => Boolean = addPhysicalLocationFn _
|
||||
override val addCorporateLocation: (UserId, Date, Double, Double) => Boolean = addCorporateLocationFn _
|
||||
override val addPhysicalLocation: (UserPrimaryId, Date, Double, Double) => Boolean = addPhysicalLocationFn _
|
||||
override val addCorporateLocation: (UserPrimaryId, Date, Double, Double) => Boolean = addCorporateLocationFn _
|
||||
override val addMoreInfo: (String) => Boolean = (text => {
|
||||
moreInfo(text).saveTheRecord()
|
||||
//the save method does not return a Boolean to inform about the saving state,
|
||||
|
||||
@ -18,7 +18,7 @@ object MappedTags extends Tags {
|
||||
}
|
||||
|
||||
override def addTag(bankId: BankId, accountId: AccountId, transactionId: TransactionId)
|
||||
(userId: UserId, viewId: ViewId, tagText: String, datePosted: Date): Box[TransactionTag] = {
|
||||
(userId: UserPrimaryId, viewId: ViewId, tagText: String, datePosted: Date): Box[TransactionTag] = {
|
||||
val metadateViewId = Views.views.vend.getMetadataViewId(BankIdAccountId(bankId, accountId), viewId)
|
||||
tryo{
|
||||
MappedTag.create
|
||||
|
||||
@ -15,7 +15,7 @@ private object MongoTransactionTags extends Tags {
|
||||
def getTags(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(viewId : ViewId) : List[TransactionTag] = {
|
||||
OBPTag.findAll(bankId, accountId, transactionId, viewId)
|
||||
}
|
||||
def addTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserId, viewId : ViewId, tagText : String, datePosted : Date) : Box[TransactionTag] = {
|
||||
def addTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserPrimaryId, viewId : ViewId, tagText : String, datePosted : Date) : Box[TransactionTag] = {
|
||||
OBPTag.createRecord.
|
||||
bankId(bankId.value).
|
||||
accountId(accountId.value).
|
||||
|
||||
@ -23,7 +23,7 @@ object Tags extends SimpleInjector {
|
||||
trait Tags {
|
||||
|
||||
def getTags(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(viewId : ViewId) : List[TransactionTag]
|
||||
def addTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserId, viewId : ViewId, tagText : String, datePosted : Date) : Box[TransactionTag]
|
||||
def addTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserPrimaryId, viewId : ViewId, tagText : String, datePosted : Date) : Box[TransactionTag]
|
||||
//TODO: viewId? should tagId always be unique -> in that case bankId, accountId, and transactionId would not be required
|
||||
def deleteTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(tagId : String) : Box[Boolean]
|
||||
def bulkDeleteTags(bankId: BankId, accountId: AccountId) : Boolean
|
||||
@ -32,7 +32,7 @@ trait Tags {
|
||||
|
||||
class RemotedataTagsCaseClasses{
|
||||
case class getTags(bankId : BankId, accountId : AccountId, transactionId: TransactionId, viewId : ViewId)
|
||||
case class addTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserId, viewId : ViewId, tagText : String, datePosted : Date)
|
||||
case class addTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserPrimaryId, viewId : ViewId, tagText : String, datePosted : Date)
|
||||
case class deleteTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId, tagId : String)
|
||||
case class bulkDeleteTags(bankId: BankId, accountId: AccountId)
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ object MapperTransactionImages extends TransactionImages {
|
||||
}
|
||||
|
||||
override def addTransactionImage(bankId: BankId, accountId: AccountId, transactionId: TransactionId)
|
||||
(userId: UserId, viewId: ViewId, description: String, datePosted: Date, imageURL: String): Box[TransactionImage] = {
|
||||
(userId: UserPrimaryId, viewId: ViewId, description: String, datePosted: Date, imageURL: String): Box[TransactionImage] = {
|
||||
val metadateViewId = Views.views.vend.getMetadataViewId(BankIdAccountId(bankId, accountId), viewId)
|
||||
tryo {
|
||||
MappedTransactionImage.create
|
||||
|
||||
@ -21,7 +21,7 @@ private object MongoTransactionImages extends TransactionImages with MdcLoggable
|
||||
}
|
||||
|
||||
def addTransactionImage(bankId : BankId, accountId : AccountId, transactionId: TransactionId)
|
||||
(userId: UserId, viewId : ViewId, description : String, datePosted : Date, imageURL: String) : Box[TransactionImage] = {
|
||||
(userId: UserPrimaryId, viewId : ViewId, description : String, datePosted : Date, imageURL: String) : Box[TransactionImage] = {
|
||||
OBPTransactionImage.createRecord.
|
||||
bankId(bankId.value).
|
||||
accountId(accountId.value).
|
||||
|
||||
@ -25,7 +25,7 @@ trait TransactionImages {
|
||||
def getImagesForTransaction(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(viewId : ViewId) : List[TransactionImage]
|
||||
|
||||
def addTransactionImage(bankId : BankId, accountId : AccountId, transactionId: TransactionId)
|
||||
(userId: UserId, viewId : ViewId, description : String, datePosted : Date, imageURL: String) : Box[TransactionImage]
|
||||
(userId: UserPrimaryId, viewId : ViewId, description : String, datePosted : Date, imageURL: String) : Box[TransactionImage]
|
||||
|
||||
def deleteTransactionImage(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(imageId : String) : Box[Boolean]
|
||||
|
||||
@ -35,7 +35,7 @@ trait TransactionImages {
|
||||
|
||||
class RemotedataTransactionImagesCaseClasses {
|
||||
case class getImagesForTransaction(bankId : BankId, accountId : AccountId, transactionId: TransactionId, viewId : ViewId)
|
||||
case class addTransactionImage(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserId, viewId : ViewId, description : String, datePosted : Date, imageURL: String)
|
||||
case class addTransactionImage(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserPrimaryId, viewId : ViewId, description : String, datePosted : Date, imageURL: String)
|
||||
case class deleteTransactionImage(bankId : BankId, accountId : AccountId, transactionId: TransactionId, imageId : String)
|
||||
case class bulkDeleteTransactionImage(bankId: BankId, accountId: AccountId)
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ object MapperWhereTags extends WhereTags {
|
||||
}
|
||||
|
||||
override def addWhereTag(bankId: BankId, accountId: AccountId, transactionId: TransactionId)
|
||||
(userId: UserId, viewId: ViewId, datePosted: Date, longitude: Double, latitude: Double): Boolean = {
|
||||
(userId: UserPrimaryId, viewId: ViewId, datePosted: Date, longitude: Double, latitude: Double): Boolean = {
|
||||
|
||||
val metadateViewId = Views.views.vend.getMetadataViewId(BankIdAccountId(bankId, accountId), viewId)
|
||||
val found = findMappedWhereTag(bankId, accountId, transactionId, ViewId(metadateViewId))
|
||||
|
||||
@ -10,7 +10,7 @@ import code.util.Helper.MdcLoggable
|
||||
private object MongoTransactionWhereTags extends WhereTags with MdcLoggable {
|
||||
|
||||
def addWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)
|
||||
(userId: UserId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double) : Boolean = {
|
||||
(userId: UserPrimaryId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double) : Boolean = {
|
||||
|
||||
//avoiding upsert for now as it seemed to behave a little strangely
|
||||
val findQuery = OBPWhereTag.getFindQuery(bankId, accountId, transactionId, viewId)
|
||||
|
||||
@ -24,7 +24,7 @@ trait WhereTags {
|
||||
|
||||
//TODO: it probably makes more sense for this to return Box[GeoTag]. Leaving it as a Boolean for now...
|
||||
def addWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)
|
||||
(userId: UserId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double) : Boolean
|
||||
(userId: UserPrimaryId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double) : Boolean
|
||||
|
||||
//TODO: would be nicer to change this to return Box[Unit] like in e.g. comments. Or perhaps change the way the other ones work
|
||||
//instead, with the end effect of keeping them consistent. Leaving it as a Boolean for now...
|
||||
@ -37,7 +37,7 @@ trait WhereTags {
|
||||
}
|
||||
|
||||
class RemotedataWhereTagsCaseClasses {
|
||||
case class addWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double)
|
||||
case class addWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserPrimaryId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double)
|
||||
case class deleteWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId, viewId : ViewId)
|
||||
case class getWhereTagForTransaction(bankId : BankId, accountId : AccountId, transactionId: TransactionId, viewId : ViewId)
|
||||
case class bulkDeleteWhereTags(bankId: BankId, accountId: AccountId)
|
||||
|
||||
@ -32,11 +32,13 @@ Berlin 13359, Germany
|
||||
package code.model
|
||||
|
||||
import java.util.Date
|
||||
|
||||
import code.api.util.ErrorMessages._
|
||||
import code.accountholder.AccountHolders
|
||||
import code.api.util.APIUtil.hasEntitlement
|
||||
import code.api.util.{APIUtil, ApiRole, CallContext, ErrorMessages}
|
||||
import code.bankconnectors.{Connector, OBPQueryParam}
|
||||
import code.customer.Customer
|
||||
import code.metadata.comments.Comments
|
||||
import code.metadata.counterparties.{Counterparties, CounterpartyTrait}
|
||||
import code.metadata.narrative.Narrative
|
||||
@ -309,14 +311,26 @@ trait BankAccount extends MdcLoggable {
|
||||
Failure(UserNoOwnerView+"user's email : " + user.emailAddress + ". account : " + accountId, Empty, Empty)
|
||||
}
|
||||
}
|
||||
|
||||
final def owners: Set[User] = {
|
||||
|
||||
/**
|
||||
* This will return all the obp users who has the link in code.accountholder.MapperAccountHolders.
|
||||
* This field is tricky, it is belong to Trait `BankAccount` directly, not a filed in `MappedBankAccount`
|
||||
* So this method always need call the Model `MapperAccountHolders`, and get the data there.
|
||||
* Note:
|
||||
* We need manully create records for`MapperAccountHolders`, then we can get the data back.
|
||||
* each time when we create a account, we need call `getOrCreateAccountHolder`
|
||||
* eg1: code.sandbox.OBPDataImport#setAccountOwner used in createSandBox
|
||||
* eg2: code.model.dataAccess.AuthUser#updateUserAccountViews used in Adapter create accounts.
|
||||
* eg3: code.bankconnectors.Connector#setAccountHolder used in api level create account.
|
||||
* @return
|
||||
*/
|
||||
final def userOwners: Set[User] = {
|
||||
val accountHolders = AccountHolders.accountHolders.vend.getAccountHolders(bankId, accountId)
|
||||
if(accountHolders.isEmpty) {
|
||||
//account holders are not all set up in the db yet, so we might not get any back.
|
||||
//In this case, we just use the previous behaviour, which did not return very much information at all
|
||||
Set(new User {
|
||||
val resourceUserId = UserId(-1)
|
||||
val userPrimaryId = UserPrimaryId(-1)
|
||||
val userId = ""
|
||||
val idGivenByProvider = ""
|
||||
val provider = ""
|
||||
|
||||
@ -126,7 +126,7 @@ trait CounterpartyMetadata {
|
||||
* @param: longitude
|
||||
* @param: latitude
|
||||
*/
|
||||
val addCorporateLocation: (UserId, Date, Double, Double) => Boolean
|
||||
val addCorporateLocation: (UserPrimaryId, Date, Double, Double) => Boolean
|
||||
val deleteCorporateLocation: () => Boolean
|
||||
/**
|
||||
* @param: userId
|
||||
@ -134,7 +134,7 @@ trait CounterpartyMetadata {
|
||||
* @param: longitude
|
||||
* @param: latitude
|
||||
*/
|
||||
val addPhysicalLocation: (UserId, Date, Double, Double) => Boolean
|
||||
val addPhysicalLocation: (UserPrimaryId, Date, Double, Double) => Boolean
|
||||
val deletePhysicalLocation: () => Boolean
|
||||
val addPublicAlias: (String) => Boolean
|
||||
val addPrivateAlias: (String) => Boolean
|
||||
@ -154,7 +154,7 @@ class TransactionMetadata(
|
||||
* @param: text
|
||||
* @param: datePosted
|
||||
*/
|
||||
val addComment : (UserId, ViewId, String, Date) => Box[Comment],
|
||||
val addComment : (UserPrimaryId, ViewId, String, Date) => Box[Comment],
|
||||
/**
|
||||
* @param: commentId
|
||||
*/
|
||||
@ -167,7 +167,7 @@ class TransactionMetadata(
|
||||
* @param: tag
|
||||
* @param: datePosted
|
||||
*/
|
||||
val addTag: (UserId, ViewId, String, Date) => Box[TransactionTag],
|
||||
val addTag: (UserPrimaryId, ViewId, String, Date) => Box[TransactionTag],
|
||||
/**
|
||||
* @param: tagId
|
||||
*/
|
||||
@ -180,7 +180,7 @@ class TransactionMetadata(
|
||||
* @param: datePosted
|
||||
* @param: imageURL
|
||||
*/
|
||||
val addImage : (UserId, ViewId, String, Date, String) => Box[TransactionImage],
|
||||
val addImage : (UserPrimaryId, ViewId, String, Date, String) => Box[TransactionImage],
|
||||
/**
|
||||
* @param: imageId
|
||||
*/
|
||||
@ -200,7 +200,7 @@ class TransactionMetadata(
|
||||
* @param: longitude
|
||||
* @param: latitude
|
||||
*/
|
||||
val addWhereTag : (UserId, ViewId, Date, Double, Double) => Boolean,
|
||||
val addWhereTag : (UserPrimaryId, ViewId, Date, Double, Double) => Boolean,
|
||||
/**
|
||||
* @param: viewId
|
||||
*/
|
||||
|
||||
@ -108,16 +108,16 @@ class ModeratedTransactionMetadata(
|
||||
val ownerComment : Moderated[String],
|
||||
val addOwnerComment : Moderated[(String => Boolean)],
|
||||
val comments : Moderated[List[Comment]],
|
||||
val addComment: Moderated[(UserId, ViewId, String, Date) => Box[Comment]],
|
||||
val addComment: Moderated[(UserPrimaryId, ViewId, String, Date) => Box[Comment]],
|
||||
private val deleteComment: Moderated[(String) => Box[Boolean]],
|
||||
val tags : Moderated[List[TransactionTag]],
|
||||
val addTag : Moderated[(UserId, ViewId, String, Date) => Box[TransactionTag]],
|
||||
val addTag : Moderated[(UserPrimaryId, ViewId, String, Date) => Box[TransactionTag]],
|
||||
private val deleteTag : Moderated[(String) => Box[Boolean]],
|
||||
val images : Moderated[List[TransactionImage]],
|
||||
val addImage : Moderated[(UserId, ViewId, String, Date, String) => Box[TransactionImage]],
|
||||
val addImage : Moderated[(UserPrimaryId, ViewId, String, Date, String) => Box[TransactionImage]],
|
||||
private val deleteImage : Moderated[String => Box[Boolean]],
|
||||
val whereTag : Moderated[Option[GeoTag]],
|
||||
val addWhereTag : Moderated[(UserId, ViewId, Date, Double, Double) => Boolean],
|
||||
val addWhereTag : Moderated[(UserPrimaryId, ViewId, Date, Double, Double) => Boolean],
|
||||
private val deleteWhereTag : Moderated[(ViewId) => Boolean]
|
||||
){
|
||||
|
||||
@ -339,8 +339,8 @@ class ModeratedOtherBankAccountMetadata(
|
||||
val addURL : Moderated[(String) => Boolean],
|
||||
val addImageURL : Moderated[(String) => Boolean],
|
||||
val addOpenCorporatesURL : Moderated[(String) => Boolean],
|
||||
val addCorporateLocation : Moderated[(UserId, Date, Double, Double) => Boolean],
|
||||
val addPhysicalLocation : Moderated[(UserId, Date, Double, Double) => Boolean],
|
||||
val addCorporateLocation : Moderated[(UserPrimaryId, Date, Double, Double) => Boolean],
|
||||
val addPhysicalLocation : Moderated[(UserPrimaryId, Date, Double, Double) => Boolean],
|
||||
val addPublicAlias : Moderated[(String) => Boolean],
|
||||
val addPrivateAlias : Moderated[(String) => Boolean],
|
||||
val deleteCorporateLocation : Moderated[() => Boolean],
|
||||
|
||||
@ -45,16 +45,38 @@ import code.users.Users
|
||||
import code.util.Helper.MdcLoggable
|
||||
import net.liftweb.mapper.By
|
||||
|
||||
case class UserId(val value : Long) {
|
||||
case class UserPrimaryId(val value : Long) {
|
||||
override def toString = value.toString
|
||||
}
|
||||
|
||||
|
||||
// TODO Document clearly the difference between this and AuthUser
|
||||
|
||||
/**
|
||||
* An O-R mapped "User" class that includes first name, last name, password
|
||||
*
|
||||
* 1 AuthUser : is used for authentication, only for webpage Login in stuff
|
||||
* 1) It is MegaProtoUser, has lots of methods for validation username, password, email ....
|
||||
* Such as lost password, reset password .....
|
||||
* Lift have some helper methods to make these things easily.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 2 ResourceUser: is only a normal LongKeyedMapper
|
||||
* 1) All the accounts, transactions ,roles, views, accountHolders, customers... should be linked to ResourceUser.userId_ field.
|
||||
* 2) The consumer keys, tokens are also belong ResourceUser
|
||||
*
|
||||
*
|
||||
* 3 RelationShips:
|
||||
* 1)When `Sign up` new user --> create AuthUser --> call AuthUser.save() --> create ResourceUser user.
|
||||
* They share the same username and email.
|
||||
* 2)AuthUser `user` field as the Foreign Key to link to Resource User.
|
||||
* one AuthUser <---> one ResourceUser
|
||||
*
|
||||
*/
|
||||
trait User extends MdcLoggable {
|
||||
|
||||
def resourceUserId : UserId
|
||||
def userPrimaryId : UserPrimaryId
|
||||
/**
|
||||
* This will be a UUID for Resource User Docment
|
||||
*/
|
||||
def userId: String
|
||||
|
||||
def idGivenByProvider: String
|
||||
@ -88,7 +110,7 @@ trait User extends MdcLoggable {
|
||||
*/
|
||||
final def hasViewAccess(view: View): Boolean ={
|
||||
val viewImpl = view.asInstanceOf[ViewImpl]
|
||||
!(ViewPrivileges.count(By(ViewPrivileges.user, this.resourceUserId.value), By(ViewPrivileges.view, viewImpl.id)) == 0)
|
||||
!(ViewPrivileges.count(By(ViewPrivileges.user, this.userPrimaryId.value), By(ViewPrivileges.view, viewImpl.id)) == 0)
|
||||
}
|
||||
|
||||
def assignedEntitlements : List[Entitlement] = {
|
||||
|
||||
@ -403,7 +403,7 @@ trait View {
|
||||
else
|
||||
None
|
||||
|
||||
val addWhereTagFunc : Option[(UserId, ViewId, Date, Double, Double) => Boolean] =
|
||||
val addWhereTagFunc : Option[(UserPrimaryId, ViewId, Date, Double, Double) => Boolean] =
|
||||
if(canAddWhereTag)
|
||||
Some(transaction.metadata.addWhereTag)
|
||||
else
|
||||
@ -609,7 +609,7 @@ trait View {
|
||||
def moderateAccount(bankAccount: BankAccount) : Box[ModeratedBankAccount] = {
|
||||
if(canSeeTransactionThisBankAccount)
|
||||
{
|
||||
val owners : Set[User] = if(canSeeBankAccountOwners) bankAccount.owners else Set()
|
||||
val owners : Set[User] = if(canSeeBankAccountOwners) bankAccount.userOwners else Set()
|
||||
val balance = if(canSeeBankAccountBalance) bankAccount.balance.toString else ""
|
||||
val accountType = if(canSeeBankAccountType) Some(bankAccount.accountType) else None
|
||||
val currency = if(canSeeBankAccountCurrency) Some(bankAccount.currency) else None
|
||||
|
||||
@ -59,9 +59,6 @@ import scala.collection.immutable.List
|
||||
/**
|
||||
* An O-R mapped "User" class that includes first name, last name, password
|
||||
*
|
||||
*
|
||||
* // TODO Document the difference between this and AuthUser / ResourceUser
|
||||
*
|
||||
* 1 AuthUser : is used for authentication, only for webpage Login in stuff
|
||||
* 1) It is MegaProtoUser, has lots of methods for validation username, password, email ....
|
||||
* Such as lost password, reset password .....
|
||||
@ -79,7 +76,6 @@ import scala.collection.immutable.List
|
||||
* They share the same username and email.
|
||||
* 2)AuthUser `user` field as the Foreign Key to link to Resource User.
|
||||
* one AuthUser <---> one ResourceUser
|
||||
*
|
||||
*
|
||||
*/
|
||||
class AuthUser extends MegaProtoUser[AuthUser] with Logger {
|
||||
|
||||
@ -48,6 +48,7 @@ package com.tesobe.model {
|
||||
|
||||
package code.model.dataAccess {
|
||||
|
||||
import code.accountholder.AccountHolders
|
||||
import code.api.util.APIUtil
|
||||
import code.bankconnectors.Connector
|
||||
import code.model._
|
||||
@ -90,7 +91,7 @@ import net.liftweb.common.{Failure, Full}
|
||||
*/
|
||||
def setAsOwner(bankId : BankId, accountId : AccountId, user: User): Unit = {
|
||||
createOwnerView(bankId, accountId, user)
|
||||
Connector.connector.vend.setAccountHolder(BankIdAccountId(bankId, accountId), user)
|
||||
val accountHolder = AccountHolders.accountHolders.vend.getOrCreateAccountHolder(user: User, BankIdAccountId(bankId, accountId))
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,7 +111,7 @@ import net.liftweb.common.{Failure, Full}
|
||||
existingOwnerView match {
|
||||
case Full(v) => {
|
||||
logger.debug(s"account $accountId at bank $bankId has already an owner view")
|
||||
v.users.toList.find(_.resourceUserId == user.resourceUserId) match {
|
||||
v.users.toList.find(_.userPrimaryId == user.userPrimaryId) match {
|
||||
case Some(u) => {
|
||||
logger.debug(s"user ${user.emailAddress} has already an owner view access on account $accountId at bank $bankId")
|
||||
}
|
||||
|
||||
@ -32,13 +32,32 @@ Berlin 13359, Germany
|
||||
package code.model.dataAccess
|
||||
|
||||
import code.api.util.APIUtil
|
||||
import code.model.{User, UserId}
|
||||
import code.model.{User, UserPrimaryId}
|
||||
import code.util.MappedUUID
|
||||
import net.liftweb.mapper._
|
||||
|
||||
/**
|
||||
* Refer to AuthUser, see the difference between AuthUser and ResourceUser
|
||||
*/
|
||||
* An O-R mapped "User" class that includes first name, last name, password
|
||||
*
|
||||
* 1 AuthUser : is used for authentication, only for webpage Login in stuff
|
||||
* 1) It is MegaProtoUser, has lots of methods for validation username, password, email ....
|
||||
* Such as lost password, reset password .....
|
||||
* Lift have some helper methods to make these things easily.
|
||||
*
|
||||
*
|
||||
*
|
||||
* 2 ResourceUser: is only a normal LongKeyedMapper
|
||||
* 1) All the accounts, transactions ,roles, views, accountHolders, customers... should be linked to ResourceUser.userId_ field.
|
||||
* 2) The consumer keys, tokens are also belong ResourceUser
|
||||
*
|
||||
*
|
||||
* 3 RelationShips:
|
||||
* 1)When `Sign up` new user --> create AuthUser --> call AuthUser.save() --> create ResourceUser user.
|
||||
* They share the same username and email.
|
||||
* 2)AuthUser `user` field as the Foreign Key to link to Resource User.
|
||||
* one AuthUser <---> one ResourceUser
|
||||
*
|
||||
*/
|
||||
class ResourceUser extends LongKeyedMapper[ResourceUser] with User with ManyToMany with OneToMany[Long, ResourceUser]{
|
||||
def getSingleton = ResourceUser
|
||||
def primaryKeyField = id
|
||||
@ -68,7 +87,7 @@ class ResourceUser extends LongKeyedMapper[ResourceUser] with User with ManyToMa
|
||||
}
|
||||
|
||||
def idGivenByProvider = providerId.get
|
||||
def resourceUserId = UserId(id.get)
|
||||
def userPrimaryId = UserPrimaryId(id.get)
|
||||
|
||||
def userId = userId_.get
|
||||
|
||||
@ -79,7 +98,7 @@ class ResourceUser extends LongKeyedMapper[ResourceUser] with User with ManyToMa
|
||||
ResourceUserCaseClass(
|
||||
emailAddress = emailAddress,
|
||||
idGivenByProvider = idGivenByProvider,
|
||||
resourceUserId = resourceUserId.value,
|
||||
resourceUserId = userPrimaryId.value,
|
||||
userId = userId,
|
||||
name = name,
|
||||
provider = provider
|
||||
|
||||
@ -11,9 +11,6 @@ object RemotedataAccountHolders extends ObpActorInit with AccountHolders {
|
||||
|
||||
val cc = RemotedataAccountHoldersCaseClasses
|
||||
|
||||
override def createAccountHolder(userId: Long, bankId: String, accountId: String): Boolean =
|
||||
extractFuture(actor ? cc.createAccountHolder(userId, bankId, accountId))
|
||||
|
||||
override def getOrCreateAccountHolder(user: User, bankAccountUID :BankIdAccountId): Box[MapperAccountHolders] =
|
||||
extractFutureToBox(actor ? cc.getOrCreateAccountHolder(user: User, bankAccountUID :BankIdAccountId))
|
||||
|
||||
|
||||
@ -14,10 +14,6 @@ class RemotedataAccountHoldersActor extends Actor with ObpActorHelper with MdcLo
|
||||
|
||||
def receive = {
|
||||
|
||||
case cc.createAccountHolder(userId: Long, bankId: String, accountId: String) =>
|
||||
logger.debug("createAccountHolder(" + userId +", "+ bankId +", "+ accountId +", " +")")
|
||||
sender ! extractResult(mapper.createAccountHolder(userId, bankId, accountId))
|
||||
|
||||
case cc.getOrCreateAccountHolder(user: User, account :BankIdAccountId) =>
|
||||
logger.debug("getOrCreateAccountHolder(" + user +", "+ account +", " +")")
|
||||
sender ! extractResult(mapper.getOrCreateAccountHolder(user: User, account :BankIdAccountId))
|
||||
|
||||
@ -18,7 +18,7 @@ object RemotedataComments extends ObpActorInit with Comments {
|
||||
def getComments(bankId : BankId, accountId : AccountId, transactionId : TransactionId)(viewId : ViewId) : List[Comment] =
|
||||
extractFuture(actor ? cc.getComments(bankId, accountId, transactionId, viewId))
|
||||
|
||||
def addComment(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserId, viewId : ViewId, text : String, datePosted : Date) : Box[Comment] =
|
||||
def addComment(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserPrimaryId, viewId : ViewId, text : String, datePosted : Date) : Box[Comment] =
|
||||
extractFutureToBox(actor ? cc.addComment(bankId, accountId, transactionId, userId, viewId, text, datePosted))
|
||||
|
||||
def deleteComment(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(commentId : String) : Box[Boolean] =
|
||||
|
||||
@ -109,10 +109,10 @@ object RemotedataCounterparties extends ObpActorInit with Counterparties {
|
||||
override def addMoreInfo(counterpartyId : String, moreInfo: String): Box[Boolean] =
|
||||
extractFutureToBox(actor ? cc.addMoreInfo(counterpartyId, moreInfo))
|
||||
|
||||
override def addPhysicalLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] =
|
||||
override def addPhysicalLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] =
|
||||
extractFutureToBox(actor ? cc.addPhysicalLocation(counterpartyId, userId, datePosted, longitude, latitude))
|
||||
|
||||
override def addCorporateLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] =
|
||||
override def addCorporateLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] =
|
||||
extractFutureToBox(actor ? cc.addCorporateLocation(counterpartyId, userId, datePosted, longitude, latitude))
|
||||
|
||||
override def deletePhysicalLocation(counterpartyId: String): Box[Boolean] =
|
||||
|
||||
@ -142,11 +142,11 @@ class RemotedataCounterpartiesActor extends Actor with ObpActorHelper with MdcLo
|
||||
logger.debug("addMoreInfo(" + counterpartyId + ", " + moreInfo +")")
|
||||
sender ! extractResult(mapper.addMoreInfo(counterpartyId, moreInfo))
|
||||
|
||||
case cc.addPhysicalLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double) =>
|
||||
case cc.addPhysicalLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double) =>
|
||||
logger.debug("addPhysicalLocation(" + counterpartyId + ", " + userId + ", " + datePosted + ", " + longitude + ", " + latitude +")")
|
||||
sender ! extractResult(mapper.addPhysicalLocation(counterpartyId, userId, datePosted, longitude, latitude))
|
||||
|
||||
case cc.addCorporateLocation(counterpartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double) =>
|
||||
case cc.addCorporateLocation(counterpartyId : String, userId: UserPrimaryId, datePosted : Date, longitude : Double, latitude : Double) =>
|
||||
logger.debug("addCorporateLocation(" + counterpartyId + ", " + userId + ", " + datePosted + ", " + longitude + ", " + latitude +")")
|
||||
sender ! extractResult(mapper.addCorporateLocation(counterpartyId, userId, datePosted, longitude, latitude))
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ object RemotedataTags extends ObpActorInit with Tags {
|
||||
def getTags(bankId : BankId, accountId : AccountId, transactionId : TransactionId)(viewId : ViewId) : List[TransactionTag] =
|
||||
extractFuture(actor ? cc.getTags(bankId, accountId, transactionId, viewId))
|
||||
|
||||
def addTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserId, viewId : ViewId, tagText : String, datePosted : Date) : Box[TransactionTag] =
|
||||
def addTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserPrimaryId, viewId : ViewId, tagText : String, datePosted : Date) : Box[TransactionTag] =
|
||||
extractFutureToBox(actor ? cc.addTag(bankId, accountId, transactionId, userId, viewId, tagText, datePosted))
|
||||
|
||||
def deleteTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(tagId : String) : Box[Boolean] =
|
||||
|
||||
@ -16,7 +16,7 @@ object RemotedataTransactionImages extends ObpActorInit with TransactionImages {
|
||||
extractFuture(actor ? cc.getImagesForTransaction(bankId, accountId, transactionId, viewId))
|
||||
|
||||
def addTransactionImage(bankId : BankId, accountId : AccountId, transactionId: TransactionId)
|
||||
(userId: UserId, viewId : ViewId, description : String, datePosted : Date, imageURL: String) : Box[TransactionImage] =
|
||||
(userId: UserPrimaryId, viewId : ViewId, description : String, datePosted : Date, imageURL: String) : Box[TransactionImage] =
|
||||
extractFutureToBox(actor ? cc.addTransactionImage(bankId, accountId, transactionId, userId, viewId, description, datePosted, imageURL))
|
||||
|
||||
def deleteTransactionImage(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(imageId : String) : Box[Boolean] =
|
||||
|
||||
@ -20,7 +20,7 @@ class RemotedataTransactionImagesActor extends Actor with ObpActorHelper with Md
|
||||
logger.debug("getImagesForTransaction(" + bankId +", "+ accountId +", "+ transactionId +", "+ viewId +")")
|
||||
sender ! extractResult(mapper.getImagesForTransaction(bankId, accountId, transactionId)(viewId))
|
||||
|
||||
case cc.addTransactionImage(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserId, viewId : ViewId, description : String, datePosted : Date, imageURL: String) =>
|
||||
case cc.addTransactionImage(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserPrimaryId, viewId : ViewId, description : String, datePosted : Date, imageURL: String) =>
|
||||
logger.debug("addTransactionImage( " + bankId +", "+ accountId +", "+ transactionId +", "+ userId +", "+ viewId + ", "+ description + ", " + datePosted + ", " + imageURL + ")")
|
||||
sender ! extractResult(mapper.addTransactionImage(bankId, accountId, transactionId)(userId, viewId, description, datePosted, imageURL))
|
||||
|
||||
|
||||
@ -17,8 +17,8 @@ object RemotedataWhereTags extends ObpActorInit with WhereTags {
|
||||
extractFutureToBox(actor ? cc.getWhereTagForTransaction(bankId, accountId, transactionId, viewId))
|
||||
|
||||
def addWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)
|
||||
(userId: UserId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double) : Boolean =
|
||||
extractFuture(actor ? cc.addWhereTag(bankId, accountId, transactionId, userId: UserId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double))
|
||||
(userId: UserPrimaryId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double) : Boolean =
|
||||
extractFuture(actor ? cc.addWhereTag(bankId, accountId, transactionId, userId: UserPrimaryId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double))
|
||||
|
||||
def deleteWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(viewId : ViewId) : Boolean =
|
||||
extractFuture(actor ? cc.deleteWhereTag(bankId, accountId, transactionId, viewId))
|
||||
|
||||
@ -28,9 +28,9 @@ class RemotedataWhereTagsActor extends Actor with ObpActorHelper with MdcLoggabl
|
||||
logger.debug("deleteWhereTag(" + bankId +", "+ accountId + ", "+ transactionId + ", "+ viewId + ")")
|
||||
sender ! extractResult(mapper.deleteWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(viewId : ViewId))
|
||||
|
||||
case cc.addWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double) =>
|
||||
case cc.addWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId, userId: UserPrimaryId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double) =>
|
||||
logger.debug("addWhereTag(" + bankId +", "+ accountId + ", "+ transactionId + ", "+ userId + ", " + viewId + ", "+ datePosted + ", "+ longitude + ", "+ latitude + ")")
|
||||
sender ! extractResult(mapper.addWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double))
|
||||
sender ! extractResult(mapper.addWhereTag(bankId : BankId, accountId : AccountId, transactionId: TransactionId)(userId: UserPrimaryId, viewId : ViewId, datePosted : Date, longitude : Double, latitude : Double))
|
||||
|
||||
case message => logger.warn("[AKKA ACTOR ERROR - REQUEST NOT RECOGNIZED] " + message)
|
||||
|
||||
|
||||
@ -174,8 +174,8 @@ trait OBPDataImport extends MdcLoggable {
|
||||
//println("{resourceUserOwner: " + resourceUserOwner)
|
||||
|
||||
resourceUserOwner match {
|
||||
case Some(o) => {
|
||||
AccountHolders.accountHolders.vend.createAccountHolder(o.resourceUserId.value, account.bankId.value, account.accountId.value)
|
||||
case Some(user) => {
|
||||
val accountHolder = AccountHolders.accountHolders.vend.getOrCreateAccountHolder(user, BankIdAccountId(account.bankId, account.accountId))
|
||||
}
|
||||
case None => {
|
||||
//This shouldn't happen as AuthUser should generate the ResourceUsers when saved
|
||||
|
||||
@ -48,7 +48,7 @@ object MapperViews extends Views with MdcLoggable {
|
||||
//search ViewPrivileges to get all views for user and then filter the views
|
||||
// by bankPermalink and accountPermalink
|
||||
//TODO: do it in a single query with a join
|
||||
val privileges = ViewPrivileges.findAll(By(ViewPrivileges.user, user.resourceUserId.value))
|
||||
val privileges = ViewPrivileges.findAll(By(ViewPrivileges.user, user.userPrimaryId.value))
|
||||
val views = privileges.flatMap(_.view.obj).filter(v =>
|
||||
if (ALLOW_PUBLIC_VIEWS) {
|
||||
v.accountId == account.accountId &&
|
||||
@ -63,11 +63,11 @@ object MapperViews extends Views with MdcLoggable {
|
||||
}
|
||||
|
||||
private def getOrCreateViewPrivilege(user: User, viewImpl: ViewImpl): Box[ViewImpl] = {
|
||||
if (ViewPrivileges.count(By(ViewPrivileges.user, user.resourceUserId.value), By(ViewPrivileges.view, viewImpl.id)) == 0) {
|
||||
if (ViewPrivileges.count(By(ViewPrivileges.user, user.userPrimaryId.value), By(ViewPrivileges.view, viewImpl.id)) == 0) {
|
||||
//logger.debug(s"saving ViewPrivileges for user ${user.resourceUserId.value} for view ${vImpl.id}")
|
||||
// SQL Insert ViewPrivileges
|
||||
val saved = ViewPrivileges.create.
|
||||
user(user.resourceUserId.value).
|
||||
user(user.userPrimaryId.value).
|
||||
view(viewImpl.id).
|
||||
save
|
||||
if (saved) {
|
||||
@ -118,7 +118,7 @@ object MapperViews extends Views with MdcLoggable {
|
||||
val res =
|
||||
for {
|
||||
viewImpl <- ViewImpl.find(viewUID)
|
||||
vp: ViewPrivileges <- ViewPrivileges.find(By(ViewPrivileges.user, user.resourceUserId.value), By(ViewPrivileges.view, viewImpl.id))
|
||||
vp: ViewPrivileges <- ViewPrivileges.find(By(ViewPrivileges.user, user.userPrimaryId.value), By(ViewPrivileges.view, viewImpl.id))
|
||||
deletable <- accessRemovableAsBox(viewImpl, user)
|
||||
} yield {
|
||||
vp.delete_!
|
||||
@ -139,8 +139,8 @@ object MapperViews extends Views with MdcLoggable {
|
||||
//if the user is an account holder, we can't revoke access to the owner view
|
||||
val accountHolders = MapperAccountHolders.getAccountHolders(viewImpl.bankId, viewImpl.accountId)
|
||||
if(accountHolders.map {h =>
|
||||
h.resourceUserId
|
||||
}.contains(user.resourceUserId)) {
|
||||
h.userPrimaryId
|
||||
}.contains(user.userPrimaryId)) {
|
||||
false
|
||||
} else {
|
||||
// if it's the owner view, we can only revoke access if there would then still be someone else
|
||||
@ -160,7 +160,7 @@ object MapperViews extends Views with MdcLoggable {
|
||||
|
||||
def revokeAllPermissions(bankId : BankId, accountId: AccountId, user : User) : Box[Boolean] = {
|
||||
//TODO: make this more efficient by using one query (with a join)
|
||||
val allUserPrivs = ViewPrivileges.findAll(By(ViewPrivileges.user, user.resourceUserId.value))
|
||||
val allUserPrivs = ViewPrivileges.findAll(By(ViewPrivileges.user, user.userPrimaryId.value))
|
||||
|
||||
val relevantAccountPrivs = allUserPrivs.filter(p => p.view.obj match {
|
||||
case Full(v) => {
|
||||
@ -291,7 +291,7 @@ object MapperViews extends Views with MdcLoggable {
|
||||
}
|
||||
|
||||
def privateViewsUserCanAccess(user: User): List[View] ={
|
||||
ViewPrivileges.findAll(By(ViewPrivileges.user, user.resourceUserId.value)).map(_.view.obj).flatten.filter(_.isPrivate)
|
||||
ViewPrivileges.findAll(By(ViewPrivileges.user, user.userPrimaryId.value)).map(_.view.obj).flatten.filter(_.isPrivate)
|
||||
}
|
||||
|
||||
def privateViewsUserCanAccessForAccount(user: User, bankIdAccountId : BankIdAccountId) : List[View] =
|
||||
@ -477,11 +477,11 @@ object MapperViews extends Views with MdcLoggable {
|
||||
def grantAccessToAllExistingViews(user : User) = {
|
||||
ViewImpl.findAll.foreach(v => {
|
||||
//Get All the views from ViewImpl table, and create the link user <--> each view. The link record the access permission.
|
||||
if ( ViewPrivileges.find(By(ViewPrivileges.view, v), By(ViewPrivileges.user, user.resourceUserId.value) ).isEmpty )
|
||||
if ( ViewPrivileges.find(By(ViewPrivileges.view, v), By(ViewPrivileges.user, user.userPrimaryId.value) ).isEmpty )
|
||||
//If the user and one view has no link, it will create one .
|
||||
ViewPrivileges.create.
|
||||
view(v).
|
||||
user(user.resourceUserId.value).
|
||||
user(user.userPrimaryId.value).
|
||||
save
|
||||
})
|
||||
true
|
||||
@ -502,10 +502,10 @@ object MapperViews extends Views with MdcLoggable {
|
||||
*/
|
||||
def grantAccessToView(user : User, view : View): Boolean = {
|
||||
val v = ViewImpl.find(view.uid).orNull
|
||||
if ( ViewPrivileges.count(By(ViewPrivileges.view, v), By(ViewPrivileges.user, user.resourceUserId.value) ) == 0 )
|
||||
if ( ViewPrivileges.count(By(ViewPrivileges.view, v), By(ViewPrivileges.user, user.userPrimaryId.value) ) == 0 )
|
||||
ViewPrivileges.create.
|
||||
view(v). //explodes if no viewImpl exists, but that's okay, the test should fail then
|
||||
user(user.resourceUserId.value).
|
||||
user(user.userPrimaryId.value).
|
||||
save
|
||||
else
|
||||
false
|
||||
|
||||
@ -73,7 +73,7 @@ class MappedCrmEventProviderTest extends ServerSetup with DefaultUsers {
|
||||
Given("MappedCrmEvent exists for a user on a bank")
|
||||
MappedCrmEvent.find(
|
||||
By(MappedCrmEvent.mBankId, testBankId1.toString),
|
||||
By(MappedCrmEvent.mUserId, resourceUser1.resourceUserId.value)
|
||||
By(MappedCrmEvent.mUserId, resourceUser1.userPrimaryId.value)
|
||||
).isDefined should equal(true)
|
||||
|
||||
When("We try to get it by bank and user")
|
||||
@ -111,7 +111,7 @@ class MappedCrmEventProviderTest extends ServerSetup with DefaultUsers {
|
||||
Given("MappedCrmEvent exists for a user")
|
||||
MappedCrmEvent.find(
|
||||
By(MappedCrmEvent.mBankId, testBankId2.toString),
|
||||
By(MappedCrmEvent.mUserId, resourceUser2.resourceUserId.value)
|
||||
By(MappedCrmEvent.mUserId, resourceUser2.userPrimaryId.value)
|
||||
).isDefined should equal(true)
|
||||
|
||||
When("We try to get them")
|
||||
|
||||
@ -40,8 +40,8 @@ class AuthUserTest extends ServerSetup with DefaultUsers {
|
||||
var accountholder1 = MapperAccountHolders.getAccountHolders(bankIdAccountId.bankId, bankIdAccountId.accountId)
|
||||
var accountholder2 = MapperAccountHolders.getAccountHolders(bankIdAccountId2.bankId, bankIdAccountId2.accountId)
|
||||
var accountholders = MapperAccountHolders.findAll()
|
||||
accountholder1.head.resourceUserId should equal(resourceUser1.resourceUserId)
|
||||
accountholder2.head.resourceUserId should equal(resourceUser1.resourceUserId)
|
||||
accountholder1.head.userPrimaryId should equal(resourceUser1.userPrimaryId)
|
||||
accountholder2.head.userPrimaryId should equal(resourceUser1.userPrimaryId)
|
||||
accountholders.length should equal(2)
|
||||
|
||||
Then("We check the views") //"Owner"::"Public" :: "Accountant" :: "Auditor"
|
||||
|
||||
@ -291,7 +291,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Match
|
||||
foundAccount.balance.toString should equal(account.balance.amount)
|
||||
foundAccount.currency should equal(account.balance.currency)
|
||||
|
||||
foundAccount.owners.map(_.name) should equal(account.owners.toSet)
|
||||
foundAccount.userOwners.map(_.name) should equal(account.owners.toSet)
|
||||
|
||||
if(account.generate_public_view) {
|
||||
Views.views.vend.viewsForAccount(BankIdAccountId(foundAccount.bankId, foundAccount.accountId)).filter(_.isPublic).size should equal(1)
|
||||
@ -299,7 +299,7 @@ class SandboxDataLoadingTest extends FlatSpec with SendServerRequests with Match
|
||||
Views.views.vend.viewsForAccount(BankIdAccountId(foundAccount.bankId, foundAccount.accountId)).filter(_.isPublic).size should equal(0)
|
||||
}
|
||||
|
||||
val owner = Users.users.vend.getUserByProviderId(defaultProvider, foundAccount.owners.toList.head.name).openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
val owner = Users.users.vend.getUserByProviderId(defaultProvider, foundAccount.userOwners.toList.head.name).openOrThrowException(attemptedToOpenAnEmptyBox)
|
||||
//there should be an owner view
|
||||
val views = Views.views.vend.privateViewsUserCanAccessForAccount(owner, BankIdAccountId(foundAccount.bankId, foundAccount.accountId))
|
||||
val ownerView = views.find(v => v.viewId.value == "owner")
|
||||
|
||||
@ -19,7 +19,7 @@ import code.api.util.ErrorMessages._
|
||||
trait TestConnectorSetupWithStandardPermissions extends TestConnectorSetup {
|
||||
|
||||
override protected def setAccountHolder(user: User, bankId : BankId, accountId : AccountId) = {
|
||||
AccountHolders.accountHolders.vend.createAccountHolder(user.resourceUserId.value, bankId.value, accountId.value)
|
||||
AccountHolders.accountHolders.vend.getOrCreateAccountHolder(user, BankIdAccountId(bankId, accountId))
|
||||
}
|
||||
|
||||
override protected def grantAccessToAllExistingViews(user : User) = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user