MappedCounterparty, MappedCounterpartyMetadata and MappedCounterpartyWhereTag separated by Akka

This commit is contained in:
Marko Milic 2017-03-17 16:49:58 +01:00
parent c72b13e4ee
commit a68859d603
16 changed files with 461 additions and 115 deletions

View File

@ -438,14 +438,14 @@ object ToSchemify {
MappedCustomer,
MappedUserCustomerLink,
Consumer,
MappedCounterparty,
MappedCounterpartyMetadata,
MappedCounterpartyWhereTag,
MapperAccountHolders
)
// The following tables are accessed directly via Mapper / JDBC
val models = List(
MappedCounterparty,
MappedCounterpartyMetadata,
MappedCounterpartyWhereTag,
AuthUser,
Admin,
Nonce,

View File

@ -35,20 +35,24 @@ import code.api.util.APIUtil
import net.liftweb.http.rest._
import net.liftweb.json.Extraction
import net.liftweb.json.JsonAST._
import net.liftweb.common.{Failure,Full,Empty, Box, Loggable}
import net.liftweb.common.{Box, Empty, Failure, Full, Loggable}
import net.liftweb.mongodb._
import _root_.java.math.MathContext
import _root_.net.liftweb.util._
import _root_.net.liftweb.util.Helpers._
import _root_.scala.xml._
import _root_.net.liftweb.http.S._
import net.liftweb.mongodb.Skip
import com.mongodb._
import code.bankconnectors.{OBPOrder, OBPLimit, OBPOffset, OBPOrdering, OBPFromDate, OBPToDate, OBPQueryParam}
import code.bankconnectors.{OBPFromDate, OBPLimit, OBPOffset, OBPOrder, OBPOrdering, OBPQueryParam, OBPToDate}
import code.model._
import java.net.URL
import APIUtil._
import code.api.OBPRestHelper
import code.metadata.counterparties.Counterparties
object OBPAPI1_2 extends OBPRestHelper with Loggable {
@ -404,7 +408,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPublicAlias) ?~ {"the view " + viewId + "does not allow adding a public alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
if(addAlias(aliasJson.alias))
added <- Counterparties.counterparties.vend.addPublicAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be added"}
if(added)
} yield {
successJsonResponse(Extraction.decompose(SuccessMessage("public alias added")), 201)
}
@ -422,7 +427,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPublicAlias) ?~ {"the view " + viewId + "does not allow updating the public alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
if(addAlias(aliasJson.alias))
added <- Counterparties.counterparties.vend.addPublicAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be updated"}
if(added)
} yield {
successJsonResponse(Extraction.decompose(SuccessMessage("public alias updated")))
}
@ -439,7 +445,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPublicAlias) ?~ {"the view " + viewId + "does not allow deleting the public alias"}
if(addAlias(""))
added <- Counterparties.counterparties.vend.addPublicAlias(other_account_id, "") ?~ {"Alias cannot be deleted"}
if(added)
} yield noContentJsonResponse
}
})
@ -473,7 +480,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPrivateAlias) ?~ {"the view " + viewId + "does not allow adding a private alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
if(addAlias(aliasJson.alias))
added <- Counterparties.counterparties.vend.addPrivateAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be added"}
if(added)
} yield {
val successJson = SuccessMessage("private alias added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -492,7 +500,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPrivateAlias) ?~ {"the view " + viewId + "does not allow updating the private alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
if(addAlias(aliasJson.alias))
added <- Counterparties.counterparties.vend.addPrivateAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be updated"}
if(added)
} yield {
val successJson = SuccessMessage("private alias updated")
successJsonResponse(Extraction.decompose(successJson))
@ -510,7 +519,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPrivateAlias) ?~ {"the view " + viewId + "does not allow deleting the private alias"}
if(addAlias(""))
added <- Counterparties.counterparties.vend.addPrivateAlias(other_account_id, "") ?~ {"Alias cannot be deleted"}
if(added)
} yield noContentJsonResponse
}
})
@ -526,7 +536,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addMoreInfo <- Box(metadata.addMoreInfo) ?~ {"the view " + viewId + "does not allow adding more info"}
moreInfoJson <- tryo{(json.extract[MoreInfoJSON])} ?~ {"wrong JSON format"}
if(addMoreInfo(moreInfoJson.more_info))
added <- Counterparties.counterparties.vend.addMoreInfo(other_account_id, moreInfoJson.more_info) ?~ {"More Info cannot be added"}
if(added)
} yield {
val successJson = SuccessMessage("more info added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -545,7 +556,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addMoreInfo <- Box(metadata.addMoreInfo) ?~ {"the view " + viewId + "does not allow updating more info"}
moreInfoJson <- tryo{(json.extract[MoreInfoJSON])} ?~ {"wrong JSON format"}
if(addMoreInfo(moreInfoJson.more_info))
updated <- Counterparties.counterparties.vend.addMoreInfo(other_account_id, moreInfoJson.more_info) ?~ {"More Info cannot be updated"}
if(updated)
} yield {
val successJson = SuccessMessage("more info updated")
successJsonResponse(Extraction.decompose(successJson))
@ -563,7 +575,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addMoreInfo <- Box(metadata.addMoreInfo) ?~ {"the view " + viewId + "does not allow deleting more info"}
if(addMoreInfo(""))
deleted <- Counterparties.counterparties.vend.addMoreInfo(other_account_id, "") ?~ {"More Info cannot be deleted"}
if(deleted)
} yield noContentJsonResponse
}
})
@ -579,7 +592,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addUrl <- Box(metadata.addURL) ?~ {"the view " + viewId + "does not allow adding a url"}
urlJson <- tryo{(json.extract[UrlJSON])} ?~ {"wrong JSON format"}
if(addUrl(urlJson.URL))
added <- Counterparties.counterparties.vend.addURL(other_account_id, urlJson.URL) ?~ {"URL cannot be added"}
if(added)
} yield {
val successJson = SuccessMessage("url added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -598,7 +612,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addUrl <- Box(metadata.addURL) ?~ {"the view " + viewId + "does not allow updating a url"}
urlJson <- tryo{(json.extract[UrlJSON])} ?~ {"wrong JSON format"}
if(addUrl(urlJson.URL))
added <- Counterparties.counterparties.vend.addURL(other_account_id, urlJson.URL) ?~ {"URL cannot be updated"}
if(added)
} yield {
val successJson = SuccessMessage("url updated")
successJsonResponse(Extraction.decompose(successJson))
@ -616,7 +631,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addUrl <- Box(metadata.addURL) ?~ {"the view " + viewId + "does not allow deleting a url"}
if(addUrl(""))
added <- Counterparties.counterparties.vend.addURL(other_account_id, "") ?~ {"URL cannot be deleted"}
if(added)
} yield noContentJsonResponse
}
})
@ -632,7 +648,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addImageUrl <- Box(metadata.addImageURL) ?~ {"the view " + viewId + "does not allow adding an image url"}
imageUrlJson <- tryo{(json.extract[ImageUrlJSON])} ?~ {"wrong JSON format"}
if(addImageUrl(imageUrlJson.image_URL))
added <- Counterparties.counterparties.vend.addImageURL(other_account_id, imageUrlJson.image_URL) ?~ {"URL cannot be added"}
if(added)
} yield {
val successJson = SuccessMessage("image url added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -651,7 +668,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addImageUrl <- Box(metadata.addImageURL) ?~ {"the view " + viewId + "does not allow updating an image url"}
imageUrlJson <- tryo{(json.extract[ImageUrlJSON])} ?~ {"wrong JSON format"}
if(addImageUrl(imageUrlJson.image_URL))
updated <- Counterparties.counterparties.vend.addImageURL(other_account_id, imageUrlJson.image_URL) ?~ {"URL cannot be updated"}
if(updated)
} yield {
val successJson = SuccessMessage("image url updated")
successJsonResponse(Extraction.decompose(successJson))
@ -669,7 +687,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addImageUrl <- Box(metadata.addImageURL) ?~ {"the view " + viewId + "does not allow deleting an image url"}
if(addImageUrl(""))
deleted <- Counterparties.counterparties.vend.addImageURL(other_account_id, "") ?~ {"URL cannot be deleted"}
if(deleted)
} yield noContentJsonResponse
}
})
@ -684,8 +703,9 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addOpenCorpUrl <- Box(metadata.addOpenCorporatesURL) ?~ {"the view " + viewId + "does not allow adding an open corporate url"}
opernCoprUrl <- tryo{(json.extract[OpenCorporateUrlJSON])} ?~ {"wrong JSON format"}
if(addOpenCorpUrl(opernCoprUrl.open_corporates_URL))
openCorpUrl <- tryo{(json.extract[OpenCorporateUrlJSON])} ?~ {"wrong JSON format"}
added <- Counterparties.counterparties.vend.addOpenCorporatesURL(other_account_id, openCorpUrl.open_corporates_URL) ?~ {"URL cannot be added"}
if(added)
} yield {
val successJson = SuccessMessage("open corporate url added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -703,8 +723,9 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addOpenCorpUrl <- Box(metadata.addOpenCorporatesURL) ?~ {"the view " + viewId + "does not allow updating an open corporate url"}
opernCoprUrl <- tryo{(json.extract[OpenCorporateUrlJSON])} ?~ {"wrong JSON format"}
if(addOpenCorpUrl(opernCoprUrl.open_corporates_URL))
openCorpUrl <- tryo{(json.extract[OpenCorporateUrlJSON])} ?~ {"wrong JSON format"}
updated <- Counterparties.counterparties.vend.addOpenCorporatesURL(other_account_id, openCorpUrl.open_corporates_URL) ?~ {"URL cannot be updated"}
if(updated)
} yield {
val successJson = SuccessMessage("open corporate url updated")
successJsonResponse(Extraction.decompose(successJson))
@ -722,7 +743,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addOpenCorpUrl <- Box(metadata.addOpenCorporatesURL) ?~ {"the view " + viewId + "does not allow deleting an open corporate url"}
if(addOpenCorpUrl(""))
deleted <- Counterparties.counterparties.vend.addOpenCorporatesURL(other_account_id, "") ?~ {"URL cannot be deleted"}
if(deleted)
} yield noContentJsonResponse
}
})
@ -740,7 +762,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
addCorpLocation <- Box(metadata.addCorporateLocation) ?~ {"the view " + viewId + "does not allow adding a corporate location"}
corpLocationJson <- tryo{(json.extract[CorporateLocationJSON])} ?~ {"wrong JSON format"}
correctCoordinates <- checkIfLocationPossible(corpLocationJson.corporate_location.latitude, corpLocationJson.corporate_location.longitude)
if(addCorpLocation(u.resourceUserId, (now:TimeSpan), corpLocationJson.corporate_location.longitude, corpLocationJson.corporate_location.latitude))
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"}
if(added)
} yield {
val successJson = SuccessMessage("corporate location added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -761,7 +784,8 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
addCorpLocation <- Box(metadata.addCorporateLocation) ?~ {"the view " + viewId + "does not allow updating a corporate location"}
corpLocationJson <- tryo{(json.extract[CorporateLocationJSON])} ?~ {"wrong JSON format"}
correctCoordinates <- checkIfLocationPossible(corpLocationJson.corporate_location.latitude, corpLocationJson.corporate_location.longitude)
if(addCorpLocation(u.resourceUserId, now, corpLocationJson.corporate_location.longitude, corpLocationJson.corporate_location.latitude))
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"}
if(updated)
} yield {
val successJson = SuccessMessage("corporate location updated")
successJsonResponse(Extraction.decompose(successJson))
@ -779,9 +803,9 @@ object OBPAPI1_2 extends OBPRestHelper with Loggable {
view <- View.fromUrl(viewId, account)
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
deleted <- Box(metadata.deleteCorporateLocation)
deleted <- Counterparties.counterparties.vend.deleteCorporateLocation(other_account_id) ?~ {"Corporate Location cannot be deleted"}
} yield {
if(deleted())
if(deleted)
noContentJsonResponse
else
errorJsonResponse("Delete not completed")
@ -809,7 +833,8 @@ def checkIfLocationPossible(lat:Double,lon:Double) : Box[Unit] = {
addPhysicalLocation <- Box(metadata.addPhysicalLocation) ?~ {"the view " + viewId + "does not allow adding a physical location"}
physicalLocationJson <- tryo{(json.extract[PhysicalLocationJSON])} ?~ {"wrong JSON format"}
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
if(addPhysicalLocation(u.resourceUserId, now, physicalLocationJson.physical_location.longitude, physicalLocationJson.physical_location.latitude))
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"}
if(added)
} yield {
val successJson = SuccessMessage("physical location added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -830,7 +855,8 @@ def checkIfLocationPossible(lat:Double,lon:Double) : Box[Unit] = {
addPhysicalLocation <- Box(metadata.addPhysicalLocation) ?~ {"the view " + viewId + "does not allow updating a physical location"}
physicalLocationJson <- tryo{(json.extract[PhysicalLocationJSON])} ?~ {"wrong JSON format"}
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
if(addPhysicalLocation(u.resourceUserId, now, physicalLocationJson.physical_location.longitude, physicalLocationJson.physical_location.latitude))
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"}
if(updated)
} yield {
val successJson = SuccessMessage("physical location updated")
successJsonResponse(Extraction.decompose(successJson))
@ -848,9 +874,9 @@ def checkIfLocationPossible(lat:Double,lon:Double) : Box[Unit] = {
view <- View.fromUrl(viewId, account)
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
deleted <- Box(metadata.deletePhysicalLocation)
deleted <- Counterparties.counterparties.vend.deletePhysicalLocation(other_account_id) ?~ {"Physical Location cannot be deleted"}
} yield {
if(deleted())
if(deleted)
noContentJsonResponse
else
errorJsonResponse("Delete not completed")

View File

@ -16,6 +16,7 @@ import code.bankconnectors._
import code.bankconnectors.OBPOffset
import code.bankconnectors.OBPFromDate
import code.bankconnectors.OBPToDate
import code.metadata.counterparties.Counterparties
import code.model.CreateViewJSON
import net.liftweb.common.Full
import code.model.UpdateViewJSON
@ -954,7 +955,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPublicAlias) ?~ {"the view " + viewId + "does not allow adding a public alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
if(addAlias(aliasJson.alias))
added <- Counterparties.counterparties.vend.addPublicAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be added"}
if(added)
} yield {
successJsonResponse(Extraction.decompose(SuccessMessage("public alias added")), 201)
}
@ -989,7 +991,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPublicAlias) ?~ {"the view " + viewId + "does not allow updating the public alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
if(addAlias(aliasJson.alias))
added <- Counterparties.counterparties.vend.addPublicAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be updated"}
if(added)
} yield {
successJsonResponse(Extraction.decompose(SuccessMessage("public alias updated")))
}
@ -1023,7 +1026,8 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPublicAlias) ?~ {"the view " + viewId + "does not allow deleting the public alias"}
if(addAlias(""))
added <- Counterparties.counterparties.vend.addPublicAlias(other_account_id, "") ?~ {"Alias cannot be deleted"}
if(added)
} yield noContentJsonResponse
}
}
@ -1090,7 +1094,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPrivateAlias) ?~ {"the view " + viewId + "does not allow adding a private alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
if(addAlias(aliasJson.alias))
added <- Counterparties.counterparties.vend.addPrivateAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be added"}
if(added)
} yield {
val successJson = SuccessMessage("private alias added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -1126,7 +1131,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPrivateAlias) ?~ {"the view " + viewId + "does not allow updating the private alias"}
aliasJson <- tryo{(json.extract[AliasJSON])} ?~ {"wrong JSON format"}
if(addAlias(aliasJson.alias))
updated <- Counterparties.counterparties.vend.addPrivateAlias(other_account_id, aliasJson.alias) ?~ {"Alias cannot be updated"}
if(updated)
} yield {
val successJson = SuccessMessage("private alias updated")
successJsonResponse(Extraction.decompose(successJson))
@ -1161,7 +1167,8 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addAlias <- Box(metadata.addPrivateAlias) ?~ {"the view " + viewId + "does not allow deleting the private alias"}
if(addAlias(""))
added <- Counterparties.counterparties.vend.addPrivateAlias(other_account_id, "") ?~ {"Alias cannot be deleted"}
if(added)
} yield noContentJsonResponse
}
}
@ -1193,7 +1200,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addMoreInfo <- Box(metadata.addMoreInfo) ?~ {"the view " + viewId + "does not allow adding more info"}
moreInfoJson <- tryo{(json.extract[MoreInfoJSON])} ?~ {"wrong JSON format"}
if(addMoreInfo(moreInfoJson.more_info))
added <- Counterparties.counterparties.vend.addMoreInfo(other_account_id, moreInfoJson.more_info) ?~ {"More Info cannot be added"}
if(added)
} yield {
val successJson = SuccessMessage("more info added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -1226,7 +1234,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addMoreInfo <- Box(metadata.addMoreInfo) ?~ {"the view " + viewId + "does not allow updating more info"}
moreInfoJson <- tryo{(json.extract[MoreInfoJSON])} ?~ {"wrong JSON format"}
if(addMoreInfo(moreInfoJson.more_info))
updated <- Counterparties.counterparties.vend.addMoreInfo(other_account_id, moreInfoJson.more_info) ?~ {"More Info cannot be updated"}
if(updated)
} yield {
val successJson = SuccessMessage("more info updated")
successJsonResponse(Extraction.decompose(successJson))
@ -1258,7 +1267,8 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addMoreInfo <- Box(metadata.addMoreInfo) ?~ {"the view " + viewId + "does not allow deleting more info"}
if(addMoreInfo(""))
deleted <- Counterparties.counterparties.vend.addMoreInfo(other_account_id, "") ?~ {"More Info cannot be deleted"}
if(deleted)
} yield noContentJsonResponse
}
}
@ -1291,7 +1301,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addUrl <- Box(metadata.addURL) ?~ {"the view " + viewId + "does not allow adding a url"}
urlJson <- tryo{(json.extract[UrlJSON])} ?~ {"wrong JSON format"}
if(addUrl(urlJson.URL))
added <- Counterparties.counterparties.vend.addURL(other_account_id, urlJson.URL) ?~ {"URL cannot be added"}
if(added)
} yield {
val successJson = SuccessMessage("url added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -1324,7 +1335,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addUrl <- Box(metadata.addURL) ?~ {"the view " + viewId + "does not allow updating a url"}
urlJson <- tryo{(json.extract[UrlJSON])} ?~ {"wrong JSON format"}
if(addUrl(urlJson.URL))
added <- Counterparties.counterparties.vend.addURL(other_account_id, urlJson.URL) ?~ {"URL cannot be updated"}
if(added)
} yield {
val successJson = SuccessMessage("url updated")
successJsonResponse(Extraction.decompose(successJson))
@ -1356,7 +1368,8 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addUrl <- Box(metadata.addURL) ?~ {"the view " + viewId + "does not allow deleting a url"}
if(addUrl(""))
added <- Counterparties.counterparties.vend.addURL(other_account_id, "") ?~ {"URL cannot be deleted"}
if(added)
} yield noContentJsonResponse
}
}
@ -1388,7 +1401,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addImageUrl <- Box(metadata.addImageURL) ?~ {"the view " + viewId + "does not allow adding an image url"}
imageUrlJson <- tryo{(json.extract[ImageUrlJSON])} ?~ {"wrong JSON format"}
if(addImageUrl(imageUrlJson.image_URL))
added <- Counterparties.counterparties.vend.addImageURL(other_account_id, imageUrlJson.image_URL) ?~ {"URL cannot be added"}
if(added)
} yield {
val successJson = SuccessMessage("image url added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -1421,7 +1435,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addImageUrl <- Box(metadata.addImageURL) ?~ {"the view " + viewId + "does not allow updating an image url"}
imageUrlJson <- tryo{(json.extract[ImageUrlJSON])} ?~ {"wrong JSON format"}
if(addImageUrl(imageUrlJson.image_URL))
updated <- Counterparties.counterparties.vend.addImageURL(other_account_id, imageUrlJson.image_URL) ?~ {"URL cannot be updated"}
if(updated)
} yield {
val successJson = SuccessMessage("image url updated")
successJsonResponse(Extraction.decompose(successJson))
@ -1453,7 +1468,8 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addImageUrl <- Box(metadata.addImageURL) ?~ {"the view " + viewId + "does not allow deleting an image url"}
if(addImageUrl(""))
deleted <- Counterparties.counterparties.vend.addImageURL(other_account_id, "") ?~ {"URL cannot be deleted"}
if(deleted)
} yield noContentJsonResponse
}
}
@ -1485,7 +1501,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addOpenCorpUrl <- Box(metadata.addOpenCorporatesURL) ?~ {"the view " + viewId + "does not allow adding an open corporate url"}
openCorpUrl <- tryo{(json.extract[OpenCorporateUrlJSON])} ?~ {"wrong JSON format"}
if(addOpenCorpUrl(openCorpUrl.open_corporates_URL))
added <- Counterparties.counterparties.vend.addOpenCorporatesURL(other_account_id, openCorpUrl.open_corporates_URL) ?~ {"URL cannot be added"}
if(added)
} yield {
val successJson = SuccessMessage("open corporate url added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -1518,7 +1535,8 @@ trait APIMethods121 {
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addOpenCorpUrl <- Box(metadata.addOpenCorporatesURL) ?~ {"the view " + viewId + "does not allow updating an open corporate url"}
openCorpUrl <- tryo{(json.extract[OpenCorporateUrlJSON])} ?~ {"wrong JSON format"}
if(addOpenCorpUrl(openCorpUrl.open_corporates_URL))
updated <- Counterparties.counterparties.vend.addOpenCorporatesURL(other_account_id, openCorpUrl.open_corporates_URL) ?~ {"URL cannot be updated"}
if(updated)
} yield {
val successJson = SuccessMessage("open corporate url updated")
successJsonResponse(Extraction.decompose(successJson))
@ -1550,7 +1568,8 @@ trait APIMethods121 {
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
addOpenCorpUrl <- Box(metadata.addOpenCorporatesURL) ?~ {"the view " + viewId + "does not allow deleting an open corporate url"}
if(addOpenCorpUrl(""))
deleted <- Counterparties.counterparties.vend.addOpenCorporatesURL(other_account_id, "") ?~ {"URL cannot be deleted"}
if(deleted)
} yield noContentJsonResponse
}
}
@ -1584,7 +1603,8 @@ trait APIMethods121 {
addCorpLocation <- Box(metadata.addCorporateLocation) ?~ {"the view " + viewId + "does not allow adding a corporate location"}
corpLocationJson <- tryo{(json.extract[CorporateLocationJSON])} ?~ {"wrong JSON format"}
correctCoordinates <- checkIfLocationPossible(corpLocationJson.corporate_location.latitude, corpLocationJson.corporate_location.longitude)
if(addCorpLocation(u.resourceUserId, (now:TimeSpan), corpLocationJson.corporate_location.longitude, corpLocationJson.corporate_location.latitude))
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"}
if(added)
} yield {
val successJson = SuccessMessage("corporate location added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -1619,7 +1639,8 @@ trait APIMethods121 {
addCorpLocation <- Box(metadata.addCorporateLocation) ?~ {"the view " + viewId + "does not allow updating a corporate location"}
corpLocationJson <- tryo{(json.extract[CorporateLocationJSON])} ?~ {"wrong JSON format"}
correctCoordinates <- checkIfLocationPossible(corpLocationJson.corporate_location.latitude, corpLocationJson.corporate_location.longitude)
if(addCorpLocation(u.resourceUserId, now, corpLocationJson.corporate_location.longitude, corpLocationJson.corporate_location.latitude))
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"}
if(updated)
} yield {
val successJson = SuccessMessage("corporate location updated")
successJsonResponse(Extraction.decompose(successJson))
@ -1651,9 +1672,9 @@ trait APIMethods121 {
view <- View.fromUrl(viewId, account)
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
deleted <- Box(metadata.deleteCorporateLocation)
deleted <- Counterparties.counterparties.vend.deleteCorporateLocation(other_account_id) ?~ {"Corporate Location cannot be deleted"}
} yield {
if(deleted())
if(deleted)
noContentJsonResponse
else
errorJsonResponse("Delete not completed")
@ -1690,7 +1711,9 @@ trait APIMethods121 {
addPhysicalLocation <- Box(metadata.addPhysicalLocation) ?~ {"the view " + viewId + "does not allow adding a physical location"}
physicalLocationJson <- tryo{(json.extract[PhysicalLocationJSON])} ?~ {"wrong JSON format"}
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
if(addPhysicalLocation(u.resourceUserId, now, physicalLocationJson.physical_location.longitude, physicalLocationJson.physical_location.latitude))
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"}
if(added)
} yield {
val successJson = SuccessMessage("physical location added")
successJsonResponse(Extraction.decompose(successJson), 201)
@ -1725,7 +1748,9 @@ trait APIMethods121 {
addPhysicalLocation <- Box(metadata.addPhysicalLocation) ?~ {"the view " + viewId + "does not allow updating a physical location"}
physicalLocationJson <- tryo{(json.extract[PhysicalLocationJSON])} ?~ {"wrong JSON format"}
correctCoordinates <- checkIfLocationPossible(physicalLocationJson.physical_location.latitude, physicalLocationJson.physical_location.longitude)
if(addPhysicalLocation(u.resourceUserId, now, physicalLocationJson.physical_location.longitude, physicalLocationJson.physical_location.latitude))
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"}
if(updated)
} yield {
val successJson = SuccessMessage("physical location updated")
successJsonResponse(Extraction.decompose(successJson))
@ -1757,9 +1782,9 @@ trait APIMethods121 {
view <- View.fromUrl(viewId, account)
otherBankAccount <- account.moderatedOtherBankAccount(other_account_id, view, user)
metadata <- Box(otherBankAccount.metadata) ?~ {"the view " + viewId + "does not allow metadata access"}
deleted <- Box(metadata.deletePhysicalLocation)
deleted <- Counterparties.counterparties.vend.deletePhysicalLocation(other_account_id) ?~ {"Physical Location cannot be deleted"}
} yield {
if(deleted())
if(deleted)
noContentJsonResponse
else
errorJsonResponse("Delete not completed")

View File

@ -553,7 +553,7 @@ object KafkaMappedConnector extends Connector with Loggable {
override def getCounterpartyByCounterpartyId(counterpartyId: CounterpartyId): Box[CounterpartyTrait] = {
if (Props.getBool("get_counterparties_from_OBP_DB", true)) {
MappedCounterparty.find(By(MappedCounterparty.mCounterPartyId, counterpartyId.value))
Counterparties.counterparties.vend.getCounterparty(counterpartyId.value)
} else {
val req = Map(
"north" -> "getCounterpartyByCounterpartyId",
@ -578,10 +578,7 @@ object KafkaMappedConnector extends Connector with Loggable {
override def getCounterpartyByIban(iban: String): Box[CounterpartyTrait] = {
if (Props.getBool("get_counterparties_from_OBP_DB", true)) {
MappedCounterparty.find(
By(MappedCounterparty.mOtherAccountRoutingAddress, iban),
By(MappedCounterparty.mOtherAccountRoutingScheme, "IBAN")
)
Counterparties.counterparties.vend.getCounterpartyByIban(iban)
} else {
val req = Map(
"north" -> "getCounterpartyByIban",

View File

@ -966,7 +966,7 @@ object KafkaMappedConnector_vMar2017 extends Connector with Loggable {
override def getCounterpartyByCounterpartyId(counterpartyId: CounterpartyId): Box[CounterpartyTrait] = {
if (Props.getBool("get_counterparties_from_OBP_DB", true)) {
MappedCounterparty.find(By(MappedCounterparty.mCounterPartyId, counterpartyId.value))
Counterparties.counterparties.vend.getCounterparty(counterpartyId.value)
} else {
val req = OutboundCounterpartyByCounterpartyId(
action = "obp.get.CounterpartyByCounterpartyId",
@ -1022,10 +1022,7 @@ object KafkaMappedConnector_vMar2017 extends Connector with Loggable {
override def getCounterpartyByIban(iban: String): Box[CounterpartyTrait] = {
if (Props.getBool("get_counterparties_from_OBP_DB", true)) {
MappedCounterparty.find(
By(MappedCounterparty.mOtherAccountRoutingAddress, iban),
By(MappedCounterparty.mOtherAccountRoutingScheme, "IBAN")
)
Counterparties.counterparties.vend.getCounterpartyByIban(iban)
} else {
val req = OutboundCounterpartyByIban(
action = "obp.get.CounterpartyByIban",

View File

@ -287,14 +287,11 @@ object LocalMappedConnector extends Connector with Loggable {
}
def getCounterpartyByCounterpartyId(counterpartyId: CounterpartyId): Box[CounterpartyTrait] ={
MappedCounterparty.find(By(MappedCounterparty.mCounterPartyId, counterpartyId.value))
Counterparties.counterparties.vend.getCounterparty(counterpartyId.value)
}
override def getCounterpartyByIban(iban: String): Box[CounterpartyTrait] ={
MappedCounterparty.find(
By(MappedCounterparty.mOtherAccountRoutingAddress, iban),
By(MappedCounterparty.mOtherAccountRoutingScheme, "IBAN")
)
Counterparties.counterparties.vend.getCounterpartyByIban(iban)
}
@ -1019,9 +1016,7 @@ object LocalMappedConnector extends Connector with Loggable {
}
override def getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId): Box[List[CounterpartyTrait]] = {
Full(MappedCounterparty.findAll(By(MappedCounterparty.mThisAccountId, thisAccountId.value),
By(MappedCounterparty.mThisBankId, thisBankId.value),
By(MappedCounterparty.mThisViewId, viewId.value)))
Counterparties.counterparties.vend.getCounterparties(thisBankId, thisAccountId, viewId)
}
}

View File

@ -1,8 +1,10 @@
package code.metadata.counterparties
import java.util.Date
import net.liftweb.common.Box
import net.liftweb.util.SimpleInjector
import code.model.{AccountId, BankId, Counterparty, CounterpartyMetadata}
import code.model._
import code.remotedata.RemotedataCounterparties
object Counterparties extends SimpleInjector {
@ -27,6 +29,8 @@ trait Counterparties {
def getCounterpartyByIban(iban : String): Box[CounterpartyTrait]
def getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId): Box[List[CounterpartyTrait]]
def createCounterparty(
createdByUserId: String,
thisBankId: String,
@ -46,6 +50,25 @@ trait Counterparties {
thisAccountId: String,
thisViewId: String
): Boolean
def addPublicAlias(counterPartyId: String, alias: String): Box[Boolean]
def addPrivateAlias(counterPartyId: String, alias: String): Box[Boolean]
def addURL(counterPartyId: String, url: String): Box[Boolean]
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 deletePhysicalLocation(counterPartyId : String): Box[Boolean]
def deleteCorporateLocation(counterPartyId : String): Box[Boolean]
def getCorporateLocation(counterPartyId : String): Box[GeoTag]
def getPhysicalLocation(counterPartyId : String): Box[GeoTag]
def getOpenCorporatesURL(counterPartyId : String): Box[String]
def getImageURL(counterPartyId : String): Box[String]
def getUrl(counterPartyId : String): Box[String]
def getMoreInfo(counterPartyId : String): Box[String]
def getPublicAlias(counterPartyId : String): Box[String]
def getPrivateAlias(counterPartyId : String): Box[String]
}
trait CounterpartyTrait {
@ -74,6 +97,8 @@ class RemotedataCounterpartiesCaseClasses {
case class getCounterpartyByIban(iban: String)
case class getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId)
case class createCounterparty(
createdByUserId: String, thisBankId: String, thisAccountId: String, thisViewId: String,
name: String,
@ -82,6 +107,42 @@ class RemotedataCounterpartiesCaseClasses {
otherBankRoutingAddress: String, isBeneficiary: Boolean)
case class checkCounterpartyAvailable(name: String, thisBankId: String, thisAccountId: String, thisViewId: String)
case class addPublicAlias(counterPartyId: String, alias: String)
case class addPrivateAlias(counterPartyId: String, alias: String)
case class addURL(counterPartyId: String, url: String)
case class addImageURL(counterPartyId : String, imageUrl: String)
case class addOpenCorporatesURL(counterPartyId : String, imageUrl: String)
case class addMoreInfo(counterPartyId : String, moreInfo: String)
case class addPhysicalLocation(counterPartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double)
case class addCorporateLocation(counterPartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double)
case class deletePhysicalLocation(counterPartyId : String)
case class deleteCorporateLocation(counterPartyId : String)
case class getCorporateLocation(counterPartyId : String)
case class getPhysicalLocation(counterPartyId : String)
case class getOpenCorporatesURL(counterPartyId : String)
case class getImageURL(counterPartyId : String)
case class getUrl(counterPartyId : String)
case class getMoreInfo(counterPartyId : String)
case class getPublicAlias(counterPartyId : String)
case class getPrivateAlias(counterPartyId : String)
}
object RemotedataCounterpartiesCaseClasses extends RemotedataCounterpartiesCaseClasses

View File

@ -113,8 +113,17 @@ object MapperCounterparties extends Counterparties with Loggable {
MappedCounterparty.find(By(MappedCounterparty.mCounterPartyId, counterPartyId))
}
override def getCounterpartyByIban(iban : String): Box[CounterpartyTrait] = {
MappedCounterparty.find(By(MappedCounterparty.mOtherAccountRoutingAddress, iban))
}
MappedCounterparty.find(
By(MappedCounterparty.mOtherAccountRoutingAddress, iban),
By(MappedCounterparty.mOtherAccountRoutingScheme, "IBAN")
)
}
override def getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId): Box[List[CounterpartyTrait]] = {
Full(MappedCounterparty.findAll(By(MappedCounterparty.mThisAccountId, thisAccountId.value),
By(MappedCounterparty.mThisBankId, thisBankId.value),
By(MappedCounterparty.mThisViewId, viewId.value)))
}
override def createCounterparty(createdByUserId: String,
thisBankId: String,
@ -170,6 +179,83 @@ object MapperCounterparties extends Counterparties with Loggable {
available
}
private def getCounterpartyMetadata(counterPartyId : String) : Box[MappedCounterpartyMetadata] = {
MappedCounterpartyMetadata.find(By(MappedCounterpartyMetadata.counterpartyId, counterPartyId))
}
override def getPublicAlias(counterPartyId : String): Box[String] = {
getCounterpartyMetadata(counterPartyId).map(_.publicAlias)
}
override def getPrivateAlias(counterPartyId : String): Box[String] = {
getCounterpartyMetadata(counterPartyId).map(_.privateAlias)
}
override def getPhysicalLocation(counterPartyId : String): Box[GeoTag] = {
getCounterpartyMetadata(counterPartyId).flatMap(_.physicalLocation.obj)
}
override def getOpenCorporatesURL(counterPartyId : String): Box[String] = {
getCounterpartyMetadata(counterPartyId).map(_.getOpenCorporatesURL)
}
override def getImageURL(counterPartyId : String): Box[String] = {
getCounterpartyMetadata(counterPartyId).map(_.getImageURL)
}
override def getUrl(counterPartyId : String): Box[String] = {
getCounterpartyMetadata(counterPartyId).map(_.getUrl)
}
override def getMoreInfo(counterPartyId : String): Box[String] = {
getCounterpartyMetadata(counterPartyId).map(_.getMoreInfo)
}
override def getCorporateLocation(counterPartyId : String): Box[GeoTag] = {
getCounterpartyMetadata(counterPartyId).flatMap(_.corporateLocation.obj)
}
override def addPublicAlias(counterPartyId : String, alias: String): Box[Boolean] = {
getCounterpartyMetadata(counterPartyId).map(_.publicAlias(alias).save())
}
override def addPrivateAlias(counterPartyId : String, alias: String): Box[Boolean] = {
getCounterpartyMetadata(counterPartyId).map(_.privateAlias(alias).save())
}
override def addURL(counterPartyId : String, url: String): Box[Boolean] = {
getCounterpartyMetadata(counterPartyId).map(_.url(url).save())
}
override def addImageURL(counterPartyId : String, url: String): Box[Boolean] = {
getCounterpartyMetadata(counterPartyId).map(_.imageUrl(url).save())
}
override def addOpenCorporatesURL(counterPartyId : String, url: String): Box[Boolean] = {
getCounterpartyMetadata(counterPartyId).map(_.openCorporatesUrl(url).save())
}
override def addMoreInfo(counterPartyId : String, moreInfo: String): Box[Boolean] = {
getCounterpartyMetadata(counterPartyId).map(_.moreInfo(moreInfo).save())
}
override def addPhysicalLocation(counterPartyId : String, userId: UserId, 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] = {
getCounterpartyMetadata(counterPartyId).map(_.setCorporateLocation(userId, datePosted, longitude, latitude))
}
override def deletePhysicalLocation(counterPartyId : String): Box[Boolean] = {
getCounterpartyMetadata(counterPartyId).flatMap(_.physicalLocation.obj).map(_.delete_!)
}
override def deleteCorporateLocation(counterPartyId : String): Box[Boolean] = {
getCounterpartyMetadata(counterPartyId).flatMap(_.corporateLocation.obj).map(_.delete_!)
}
}
class MappedCounterpartyMetadata extends CounterpartyMetadata with LongKeyedMapper[MappedCounterpartyMetadata] with IdPK with CreatedUpdated {

View File

@ -1,7 +1,9 @@
package code.metadata.counterparties
import code.model.{AccountId, BankId, CounterpartyMetadata, Counterparty}
import net.liftweb.common.{Box, Loggable, Empty}
import java.util.Date
import code.model._
import net.liftweb.common.{Box, Empty, Loggable}
import com.mongodb.QueryBuilder
import net.liftweb.util.Helpers.tryo
import net.liftweb.common.Full
@ -124,4 +126,25 @@ object MongoCounterparties extends Counterparties with Loggable {
thisAccountId: String,
thisViewId: String
): Boolean = false
override def getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId): Box[List[CounterpartyTrait]] = ???
override def addPublicAlias(counterPartyId : String, alias: String): Box[Boolean] = ???
override def addPrivateAlias(counterPartyId : String, alias: String): Box[Boolean] = ???
override def addURL(counterPartyId : String, url: String): Box[Boolean] = ???
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 deletePhysicalLocation(counterPartyId : String): Box[Boolean] = ???
override def deleteCorporateLocation(counterPartyId : String): Box[Boolean] = ???
override def getCorporateLocation(counterPartyId : String): Box[GeoTag] = ???
override def getPhysicalLocation(counterPartyId : String): Box[GeoTag] = ???
override def getOpenCorporatesURL(counterPartyId : String): Box[String] = ???
override def getImageURL(counterPartyId : String): Box[String] = ???
override def getUrl(counterPartyId : String): Box[String] = ???
override def getMoreInfo(counterPartyId : String): Box[String] = ???
override def getPublicAlias(counterPartyId : String): Box[String] = ???
override def getPrivateAlias(counterPartyId : String): Box[String] = ???
}

View File

@ -469,12 +469,12 @@ trait BankAccount {
Failure({"user: " + userDoingTheCreate.idGivenByProvider + " at provider " + userDoingTheCreate.provider + " does not have owner access"})
} else {
val view = Views.views.vend.createView(BankAccountUID(this.bankId,this.accountId), v)
if(view.isDefined) {
log.info("user: " + userDoingTheCreate.idGivenByProvider + " at provider " + userDoingTheCreate.provider + " created view: " + view.get +
" for account " + accountId + "at bank " + bankId)
}
view
}
}
@ -484,12 +484,12 @@ trait BankAccount {
Failure({"user: " + userDoingTheUpdate.idGivenByProvider + " at provider " + userDoingTheUpdate.provider + " does not have owner access"})
} else {
val view = Views.views.vend.updateView(BankAccountUID(this.bankId,this.accountId), viewId, v)
if(view.isDefined) {
log.info("user: " + userDoingTheUpdate.idGivenByProvider + " at provider " + userDoingTheUpdate.provider + " updated view: " + view.get +
" for account " + accountId + "at bank " + bankId)
}
view
}
}

View File

@ -34,6 +34,8 @@ Berlin 13359, Germany
package code.model
import java.util.Date
import code.metadata.counterparties.Counterparties
import code.util.Helper
import net.liftweb.common._
import code.views.Views
@ -501,14 +503,14 @@ trait View {
if (usePublicAliasIfOneExists) {
val publicAlias = otherBankAccount.metadata.getPublicAlias
val publicAlias = Counterparties.counterparties.vend.getPublicAlias(otherBankAccount.counterPartyId).getOrElse("Unknown")
if (! publicAlias.isEmpty ) AccountName(publicAlias, PublicAlias)
else AccountName(realName, NoAlias)
} else if (usePrivateAliasIfOneExists) {
val privateAlias = otherBankAccount.metadata.getPrivateAlias
val privateAlias = Counterparties.counterparties.vend.getPrivateAlias(otherBankAccount.counterPartyId).getOrElse("Unknown")
if (! privateAlias.isEmpty) AccountName(privateAlias, PrivateAlias)
else AccountName(realName, PrivateAlias)
@ -541,20 +543,20 @@ trait View {
val otherAccountMetadata =
if(canSeeOtherAccountMetadata){
//other bank account metadata
val moreInfo = moderateField(canSeeMoreInfo,otherBankAccount.metadata.getMoreInfo)
val url = moderateField(canSeeUrl, otherBankAccount.metadata.getUrl)
val imageUrl = moderateField(canSeeImageUrl, otherBankAccount.metadata.getImageURL)
val openCorporatesUrl = moderateField (canSeeOpenCorporatesUrl, otherBankAccount.metadata.getOpenCorporatesURL)
val corporateLocation : Option[Option[GeoTag]] = moderateField(canSeeCorporateLocation, otherBankAccount.metadata.getCorporateLocation)
val physicalLocation : Option[Option[GeoTag]] = moderateField(canSeePhysicalLocation, otherBankAccount.metadata.getPhysicalLocation)
val moreInfo = moderateField(canSeeMoreInfo, Counterparties.counterparties.vend.getMoreInfo(otherBankAccount.counterPartyId).getOrElse("Unknown"))
val url = moderateField(canSeeUrl, Counterparties.counterparties.vend.getUrl(otherBankAccount.counterPartyId).getOrElse("Unknown"))
val imageUrl = moderateField(canSeeImageUrl, Counterparties.counterparties.vend.getImageURL(otherBankAccount.counterPartyId).getOrElse("Unknown"))
val openCorporatesUrl = moderateField (canSeeOpenCorporatesUrl, Counterparties.counterparties.vend.getOpenCorporatesURL(otherBankAccount.counterPartyId).getOrElse("Unknown"))
val corporateLocation : Option[Option[GeoTag]] = moderateField(canSeeCorporateLocation, Counterparties.counterparties.vend.getCorporateLocation(otherBankAccount.counterPartyId).toOption)
val physicalLocation : Option[Option[GeoTag]] = moderateField(canSeePhysicalLocation, Counterparties.counterparties.vend.getPhysicalLocation(otherBankAccount.counterPartyId).toOption)
val addMoreInfo = moderateField(canAddMoreInfo, otherBankAccount.metadata.addMoreInfo)
val addURL = moderateField(canAddURL, otherBankAccount.metadata.addURL)
val addImageURL = moderateField(canAddImageURL, otherBankAccount.metadata.addImageURL)
val addOpenCorporatesUrl = moderateField(canAddOpenCorporatesUrl, otherBankAccount.metadata.addOpenCorporatesURL)
val addCorporateLocation = moderateField(canAddCorporateLocation, otherBankAccount.metadata.addCorporateLocation)
val addPhysicalLocation = moderateField(canAddPhysicalLocation, otherBankAccount.metadata.addPhysicalLocation)
val publicAlias = moderateField(canSeePublicAlias, otherBankAccount.metadata.getPublicAlias)
val privateAlias = moderateField(canSeePrivateAlias, otherBankAccount.metadata.getPrivateAlias)
val publicAlias = moderateField(canSeePublicAlias, Counterparties.counterparties.vend.getPublicAlias(otherBankAccount.counterPartyId).getOrElse("Unknown"))
val privateAlias = moderateField(canSeePrivateAlias, Counterparties.counterparties.vend.getPrivateAlias(otherBankAccount.counterPartyId).getOrElse("Unknown"))
val addPublicAlias = moderateField(canAddPublicAlias, otherBankAccount.metadata.addPublicAlias)
val addPrivateAlias = moderateField(canAddPrivateAlias, otherBankAccount.metadata.addPrivateAlias)
val deleteCorporateLocation = moderateField(canDeleteCorporateLocation, otherBankAccount.metadata.deleteCorporateLocation)

View File

@ -33,6 +33,9 @@ object RemotedataCounterparties extends ActorInit with Counterparties {
override def getCounterpartyByIban(iban: String): Box[CounterpartyTrait] =
extractFutureToBox(actor ? cc.getCounterpartyByIban(iban: String))
override def getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId): Box[List[CounterpartyTrait]] =
extractFutureToBox(actor ? cc.getCounterparties(thisBankId, thisAccountId, viewId))
override def createCounterparty(createdByUserId: String,
thisBankId: String,
@ -55,4 +58,58 @@ object RemotedataCounterparties extends ActorInit with Counterparties {
override def checkCounterpartyAvailable(name: String, thisBankId: String, thisAccountId: String, thisViewId: String): Boolean =
extractFuture(actor ? cc.checkCounterpartyAvailable(name: String, thisBankId: String, thisAccountId: String, thisViewId: String))
override def getCorporateLocation(counterPartyId: String): Box[GeoTag] =
extractFutureToBox(actor ? cc.getCorporateLocation(counterPartyId))
override def getPublicAlias(counterPartyId: String): Box[String] =
extractFutureToBox(actor ? cc.getPublicAlias(counterPartyId))
override def getPrivateAlias(counterPartyId: String): Box[String] =
extractFutureToBox(actor ? cc.getPrivateAlias(counterPartyId))
override def getPhysicalLocation(counterPartyId: String): Box[GeoTag] =
extractFutureToBox(actor ? cc.getPhysicalLocation(counterPartyId))
override def getOpenCorporatesURL(counterPartyId: String): Box[String] =
extractFutureToBox(actor ? cc.getOpenCorporatesURL(counterPartyId))
override def getImageURL(counterPartyId: String): Box[String] =
extractFutureToBox(actor ? cc.getImageURL(counterPartyId))
override def getUrl(counterPartyId: String): Box[String] =
extractFutureToBox(actor ? cc.getUrl(counterPartyId))
override def getMoreInfo(counterPartyId: String): Box[String] =
extractFutureToBox(actor ? cc.getMoreInfo(counterPartyId))
override def addPublicAlias(counterPartyId: String, alias: String): Box[Boolean] =
extractFutureToBox(actor ? cc.addPublicAlias(counterPartyId, alias))
override def addPrivateAlias(counterPartyId: String, alias: String): Box[Boolean] =
extractFutureToBox(actor ? cc.addPrivateAlias(counterPartyId, alias))
override def addURL(counterPartyId: String, url: String): Box[Boolean] =
extractFutureToBox(actor ? cc.addURL(counterPartyId, url))
override def addImageURL(counterPartyId: String, url: String): Box[Boolean] =
extractFutureToBox(actor ? cc.addImageURL(counterPartyId, url))
override def addOpenCorporatesURL(counterPartyId: String, url: String): Box[Boolean] =
extractFutureToBox(actor ? cc.addOpenCorporatesURL(counterPartyId, url))
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] =
extractFutureToBox(actor ? cc.addPhysicalLocation(counterPartyId, userId, datePosted, longitude, latitude))
override def addCorporateLocation(counterPartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double): Box[Boolean] =
extractFutureToBox(actor ? cc.addCorporateLocation(counterPartyId, userId, datePosted, longitude, latitude))
override def deletePhysicalLocation(counterPartyId: String): Box[Boolean] =
extractFutureToBox(actor ? cc.deletePhysicalLocation(counterPartyId))
override def deleteCorporateLocation(counterPartyId: String): Box[Boolean] =
extractFutureToBox(actor ? cc.deleteCorporateLocation(counterPartyId))
}

View File

@ -1,12 +1,12 @@
package code.remotedata
import java.util.Date
import akka.actor.Actor
import akka.event.Logging
import code.metadata.counterparties.{MapperCounterparties, RemotedataCounterpartiesCaseClasses}
import code.model._
import scala.concurrent.duration._
class RemotedataCounterpartiesActor extends Actor with ActorHelper {
@ -47,10 +47,86 @@ class RemotedataCounterpartiesActor extends Actor with ActorHelper {
logger.info("getCounterparty(" + counterPartyId +")")
sender ! extractResult(mapper.getCounterparty(counterPartyId: String))
case cc.getCounterparties(thisBankId: BankId, thisAccountId: AccountId, viewId: ViewId) =>
logger.info("getCounterparties(" + thisBankId +")")
sender ! extractResult(mapper.getCounterparties(thisBankId, thisAccountId, viewId))
case cc.getCounterpartyByIban(iban: String) =>
logger.info("getOrCreateMetadata(" + iban +")")
sender ! extractResult(mapper.getCounterpartyByIban(iban: String))
case cc.getPublicAlias(counterPartyId: String) =>
logger.info("getPublicAlias(" + counterPartyId + ")")
sender ! extractResult(mapper.getPublicAlias(counterPartyId))
case cc.getPrivateAlias(counterPartyId: String) =>
logger.info("getPrivateAlias(" + counterPartyId + ")")
sender ! extractResult(mapper.getPrivateAlias(counterPartyId))
case cc.getCorporateLocation(counterPartyId: String) =>
logger.info("getCorporateLocation(" + counterPartyId + ")")
sender ! extractResult(mapper.getCorporateLocation(counterPartyId))
case cc.getPhysicalLocation(counterPartyId: String) =>
logger.info("getPhysicalLocation(" + counterPartyId + ")")
sender ! extractResult(mapper.getPhysicalLocation(counterPartyId))
case cc.getOpenCorporatesURL(counterPartyId: String) =>
logger.info("getOpenCorporatesURL(" + counterPartyId + ")")
sender ! extractResult(mapper.getOpenCorporatesURL(counterPartyId))
case cc.getImageURL(counterPartyId: String) =>
logger.info("getImageURL(" + counterPartyId + ")")
sender ! extractResult(mapper.getImageURL(counterPartyId))
case cc.getUrl(counterPartyId: String) =>
logger.info("getUrl(" + counterPartyId + ")")
sender ! extractResult(mapper.getUrl(counterPartyId))
case cc.getMoreInfo(counterPartyId: String) =>
logger.info("getMoreInfo(" + counterPartyId + ")")
sender ! extractResult(mapper.getMoreInfo(counterPartyId))
case cc.addPrivateAlias(counterPartyId: String, alias: String) =>
logger.info("addPrivateAlias(" + counterPartyId + ", " + alias +")")
sender ! extractResult(mapper.addPrivateAlias(counterPartyId, alias))
case cc.addPublicAlias(counterPartyId: String, alias: String) =>
logger.info("addPublicAlias(" + counterPartyId + ", " + alias +")")
sender ! extractResult(mapper.addPublicAlias(counterPartyId, alias))
case cc.addURL(counterPartyId: String, url: String) =>
logger.info("addURL(" + counterPartyId + ", " + url +")")
sender ! extractResult(mapper.addURL(counterPartyId, url))
case cc.addImageURL(counterPartyId: String, url: String) =>
logger.info("addImageURL(" + counterPartyId + ", " + url +")")
sender ! extractResult(mapper.addImageURL(counterPartyId, url))
case cc.addOpenCorporatesURL(counterPartyId: String, url: String) =>
logger.info("addOpenCorporatesURL(" + counterPartyId + ", " + url +")")
sender ! extractResult(mapper.addOpenCorporatesURL(counterPartyId, url))
case cc.addMoreInfo(counterPartyId : String, moreInfo: String) =>
logger.info("addMoreInfo(" + counterPartyId + ", " + moreInfo +")")
sender ! extractResult(mapper.addMoreInfo(counterPartyId, moreInfo))
case cc.addPhysicalLocation(counterPartyId : String, userId: UserId, datePosted : Date, longitude : Double, latitude : Double) =>
logger.info("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) =>
logger.info("addCorporateLocation(" + counterPartyId + ", " + userId + ", " + datePosted + ", " + longitude + ", " + latitude +")")
sender ! extractResult(mapper.addCorporateLocation(counterPartyId, userId, datePosted, longitude, latitude))
case cc.deleteCorporateLocation(counterPartyId: String) =>
logger.info("deleteCorporateLocation(" + counterPartyId + ")")
sender ! extractResult(mapper.deleteCorporateLocation(counterPartyId))
case cc.deletePhysicalLocation(counterPartyId: String) =>
logger.info("deletePhysicalLocation(" + counterPartyId + ")")
sender ! extractResult(mapper.deletePhysicalLocation(counterPartyId))
case message => logger.info("[AKKA ACTOR ERROR - REQUEST NOT RECOGNIZED] " + message)
}

View File

@ -8,11 +8,11 @@ import code.accountholder.AccountHolders
import code.model._
import code.model.dataAccess._
import net.liftweb.common.Box
import net.liftweb.mapper.{By, MappedString, MetaMapper}
import net.liftweb.mapper.{By, MetaMapper}
import net.liftweb.util.Props
import net.liftweb.util.Helpers._
import code.entitlement.{Entitlement, MappedEntitlement}
import code.metadata.counterparties.{CounterpartyTrait, MappedCounterparty, MappedCounterpartyMetadata}
import code.metadata.counterparties.{Counterparties, CounterpartyTrait}
import code.transaction.MappedTransaction
import code.views.Views
@ -31,17 +31,18 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
.national_identifier(randomString(5)).saveMe
}
override protected def createCounterparty(bankId: String, accountId: String, accountRoutingAddress: String, otherAccountRoutingScheme: String, isBeneficiary: Boolean, counterpartyId: String): CounterpartyTrait = {
MappedCounterparty.create.
mCounterPartyId(counterpartyId).
mName(UUID.randomUUID().toString).
mOtherAccountRoutingAddress(accountRoutingAddress).
mOtherAccountRoutingAddress(accountId).
mOtherAccountRoutingScheme(otherAccountRoutingScheme).
mOtherBankRoutingScheme("OBP").
mOtherBankRoutingAddress(bankId).
mIsBeneficiary(isBeneficiary).
saveMe
override protected def createCounterparty(bankId: String, accountId: String, accountRoutingAddress: String, otherAccountRoutingScheme: String, isBeneficiary: Boolean, createdByUserId: String): CounterpartyTrait = {
Counterparties.counterparties.vend.createCounterparty(createdByUserId = createdByUserId,
thisBankId = bankId,
thisAccountId = accountId,
thisViewId = "",
name = UUID.randomUUID().toString,
otherAccountRoutingAddress = accountId,
otherAccountRoutingScheme = otherAccountRoutingScheme,
otherBankRoutingScheme = "OBP",
otherBankRoutingAddress = bankId,
isBeneficiary = isBeneficiary
).get
}
// TODO: Should return an option or box so can test if the insert succeeded

View File

@ -32,7 +32,7 @@ class CreateCounterpartyTest extends V210ServerSetup with DefaultUsers {
scenario("There is a user has the owner view and the BankAccount") {
Given("The user ower access and BankAccount")
val testBank = createBank("transactions-test-bank")
val testBank = createBank("transactions-test-bank1")
val bankId = testBank.bankId
val accountId = AccountId("__acc1")
val viewId =ViewId("owner")

View File

@ -32,10 +32,10 @@ class TransactionRequestsTest extends ServerSetupWithTestData with DefaultUsers
val sharedChargePolicy = ChargePolicy.withName("SHARED").toString
var transactionRequestType: String = transactionRequestTypeInput
val testBank = createBank("transactions-test-bank")
val testBank = createBank("__transactions-test-bank2")
val bankId = testBank.bankId
val accountId1 = AccountId("__acc1")
val accountId2 = AccountId("__acc2")
val accountId1 = AccountId("__acc1__")
val accountId2 = AccountId("__acc2__")
var amt = BigDecimal("12.50")
var fromCurrency = "AED"