From d52a24bf6a904ba6db73cf1b4c79d6c473bc8d5f Mon Sep 17 00:00:00 2001 From: hongwei Date: Fri, 4 Apr 2025 14:13:48 +0200 Subject: [PATCH 1/6] feature/added getRegulatedEntities and getRegulatedEntityByEntityId to RabbitMQConnector_vOct2024 --- .../api/util/newstyle/RegulatedEntity.scala | 29 ++--- .../scala/code/api/v5_1_0/APIMethods510.scala | 2 +- .../scala/code/bankconnectors/Connector.scala | 9 +- .../bankconnectors/LocalMappedConnector.scala | 18 ++++ .../generator/ConnectorBuilderUtil.scala | 2 + .../rabbitmq/RabbitMQConnector_vOct2024.scala | 101 ++++++++++++++++-- .../commons/dto/JsonsTransfer.scala | 8 ++ .../commons/model/CommonModel.scala | 15 +++ 8 files changed, 162 insertions(+), 22 deletions(-) diff --git a/obp-api/src/main/scala/code/api/util/newstyle/RegulatedEntity.scala b/obp-api/src/main/scala/code/api/util/newstyle/RegulatedEntity.scala index 58f5f11bd5..c0002f2398 100644 --- a/obp-api/src/main/scala/code/api/util/newstyle/RegulatedEntity.scala +++ b/obp-api/src/main/scala/code/api/util/newstyle/RegulatedEntity.scala @@ -8,6 +8,10 @@ import code.model.{AppType, Consumer} import code.regulatedentities.MappedRegulatedEntityProvider import com.openbankproject.commons.model.RegulatedEntityTrait import net.liftweb.common.Box +import code.bankconnectors.Connector +import code.api.util.ErrorMessages.{InvalidConnectorResponse} +import code.api.util.{APIUtil, CallContext} +import com.github.dwickern.macros.NameOf.nameOf import scala.concurrent.Future @@ -48,22 +52,19 @@ object RegulatedEntityNewStyle { } } - def getRegulatedEntitiesNewStyle(callContext: Option[CallContext]): OBPReturnType[List[RegulatedEntityTrait]] = { - Future { - MappedRegulatedEntityProvider.getRegulatedEntities() - } map { - (_, callContext) + def getRegulatedEntitiesNewStyle( + callContext: Option[CallContext] + ): OBPReturnType[List[RegulatedEntityTrait]] = { + Connector.connector.vend.getRegulatedEntities(callContext: Option[CallContext]) map { i => + (unboxFullOrFail(i._1, callContext,s"$InvalidConnectorResponse ${nameOf(Connector.connector.vend.getRegulatedEntities _)} ", 400 ), i._2) } } - def getRegulatedEntityByEntityIdNewStyle(id: String, - callContext: Option[CallContext] - ): OBPReturnType[RegulatedEntityTrait] = { - Future { - MappedRegulatedEntityProvider.getRegulatedEntityByEntityId(id) - } map { - (_, callContext) - } map { - x => (unboxFullOrFail(x._1, callContext, RegulatedEntityNotFound, 404), x._2) + def getRegulatedEntityByEntityIdNewStyle( + id: String, + callContext: Option[CallContext] + ): OBPReturnType[RegulatedEntityTrait] = { + Connector.connector.vend.getRegulatedEntityByEntityId(id, callContext: Option[CallContext]) map { i => + (unboxFullOrFail(i._1, callContext,s"$InvalidConnectorResponse ${nameOf(Connector.connector.vend.getRegulatedEntityByEntityId _)} ", 400 ), i._2) } } def deleteRegulatedEntityNewStyle(id: String, diff --git a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala index 4dc6f7d08f..d96342769d 100644 --- a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala +++ b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala @@ -174,7 +174,7 @@ trait APIMethods510 { """Get Regulated Entity By REGULATED_ENTITY_ID """, EmptyBody, - regulatedEntitiesJsonV510, + regulatedEntityJsonV510, List(UnknownError), apiTagDirectory :: apiTagApi :: Nil) diff --git a/obp-api/src/main/scala/code/bankconnectors/Connector.scala b/obp-api/src/main/scala/code/bankconnectors/Connector.scala index 61c483d004..fdf9efe7d3 100644 --- a/obp-api/src/main/scala/code/bankconnectors/Connector.scala +++ b/obp-api/src/main/scala/code/bankconnectors/Connector.scala @@ -1885,5 +1885,12 @@ trait Connector extends MdcLoggable { callContext: Option[CallContext] ): OBPReturnType[Box[Boolean]] = Future{(Failure(setUnimplementedError(nameOf(deleteCounterpartyLimit _))), callContext)} - + def getRegulatedEntities( + callContext: Option[CallContext] + ): OBPReturnType[Box[List[RegulatedEntityTrait]]] = Future{(Failure(setUnimplementedError(nameOf(getRegulatedEntities _))), callContext)} + + def getRegulatedEntityByEntityId( + regulatedEntityId: String, + callContext: Option[CallContext] + ): OBPReturnType[Box[RegulatedEntityTrait]] = Future{(Failure(setUnimplementedError(nameOf(getRegulatedEntityByEntityId _))), callContext)} } diff --git a/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala b/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala index b9e27ab9a9..0ee18569f5 100644 --- a/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala +++ b/obp-api/src/main/scala/code/bankconnectors/LocalMappedConnector.scala @@ -49,6 +49,7 @@ import code.productcollection.ProductCollectionX import code.productcollectionitem.ProductCollectionItems import code.productfee.ProductFeeX import code.products.MappedProduct +import code.regulatedentities.MappedRegulatedEntityProvider import code.standingorders.StandingOrders import com.openbankproject.commons.model.StandingOrderTrait import code.taxresidence.TaxResidenceX @@ -5345,5 +5346,22 @@ object LocalMappedConnector extends Connector with MdcLoggable { counterpartyId: String) map { (_, callContext) } + + override def getRegulatedEntities( + callContext: Option[CallContext] + ): OBPReturnType[Box[List[RegulatedEntityTrait]]] = Future { + tryo {MappedRegulatedEntityProvider.getRegulatedEntities()} + } map { + (_, callContext) + } + + override def getRegulatedEntityByEntityId( + regulatedEntityId: String, + callContext: Option[CallContext] + ): OBPReturnType[Box[RegulatedEntityTrait]] = Future { + MappedRegulatedEntityProvider.getRegulatedEntityByEntityId(regulatedEntityId) + } map { + (_, callContext) + } } diff --git a/obp-api/src/main/scala/code/bankconnectors/generator/ConnectorBuilderUtil.scala b/obp-api/src/main/scala/code/bankconnectors/generator/ConnectorBuilderUtil.scala index d3cbd332ae..8c58ecc382 100644 --- a/obp-api/src/main/scala/code/bankconnectors/generator/ConnectorBuilderUtil.scala +++ b/obp-api/src/main/scala/code/bankconnectors/generator/ConnectorBuilderUtil.scala @@ -435,6 +435,8 @@ object ConnectorBuilderUtil { "getTransactionRequestTypeCharges", "getAccountsHeld", "getAccountsHeldByUser", + "getRegulatedEntities", + "getRegulatedEntityByEntityId", ).distinct /** diff --git a/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala b/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala index bb0fa04bee..ce20454fbc 100644 --- a/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala +++ b/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala @@ -60,17 +60,15 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable { // If we want to add a new message format, create a new file e.g. March2017_messages.scala // Then add a suffix to the connector value i.e. instead of RabbitMq we might have rest_vMar2019. // Then in this file, populate the different case classes depending on the connector name and send to CBS - val messageFormat: String = "Oct2024" + val messageFormat: String = "rabbitmq_vOct2024" override val messageDocs = ArrayBuffer[MessageDoc]() val authInfoExample = AuthInfo(userId = "userId", username = "username", cbsToken = "cbsToken") val errorCodeExample = "INTERNAL-OBP-ADAPTER-6001: ..." - val connectorName = "rabbitmq_vOct2024" - //---------------- dynamic start -------------------please don't modify this line -// ---------- created on 2025-01-14T19:52:36Z +// ---------- created on 2025-04-04T14:01:22Z messageDocs += getAdapterInfoDoc def getAdapterInfoDoc = MessageDoc( @@ -7070,8 +7068,99 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable { response.map(convertToTuple[Boolean](callContext)) } -// ---------- created on 2025-01-14T19:52:36Z -//---------------- dynamic end ---------------------please don't modify this line + messageDocs += getRegulatedEntitiesDoc + def getRegulatedEntitiesDoc = MessageDoc( + process = "obp.getRegulatedEntities", + messageFormat = messageFormat, + description = "Get Regulated Entities", + outboundTopic = None, + inboundTopic = None, + exampleOutboundMessage = ( + OutBoundGetRegulatedEntities(MessageDocsSwaggerDefinitions.outboundAdapterCallContext) + ), + exampleInboundMessage = ( + InBoundGetRegulatedEntities(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext, + status=MessageDocsSwaggerDefinitions.inboundStatus, + data = List(RegulatedEntityTraitCommons(entityId = "0af807d7-3c39-43ef-9712-82bcfde1b9ca", + certificateAuthorityCaOwnerId = "CY_CBC", + entityName = "EXAMPLE COMPANY LTD", + entityCode = "PSD_PICY_CBC!12345", + entityCertificatePublicKey = + """-----BEGIN CERTIFICATE-----MIICsjCCAZqgAwIBAgIGAYwQ62R0MA0GCSqGSIb3DQEBCwUAMBoxGDAWBgNVBAMMD2 + |FwcC5leGFtcGxlLmNvbTAeFw0yMzExMjcxMzE1MTFaFw0yNTExMjYxMzE1MTFaMBoxGDAWBgNVBAMMD2FwcC5leGFtcGxlLmNvbTCCASIwDQ + |YJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK9WIodZHWzKyCcf9YfWEhPURbfO6zKuMqzHN27GdqHsVVEGxP4F/J4mso+0ENcRr6ur4u81iRE + |aVdCc40rHDHVJNEtniD8Icbz7tcsqAewIVhc/q6WXGqImJpCq7hA0m247dDsaZT0lb/MVBiMoJxDEmAE/GYYnWTEn84R35WhJsMvuQ7QmLvNg6 + |RkChY6POCT/YKe9NKwa1NqI1U+oA5RFzAaFtytvZCE3jtp+aR0brL7qaGfgxm6B7dEpGyhg0NcVCV7xMQNq2JxZTVdAr6lcsRGaAFulakmW3aN + |nmK+L35Wu8uW+OxNxwUuC6f3b4FVBa276FMuUTRfu7gc+k6kCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAAU5CjEyAoyTn7PgFpQD48ZNPuUsEQ + |19gzYgJvHMzFIoZ7jKBodjO5mCzWBcR7A4mpeAsdyiNBl2sTiZscSnNqxk61jVzP5Ba1D7XtOjjr7+3iqowrThj6BY40QqhYh/6BSY9fDzVZQi + |Hnvlo6ZUM5kUK6OavZOovKlp5DIl5sGqoP0qAJnpQ4nhB2WVVsKfPlOXc+2KSsbJ23g9l8zaTMr+X0umlvfEKqyEl1Fa2L1dO0y/KFQ+ILmxcZ + |LpRdq1hRAjd0quq9qGC8ucXhRWDgM4hslVpau0da68g0aItWNez3mc5lB82b3dcZpFMzO41bgw7gvw10AvvTfQDqEYIuQ==-----END CERTIFICATE----- """.stripMargin, + entityType = "PSD_PI", + entityAddress = "EXAMPLE COMPANY LTD, 5 SOME STREET", + entityTownCity = "SOME CITY", + entityPostCode = "1060", + entityCountry = "CY", + entityWebSite = "www.example.com", + services = "PISP,AISP"))) + ), + adapterImplementation = Some(AdapterImplementation("- Core", 1)) + ) + + override def getRegulatedEntities(callContext: Option[CallContext]): OBPReturnType[Box[List[RegulatedEntityTrait]]] = { + import com.openbankproject.commons.dto.{InBoundGetRegulatedEntities => InBound, OutBoundGetRegulatedEntities => OutBound} + val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull) + val response: Future[Box[InBound]] = sendRequest[InBound]("obp_get_regulated_entities", req, callContext) + response.map(convertToTuple[List[RegulatedEntityTraitCommons]](callContext)) + } + + messageDocs += getRegulatedEntityByEntityIdDoc + def getRegulatedEntityByEntityIdDoc = MessageDoc( + process = "obp.getRegulatedEntityByEntityId", + messageFormat = messageFormat, + description = "Get Regulated Entity By Entity Id", + outboundTopic = None, + inboundTopic = None, + exampleOutboundMessage = ( + OutBoundGetRegulatedEntityByEntityId(outboundAdapterCallContext=MessageDocsSwaggerDefinitions.outboundAdapterCallContext, + regulatedEntityId="string") + ), + exampleInboundMessage = ( + InBoundGetRegulatedEntityByEntityId(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext, + status = MessageDocsSwaggerDefinitions.inboundStatus, + data = RegulatedEntityTraitCommons(entityId = "0af807d7-3c39-43ef-9712-82bcfde1b9ca", + certificateAuthorityCaOwnerId = "CY_CBC", + entityName = "EXAMPLE COMPANY LTD", + entityCode = "PSD_PICY_CBC!12345", + entityCertificatePublicKey = + """-----BEGIN CERTIFICATE-----MIICsjCCAZqgAwIBAgIGAYwQ62R0MA0GCSqGSIb3DQEBCwUAMBoxGDAWBgNVBAMMD2 + |FwcC5leGFtcGxlLmNvbTAeFw0yMzExMjcxMzE1MTFaFw0yNTExMjYxMzE1MTFaMBoxGDAWBgNVBAMMD2FwcC5leGFtcGxlLmNvbTCCASIwDQ + |YJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK9WIodZHWzKyCcf9YfWEhPURbfO6zKuMqzHN27GdqHsVVEGxP4F/J4mso+0ENcRr6ur4u81iRE + |aVdCc40rHDHVJNEtniD8Icbz7tcsqAewIVhc/q6WXGqImJpCq7hA0m247dDsaZT0lb/MVBiMoJxDEmAE/GYYnWTEn84R35WhJsMvuQ7QmLvNg6 + |RkChY6POCT/YKe9NKwa1NqI1U+oA5RFzAaFtytvZCE3jtp+aR0brL7qaGfgxm6B7dEpGyhg0NcVCV7xMQNq2JxZTVdAr6lcsRGaAFulakmW3aN + |nmK+L35Wu8uW+OxNxwUuC6f3b4FVBa276FMuUTRfu7gc+k6kCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAAU5CjEyAoyTn7PgFpQD48ZNPuUsEQ + |19gzYgJvHMzFIoZ7jKBodjO5mCzWBcR7A4mpeAsdyiNBl2sTiZscSnNqxk61jVzP5Ba1D7XtOjjr7+3iqowrThj6BY40QqhYh/6BSY9fDzVZQi + |Hnvlo6ZUM5kUK6OavZOovKlp5DIl5sGqoP0qAJnpQ4nhB2WVVsKfPlOXc+2KSsbJ23g9l8zaTMr+X0umlvfEKqyEl1Fa2L1dO0y/KFQ+ILmxcZ + |LpRdq1hRAjd0quq9qGC8ucXhRWDgM4hslVpau0da68g0aItWNez3mc5lB82b3dcZpFMzO41bgw7gvw10AvvTfQDqEYIuQ==-----END CERTIFICATE----- """.stripMargin, + entityType = "PSD_PI", + entityAddress = "EXAMPLE COMPANY LTD, 5 SOME STREET", + entityTownCity = "SOME CITY", + entityPostCode = "1060", + entityCountry = "CY", + entityWebSite = "www.example.com", + services = "PISP,AISP")) + ), + adapterImplementation = Some(AdapterImplementation("- Core", 1)) + ) + + override def getRegulatedEntityByEntityId(regulatedEntityId: String, callContext: Option[CallContext]): OBPReturnType[Box[RegulatedEntityTrait]] = { + import com.openbankproject.commons.dto.{InBoundGetRegulatedEntityByEntityId => InBound, OutBoundGetRegulatedEntityByEntityId => OutBound} + val req = OutBound(callContext.map(_.toOutboundAdapterCallContext).orNull, regulatedEntityId) + val response: Future[Box[InBound]] = sendRequest[InBound]("obp_get_regulated_entity_by_entity_id", req, callContext) + response.map(convertToTuple[RegulatedEntityTraitCommons](callContext)) + } + +// ---------- created on 2025-04-04T14:01:22Z +//---------------- dynamic end ---------------------please don't modify this line private val availableOperation = DynamicEntityOperation.values.map(it => s""""$it"""").mkString("[", ", ", "]") diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala b/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala index 4a712d7912..b14ab8e682 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/dto/JsonsTransfer.scala @@ -43,6 +43,14 @@ trait InBoundTrait[T] { //--------generated +case class OutBoundGetRegulatedEntities (outboundAdapterCallContext: OutboundAdapterCallContext) extends TopicTrait +case class InBoundGetRegulatedEntities (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: List[RegulatedEntityTraitCommons]) extends InBoundTrait[List[RegulatedEntityTraitCommons]] + + +case class OutBoundGetRegulatedEntityByEntityId (outboundAdapterCallContext: OutboundAdapterCallContext, + regulatedEntityId: String) extends TopicTrait +case class InBoundGetRegulatedEntityByEntityId (inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: RegulatedEntityTraitCommons) extends InBoundTrait[RegulatedEntityTraitCommons] + case class OutBoundGetObpConnectorLoopback(outboundAdapterCallContext: OutboundAdapterCallContext) extends TopicTrait case class InBoundGetObpConnectorLoopback(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: ObpApiLoopback) extends InBoundTrait[ObpApiLoopback] diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala b/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala index 071c84bd2c..49c4170259 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala @@ -890,6 +890,21 @@ case class TransactionRequestTransferToAtm( to: ToAccountTransferToAtm ) extends TransactionRequestCommonBodyJSON +case class RegulatedEntityTraitCommons( + entityId :String, + certificateAuthorityCaOwnerId :String, + entityName :String, + entityCode :String, + entityCertificatePublicKey :String, + entityType :String, + entityAddress :String, + entityTownCity :String, + entityPostCode :String, + entityCountry :String, + entityWebSite :String, + services :String) extends RegulatedEntityTrait +object RegulatedEntityTraitCommons extends Converter[RegulatedEntityTrait, RegulatedEntityTraitCommons] + //For COUNTERPARTY, it needs the counterparty_id to find the toCounterparty--> toBankAccount case class TransactionRequestCounterpartyId (counterparty_id : String) From 4c19d39aa21d6b13eb4296869a6886d5a93e0d64 Mon Sep 17 00:00:00 2001 From: hongwei Date: Mon, 7 Apr 2025 10:41:07 +0200 Subject: [PATCH 2/6] refactor/tweaked the messageDoc example value --- .../rabbitmq/RabbitMQConnector_vOct2024.scala | 66 ++++++++++++------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala b/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala index a70bc9cf1e..6695a5b37b 100644 --- a/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala +++ b/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala @@ -7081,18 +7081,27 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable { exampleInboundMessage = ( InBoundGetRegulatedEntities(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext, status=MessageDocsSwaggerDefinitions.inboundStatus, - data=List( RegulatedEntityTraitCommons(entityId="string", - certificateAuthorityCaOwnerId="string", - entityName="string", - entityCode="string", - entityCertificatePublicKey="string", - entityType="string", - entityAddress="string", - entityTownCity="string", - entityPostCode="string", - entityCountry="string", - entityWebSite="string", - services="string"))) + data=List( RegulatedEntityTraitCommons(entityId = "0af807d7-3c39-43ef-9712-82bcfde1b9ca", + certificateAuthorityCaOwnerId = "CY_CBC", + entityName = "EXAMPLE COMPANY LTD", + entityCode = "PSD_PICY_CBC!12345", + entityCertificatePublicKey = + """-----BEGIN CERTIFICATE-----MIICsjCCAZqgAwIBAgIGAYwQ62R0MA0GCSqGSIb3DQEBCwUAMBoxGDAWBgNVBAMMD2 + |FwcC5leGFtcGxlLmNvbTAeFw0yMzExMjcxMzE1MTFaFw0yNTExMjYxMzE1MTFaMBoxGDAWBgNVBAMMD2FwcC5leGFtcGxlLmNvbTCCASIwDQ + |YJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK9WIodZHWzKyCcf9YfWEhPURbfO6zKuMqzHN27GdqHsVVEGxP4F/J4mso+0ENcRr6ur4u81iRE + |aVdCc40rHDHVJNEtniD8Icbz7tcsqAewIVhc/q6WXGqImJpCq7hA0m247dDsaZT0lb/MVBiMoJxDEmAE/GYYnWTEn84R35WhJsMvuQ7QmLvNg6 + |RkChY6POCT/YKe9NKwa1NqI1U+oA5RFzAaFtytvZCE3jtp+aR0brL7qaGfgxm6B7dEpGyhg0NcVCV7xMQNq2JxZTVdAr6lcsRGaAFulakmW3aN + |nmK+L35Wu8uW+OxNxwUuC6f3b4FVBa276FMuUTRfu7gc+k6kCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAAU5CjEyAoyTn7PgFpQD48ZNPuUsEQ + |19gzYgJvHMzFIoZ7jKBodjO5mCzWBcR7A4mpeAsdyiNBl2sTiZscSnNqxk61jVzP5Ba1D7XtOjjr7+3iqowrThj6BY40QqhYh/6BSY9fDzVZQi + |Hnvlo6ZUM5kUK6OavZOovKlp5DIl5sGqoP0qAJnpQ4nhB2WVVsKfPlOXc+2KSsbJ23g9l8zaTMr+X0umlvfEKqyEl1Fa2L1dO0y/KFQ+ILmxcZ + |LpRdq1hRAjd0quq9qGC8ucXhRWDgM4hslVpau0da68g0aItWNez3mc5lB82b3dcZpFMzO41bgw7gvw10AvvTfQDqEYIuQ==-----END CERTIFICATE----- """.stripMargin, + entityType = "PSD_PI", + entityAddress = "EXAMPLE COMPANY LTD, 5 SOME STREET", + entityTownCity = "SOME CITY", + entityPostCode = "1060", + entityCountry = "CY", + entityWebSite = "www.example.com", + services = """[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]"""))) ), adapterImplementation = Some(AdapterImplementation("- Core", 1)) ) @@ -7118,18 +7127,27 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable { exampleInboundMessage = ( InBoundGetRegulatedEntityByEntityId(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext, status=MessageDocsSwaggerDefinitions.inboundStatus, - data= RegulatedEntityTraitCommons(entityId="string", - certificateAuthorityCaOwnerId="string", - entityName="string", - entityCode="string", - entityCertificatePublicKey="string", - entityType="string", - entityAddress="string", - entityTownCity="string", - entityPostCode="string", - entityCountry="string", - entityWebSite="string", - services="string")) + data= RegulatedEntityTraitCommons(entityId = "0af807d7-3c39-43ef-9712-82bcfde1b9ca", + certificateAuthorityCaOwnerId = "CY_CBC", + entityName = "EXAMPLE COMPANY LTD", + entityCode = "PSD_PICY_CBC!12345", + entityCertificatePublicKey = + """-----BEGIN CERTIFICATE-----MIICsjCCAZqgAwIBAgIGAYwQ62R0MA0GCSqGSIb3DQEBCwUAMBoxGDAWBgNVBAMMD2 + |FwcC5leGFtcGxlLmNvbTAeFw0yMzExMjcxMzE1MTFaFw0yNTExMjYxMzE1MTFaMBoxGDAWBgNVBAMMD2FwcC5leGFtcGxlLmNvbTCCASIwDQ + |YJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK9WIodZHWzKyCcf9YfWEhPURbfO6zKuMqzHN27GdqHsVVEGxP4F/J4mso+0ENcRr6ur4u81iRE + |aVdCc40rHDHVJNEtniD8Icbz7tcsqAewIVhc/q6WXGqImJpCq7hA0m247dDsaZT0lb/MVBiMoJxDEmAE/GYYnWTEn84R35WhJsMvuQ7QmLvNg6 + |RkChY6POCT/YKe9NKwa1NqI1U+oA5RFzAaFtytvZCE3jtp+aR0brL7qaGfgxm6B7dEpGyhg0NcVCV7xMQNq2JxZTVdAr6lcsRGaAFulakmW3aN + |nmK+L35Wu8uW+OxNxwUuC6f3b4FVBa276FMuUTRfu7gc+k6kCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAAU5CjEyAoyTn7PgFpQD48ZNPuUsEQ + |19gzYgJvHMzFIoZ7jKBodjO5mCzWBcR7A4mpeAsdyiNBl2sTiZscSnNqxk61jVzP5Ba1D7XtOjjr7+3iqowrThj6BY40QqhYh/6BSY9fDzVZQi + |Hnvlo6ZUM5kUK6OavZOovKlp5DIl5sGqoP0qAJnpQ4nhB2WVVsKfPlOXc+2KSsbJ23g9l8zaTMr+X0umlvfEKqyEl1Fa2L1dO0y/KFQ+ILmxcZ + |LpRdq1hRAjd0quq9qGC8ucXhRWDgM4hslVpau0da68g0aItWNez3mc5lB82b3dcZpFMzO41bgw7gvw10AvvTfQDqEYIuQ==-----END CERTIFICATE----- """.stripMargin, + entityType = "PSD_PI", + entityAddress = "EXAMPLE COMPANY LTD, 5 SOME STREET", + entityTownCity = "SOME CITY", + entityPostCode = "1060", + entityCountry = "CY", + entityWebSite = "www.example.com", + services = """[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]""")) ), adapterImplementation = Some(AdapterImplementation("- Core", 1)) ) From 52090a2532463ad0094de31b1cd193ad77c1468a Mon Sep 17 00:00:00 2001 From: hongwei Date: Mon, 7 Apr 2025 11:06:04 +0200 Subject: [PATCH 3/6] refactor/update regulated entity JSON reference in APIMethods510 --- obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala index c8b05ec295..98d21722dc 100644 --- a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala +++ b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala @@ -202,7 +202,7 @@ trait APIMethods510 { | |""", regulatedEntityPostJsonV510, - regulatedEntitiesJsonV510, + regulatedEntityJsonV510, List( $UserNotLoggedIn, UserHasMissingRoles, From c056777b0df84d7ee4ba8403d1a884a549f150cc Mon Sep 17 00:00:00 2001 From: hongwei Date: Mon, 7 Apr 2025 11:20:54 +0200 Subject: [PATCH 4/6] feature/add regulated entity attribute management functionality --- .../main/scala/bootstrap/liftweb/Boot.scala | 5 +- ...ppedRegulatedEntityAttributeProvider.scala | 104 ++++++++++++++++++ .../attribute/RegulatedEntityAttribute.scala | 50 +++++++++ .../commons/model/BankingModel.scala | 7 ++ .../commons/model/CommonModelTrait.scala | 9 ++ .../commons/model/enums/Enumerations.scala | 7 ++ 6 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 obp-api/src/main/scala/code/regulatedentities/attribute/MappedRegulatedEntityAttributeProvider.scala create mode 100644 obp-api/src/main/scala/code/regulatedentities/attribute/RegulatedEntityAttribute.scala diff --git a/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala b/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala index 899e781e9c..38f3964810 100644 --- a/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala +++ b/obp-api/src/main/scala/bootstrap/liftweb/Boot.scala @@ -133,10 +133,10 @@ import code.views.Views import code.views.system.{AccountAccess, ViewDefinition, ViewPermission} import code.webhook.{BankAccountNotificationWebhook, MappedAccountWebhook, SystemAccountNotificationWebhook} import code.webuiprops.WebUiProps +import code.regulatedentities.attribute.RegulatedEntityAttribute import com.openbankproject.commons.model.ErrorMessage import com.openbankproject.commons.util.Functions.Implicits._ import com.openbankproject.commons.util.{ApiVersion, Functions} - import javax.mail.internet.MimeMessage import net.liftweb.common._ import net.liftweb.db.{DB, DBLogEntry} @@ -1124,7 +1124,8 @@ object ToSchemify { MappedCustomerDependant, AttributeDefinition, CustomerAccountLink, - TransactionIdMapping + TransactionIdMapping, + RegulatedEntityAttribute, ) // start grpc server diff --git a/obp-api/src/main/scala/code/regulatedentities/attribute/MappedRegulatedEntityAttributeProvider.scala b/obp-api/src/main/scala/code/regulatedentities/attribute/MappedRegulatedEntityAttributeProvider.scala new file mode 100644 index 0000000000..1a606f06b4 --- /dev/null +++ b/obp-api/src/main/scala/code/regulatedentities/attribute/MappedRegulatedEntityAttributeProvider.scala @@ -0,0 +1,104 @@ +package code.regulatedentities.attribute + +import code.util.{MappedUUID, UUIDString} +import com.openbankproject.commons.ExecutionContext.Implicits.global +import com.openbankproject.commons.model.enums.RegulatedEntityAttributeType +import com.openbankproject.commons.model.{RegulatedEntityAttributeTrait, RegulatedEntityId} +import net.liftweb.common.{Box, Empty, Full} +import net.liftweb.mapper.{MappedBoolean, _} +import net.liftweb.util.Helpers.tryo + +import scala.concurrent.Future + + +object RegulatedEntityAttributeProvider extends RegulatedEntityAttributeProviderTrait { + + override def getRegulatedEntityAttributesFromProvider(regulatedEntityId: RegulatedEntityId): Future[Box[List[RegulatedEntityAttribute]]] = + Future { + Box !! RegulatedEntityAttribute.findAll( + By(RegulatedEntityAttribute.RegulatedEntityId_, regulatedEntityId.value) + ) + } + + override def getRegulatedEntityAttributeById(RegulatedEntityAttributeId: String): Future[Box[RegulatedEntityAttribute]] = Future { + RegulatedEntityAttribute.find(By(RegulatedEntityAttribute.RegulatedEntityAttributeId, RegulatedEntityAttributeId)) + } + + override def createOrUpdateRegulatedEntityAttribute( + regulatedEntityId: RegulatedEntityId, + RegulatedEntityAttributeId: Option[String], + name: String, + attributeType: RegulatedEntityAttributeType.Value, + value: String, + isActive: Option[Boolean] + ): Future[Box[RegulatedEntityAttribute]] = { + RegulatedEntityAttributeId match { + case Some(id) => Future { + RegulatedEntityAttribute.find(By(RegulatedEntityAttribute.RegulatedEntityAttributeId, id)) match { + case Full(attribute) => tryo { + attribute + .RegulatedEntityId_(regulatedEntityId.value) + .Name(name) + .Type(attributeType.toString) + .`Value`(value) + .IsActive(isActive.getOrElse(true)) + .saveMe() + } + case _ => Empty + } + } + case None => Future { + Full { + RegulatedEntityAttribute.create + .RegulatedEntityId_(regulatedEntityId.value) + .Name(name) + .Type(attributeType.toString()) + .`Value`(value) + .IsActive(isActive.getOrElse(true)) + .saveMe() + } + } + } + } + + override def deleteRegulatedEntityAttribute(RegulatedEntityAttributeId: String): Future[Box[Boolean]] = Future { + tryo ( + RegulatedEntityAttribute.bulkDelete_!!(By(RegulatedEntityAttribute.RegulatedEntityAttributeId, RegulatedEntityAttributeId)) + ) + } + + override def deleteRegulatedEntityAttributesByRegulatedEntityId(regulatedEntityId: RegulatedEntityId): Future[Box[Boolean]]= Future { + tryo( + RegulatedEntityAttribute.bulkDelete_!!(By(RegulatedEntityAttribute.RegulatedEntityId_, regulatedEntityId.value)) + ) + } +} + +class RegulatedEntityAttribute extends RegulatedEntityAttributeTrait with LongKeyedMapper[RegulatedEntityAttribute] with IdPK { + + override def getSingleton = RegulatedEntityAttribute + + object RegulatedEntityId_ extends UUIDString(this) { + override def dbColumnName = "RegulatedEntityId" + } + object RegulatedEntityAttributeId extends MappedUUID(this) + object Name extends MappedString(this, 50) + object Type extends MappedString(this, 50) + object `Value` extends MappedString(this, 255) + object IsActive extends MappedBoolean(this) { + override def defaultValue = true + } + + override def regulatedEntityId: RegulatedEntityId = RegulatedEntityId(RegulatedEntityId_.get) + override def regulatedEntityAttributeId: String = RegulatedEntityAttributeId.get + override def name: String = Name.get + override def attributeType: RegulatedEntityAttributeType.Value = RegulatedEntityAttributeType.withName(Type.get) + override def value: String = `Value`.get + override def isActive: Option[Boolean] = if (IsActive.jdbcFriendly(IsActive.calcFieldName) == null) { None } else Some(IsActive.get) + +} + +object RegulatedEntityAttribute extends RegulatedEntityAttribute with LongKeyedMetaMapper[RegulatedEntityAttribute] { + override def dbIndexes: List[BaseIndex[RegulatedEntityAttribute]] = Index(RegulatedEntityId_) :: super.dbIndexes +} + diff --git a/obp-api/src/main/scala/code/regulatedentities/attribute/RegulatedEntityAttribute.scala b/obp-api/src/main/scala/code/regulatedentities/attribute/RegulatedEntityAttribute.scala new file mode 100644 index 0000000000..b28647e5d0 --- /dev/null +++ b/obp-api/src/main/scala/code/regulatedentities/attribute/RegulatedEntityAttribute.scala @@ -0,0 +1,50 @@ +package code.regulatedentities.attribute + +/* For ProductAttribute */ + +import com.openbankproject.commons.model.{RegulatedEntityId, BankId} +import com.openbankproject.commons.model.enums.RegulatedEntityAttributeType +import net.liftweb.common.{Box, Logger} +import net.liftweb.util.SimpleInjector + +import scala.concurrent.Future + +object RegulatedEntityAttributeX extends SimpleInjector { + + val regulatedEntityAttributeProvider = new Inject(buildOne _) {} + + def buildOne: RegulatedEntityAttributeProviderTrait = RegulatedEntityAttributeProvider + + // Helper to get the count out of an option + def countOfRegulatedEntityAttribute(listOpt: Option[List[RegulatedEntityAttribute]]): Int = { + val count = listOpt match { + case Some(list) => list.size + case None => 0 + } + count + } + + +} + +trait RegulatedEntityAttributeProviderTrait { + + private val logger = Logger(classOf[RegulatedEntityAttributeProviderTrait]) + + def getRegulatedEntityAttributesFromProvider(regulatedEntityId: RegulatedEntityId): Future[Box[List[RegulatedEntityAttribute]]] + + def getRegulatedEntityAttributeById(regulatedEntityAttributeId: String): Future[Box[RegulatedEntityAttribute]] + + def createOrUpdateRegulatedEntityAttribute( + regulatedEntityId: RegulatedEntityId, + regulatedEntityAttributeId: Option[String], + name: String, + attributeType: RegulatedEntityAttributeType.Value, + value: String, + isActive: Option[Boolean]): Future[Box[RegulatedEntityAttribute]] + + def deleteRegulatedEntityAttribute(regulatedEntityAttributeId: String): Future[Box[Boolean]] + + def deleteRegulatedEntityAttributesByRegulatedEntityId(regulatedEntityId: RegulatedEntityId): Future[Box[Boolean]] + // End of Trait +} diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/model/BankingModel.scala b/obp-commons/src/main/scala/com/openbankproject/commons/model/BankingModel.scala index 356c035ab9..06a1f0a0ed 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/model/BankingModel.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/model/BankingModel.scala @@ -128,6 +128,13 @@ case class TransactionTypeId(val value : String) { object TransactionTypeId { def unapply(id : String) = Some(TransactionTypeId(id)) } +case class RegulatedEntityId(val value : String) { + override def toString = value +} + +object RegulatedEntityId { + def unapply(id : String) = Some(RegulatedEntityId(id)) +} case class AccountId(val value : String) { override def toString = value diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModelTrait.scala b/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModelTrait.scala index 4e0af1910c..37db4361cb 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModelTrait.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModelTrait.scala @@ -532,6 +532,15 @@ trait AtmAttributeTrait { def isActive: Option[Boolean] } +trait RegulatedEntityAttributeTrait { + def regulatedEntityId: RegulatedEntityId + def regulatedEntityAttributeId: String + def attributeType: RegulatedEntityAttributeType.Value + def name: String + def value: String + def isActive: Option[Boolean] +} + trait BankAttributeTrait { def bankId: BankId def bankAttributeId: String diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/model/enums/Enumerations.scala b/obp-commons/src/main/scala/com/openbankproject/commons/model/enums/Enumerations.scala index 0372048c8d..6de788ee31 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/model/enums/Enumerations.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/model/enums/Enumerations.scala @@ -22,6 +22,13 @@ object AtmAttributeType extends OBPEnumeration[AtmAttributeType]{ object DOUBLE extends Value object DATE_WITH_DAY extends Value } +sealed trait RegulatedEntityAttributeType extends EnumValue +object RegulatedEntityAttributeType extends OBPEnumeration[RegulatedEntityAttributeType]{ + object STRING extends Value + object INTEGER extends Value + object DOUBLE extends Value + object DATE_WITH_DAY extends Value +} sealed trait BankAttributeType extends EnumValue object BankAttributeType extends OBPEnumeration[BankAttributeType]{ object STRING extends Value From 39190a79ef26c3d19736d881367b60835551d514 Mon Sep 17 00:00:00 2001 From: hongwei Date: Mon, 7 Apr 2025 16:32:10 +0200 Subject: [PATCH 5/6] feature/add attributes support to regulated entity models --- .../SwaggerDefinitionsJSON.scala | 14 ++++++++++++-- .../code/api/v5_1_0/JSONFactory5.1.0.scala | 9 ++++++--- .../rabbitmq/RabbitMQConnector_vOct2024.scala | 18 ++++++++++++++---- .../MappedRegulatedEntitiyProvider.scala | 9 +++++++-- .../commons/model/CommonModel.scala | 5 ++++- .../commons/model/CommonModelTrait.scala | 9 +++++++++ 6 files changed, 52 insertions(+), 12 deletions(-) diff --git a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala index c3dd9bd1bb..d9d9484ee6 100644 --- a/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala +++ b/obp-api/src/main/scala/code/api/ResourceDocs1_4_0/SwaggerDefinitionsJSON.scala @@ -60,7 +60,12 @@ object SwaggerDefinitionsJSON { entity_post_code = "1060", entity_country = "CY", entity_web_site = "www.example.com", - services = json.parse("""[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]""") + services = json.parse("""[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]"""), + attributes = Some(List(RegulatedEntityAttributeSimple( + attributeType=attributeTypeExample.value, + name=attributeNameExample.value, + value=attributeValueExample.value) + )) ) lazy val regulatedEntityPostJsonV510: RegulatedEntityPostJsonV510 = RegulatedEntityPostJsonV510( @@ -74,7 +79,12 @@ object SwaggerDefinitionsJSON { entity_post_code = "1060", entity_country = "CY", entity_web_site = "www.example.com", - services = json.parse("""[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]""") + services = json.parse("""[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]"""), + attributes = Some(List(RegulatedEntityAttributeSimple( + attributeType=attributeTypeExample.value, + name=attributeNameExample.value, + value=attributeValueExample.value) + )) ) val license = License( diff --git a/obp-api/src/main/scala/code/api/v5_1_0/JSONFactory5.1.0.scala b/obp-api/src/main/scala/code/api/v5_1_0/JSONFactory5.1.0.scala index d5295b740d..b1c9dea622 100644 --- a/obp-api/src/main/scala/code/api/v5_1_0/JSONFactory5.1.0.scala +++ b/obp-api/src/main/scala/code/api/v5_1_0/JSONFactory5.1.0.scala @@ -83,7 +83,8 @@ case class RegulatedEntityJsonV510( entity_post_code: String, entity_country: String, entity_web_site: String, - services: JValue + services: JValue, + attributes: Option[List[RegulatedEntityAttributeSimple]] ) case class RegulatedEntityPostJsonV510( certificate_authority_ca_owner_id: String, @@ -96,7 +97,8 @@ case class RegulatedEntityPostJsonV510( entity_post_code: String, entity_country: String, entity_web_site: String, - services: JValue + services: JValue, + attributes: Option[List[RegulatedEntityAttributeSimple]] ) case class RegulatedEntitiesJsonV510(entities: List[RegulatedEntityJsonV510]) @@ -989,7 +991,8 @@ object JSONFactory510 extends CustomJsonFormats { entity_post_code = entity.entityPostCode, entity_country = entity.entityCountry, entity_web_site = entity.entityWebSite, - services = json.parse(entity.services) + services = json.parse(entity.services), + attributes = entity.attributes ) } def createRegulatedEntitiesJson(entities: List[RegulatedEntityTrait]): RegulatedEntitiesJsonV510 = { diff --git a/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala b/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala index 6695a5b37b..879a7a8f7f 100644 --- a/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala +++ b/obp-api/src/main/scala/code/bankconnectors/rabbitmq/RabbitMQConnector_vOct2024.scala @@ -36,7 +36,7 @@ import com.openbankproject.commons.ExecutionContext.Implicits.global import com.openbankproject.commons.dto.{InBoundTrait, _} import com.openbankproject.commons.model.enums.StrongCustomerAuthenticationStatus.SCAStatus import com.openbankproject.commons.model.enums._ -import com.openbankproject.commons.model.{TopicTrait, _} +import com.openbankproject.commons.model.{TopicTrait, RegulatedEntityAttributeSimple, _} import com.openbankproject.commons.util.ReflectUtils import net.liftweb.common.{Box, _} import net.liftweb.json._ @@ -7081,7 +7081,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable { exampleInboundMessage = ( InBoundGetRegulatedEntities(inboundAdapterCallContext=MessageDocsSwaggerDefinitions.inboundAdapterCallContext, status=MessageDocsSwaggerDefinitions.inboundStatus, - data=List( RegulatedEntityTraitCommons(entityId = "0af807d7-3c39-43ef-9712-82bcfde1b9ca", + data=List(RegulatedEntityTraitCommons(entityId = "0af807d7-3c39-43ef-9712-82bcfde1b9ca", certificateAuthorityCaOwnerId = "CY_CBC", entityName = "EXAMPLE COMPANY LTD", entityCode = "PSD_PICY_CBC!12345", @@ -7101,7 +7101,12 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable { entityPostCode = "1060", entityCountry = "CY", entityWebSite = "www.example.com", - services = """[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]"""))) + services = """[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]""", + attributes = Some(List(RegulatedEntityAttributeSimple( + attributeType=attributeTypeExample.value, + name=attributeNameExample.value, + value=attributeValueExample.value) + ))))) ), adapterImplementation = Some(AdapterImplementation("- Core", 1)) ) @@ -7147,7 +7152,12 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable { entityPostCode = "1060", entityCountry = "CY", entityWebSite = "www.example.com", - services = """[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]""")) + services = """[{"CY":["PS_010","PS_020","PS_03C","PS_04C"]}]""", + attributes = Some(List(RegulatedEntityAttributeSimple( + attributeType=attributeTypeExample.value, + name=attributeNameExample.value, + value=attributeValueExample.value) + )))) ), adapterImplementation = Some(AdapterImplementation("- Core", 1)) ) diff --git a/obp-api/src/main/scala/code/regulatedentities/MappedRegulatedEntitiyProvider.scala b/obp-api/src/main/scala/code/regulatedentities/MappedRegulatedEntitiyProvider.scala index e84a6d0421..7289413d7f 100644 --- a/obp-api/src/main/scala/code/regulatedentities/MappedRegulatedEntitiyProvider.scala +++ b/obp-api/src/main/scala/code/regulatedentities/MappedRegulatedEntitiyProvider.scala @@ -1,7 +1,7 @@ package code.regulatedentities import code.util.MappedUUID -import com.openbankproject.commons.model.RegulatedEntityTrait +import com.openbankproject.commons.model.{RegulatedEntityTrait,RegulatedEntityAttributeSimple} import net.liftweb.common.Box import net.liftweb.common.Box.tryo import net.liftweb.mapper._ @@ -120,7 +120,12 @@ class MappedRegulatedEntity extends RegulatedEntityTrait with LongKeyedMapper[Ma override def entityCountry: String = EntityCountry.get override def entityWebSite: String = EntityWebSite.get override def services: String = Services.get - +// override def attributes: Option[List[RegulatedEntityAttributeSimple]] = Some(List(RegulatedEntityAttributeSimple( +// attributeType="attributeTypeExample.value", +// name="attributeNameExample.value", +// value="attributeValueExample.value") +// )) + override def attributes: Option[List[RegulatedEntityAttributeSimple]] = None //not for mapped mode yet, will add it later. } diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala b/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala index 49c4170259..04a6903205 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModel.scala @@ -902,7 +902,10 @@ case class RegulatedEntityTraitCommons( entityPostCode :String, entityCountry :String, entityWebSite :String, - services :String) extends RegulatedEntityTrait + services :String, + attributes :Option[List[RegulatedEntityAttributeSimple]] +) extends RegulatedEntityTrait + object RegulatedEntityTraitCommons extends Converter[RegulatedEntityTrait, RegulatedEntityTraitCommons] //For COUNTERPARTY, it needs the counterparty_id to find the toCounterparty--> toBankAccount diff --git a/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModelTrait.scala b/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModelTrait.scala index 37db4361cb..c89720376a 100644 --- a/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModelTrait.scala +++ b/obp-commons/src/main/scala/com/openbankproject/commons/model/CommonModelTrait.scala @@ -114,6 +114,14 @@ trait SigningBasketConsentTrait { def consentId: String } +//TODO, this is only from CBS yet, not use mapped mode, may need to be refactor. +case class RegulatedEntityAttributeSimple( + attributeType: String, + name: String, + value: String, +) + + trait RegulatedEntityTrait { def entityId: String def certificateAuthorityCaOwnerId: String @@ -127,6 +135,7 @@ trait RegulatedEntityTrait { def entityCountry: String def entityWebSite: String def services: String + def attributes: Option[List[RegulatedEntityAttributeSimple]] } trait UserAttributeTrait { From 225cb6281208d9c40c4409c7b6a9bccfd6bbc6b4 Mon Sep 17 00:00:00 2001 From: hongwei Date: Mon, 7 Apr 2025 16:59:25 +0200 Subject: [PATCH 6/6] feature/add get_regulated_entities and get_regulated_entity_by_entity_id functionality --- .../Adapter/MockedRabbitMqAdapter.scala | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/obp-api/src/main/scala/code/bankconnectors/rabbitmq/Adapter/MockedRabbitMqAdapter.scala b/obp-api/src/main/scala/code/bankconnectors/rabbitmq/Adapter/MockedRabbitMqAdapter.scala index bef2cb25f1..1325382602 100644 --- a/obp-api/src/main/scala/code/bankconnectors/rabbitmq/Adapter/MockedRabbitMqAdapter.scala +++ b/obp-api/src/main/scala/code/bankconnectors/rabbitmq/Adapter/MockedRabbitMqAdapter.scala @@ -77,7 +77,7 @@ class ServerCallback(val ch: Channel) extends DeliverCallback with MdcLoggable{ )) } //---------------- dynamic start -------------------please don't modify this line -// ---------- created on 2025-01-14T11:53:01Z +// ---------- created on 2025-04-07T14:53:47Z } else if (obpMessageId.contains("get_adapter_info")) { val outBound = json.parse(message).extract[OutBoundGetAdapterInfo] @@ -3109,6 +3109,48 @@ class ServerCallback(val ch: Channel) extends DeliverCallback with MdcLoggable{ data = false )) } + } else if (obpMessageId.contains("get_regulated_entities")) { + val outBound = json.parse(message).extract[OutBoundGetRegulatedEntities] + val obpMappedResponse = code.bankconnectors.LocalMappedConnector.getRegulatedEntities(None).map(_._1.head) + + obpMappedResponse.map(response => InBoundGetRegulatedEntities( + + inboundAdapterCallContext = InboundAdapterCallContext( + correlationId = outBound.outboundAdapterCallContext.correlationId + ), + status = Status("", Nil), + data = response + )).recoverWith { + case e: Exception => Future(InBoundGetRegulatedEntities( + + inboundAdapterCallContext = InboundAdapterCallContext( + correlationId = outBound.outboundAdapterCallContext.correlationId + ), + status = Status(e.getMessage, Nil), + data = null + )) + } + } else if (obpMessageId.contains("get_regulated_entity_by_entity_id")) { + val outBound = json.parse(message).extract[OutBoundGetRegulatedEntityByEntityId] + val obpMappedResponse = code.bankconnectors.LocalMappedConnector.getRegulatedEntityByEntityId(outBound.regulatedEntityId,None).map(_._1.head) + + obpMappedResponse.map(response => InBoundGetRegulatedEntityByEntityId( + + inboundAdapterCallContext = InboundAdapterCallContext( + correlationId = outBound.outboundAdapterCallContext.correlationId + ), + status = Status("", Nil), + data = response + )).recoverWith { + case e: Exception => Future(InBoundGetRegulatedEntityByEntityId( + + inboundAdapterCallContext = InboundAdapterCallContext( + correlationId = outBound.outboundAdapterCallContext.correlationId + ), + status = Status(e.getMessage, Nil), + data = null + )) + } } else if (obpMessageId.contains("dynamic_entity_process")) { val outBound = json.parse(message).extract[OutBoundDynamicEntityProcess] val obpMappedResponse = code.bankconnectors.LocalMappedConnector.dynamicEntityProcess(outBound.operation,outBound.entityName,outBound.requestBody,outBound.entityId,None,None,None,false,None).map(_._1.head) @@ -3130,8 +3172,8 @@ class ServerCallback(val ch: Channel) extends DeliverCallback with MdcLoggable{ data = null )) } -// ---------- created on 2025-01-14T11:53:01Z -//---------------- dynamic end ---------------------please don't modify this line +// ---------- created on 2025-04-07T14:53:47Z +//---------------- dynamic end ---------------------please don't modify this line } else { Future { 1