Commit 8dbcd1c2 by Amelin Konstantin

Add parties dictionary. Complete ForwardBondTemplate.

parent d7b8e607
......@@ -93,7 +93,7 @@
<nsdext:clientDetails>
<nsdext:servicingParty href="Party1"/>
<nsdext:type>P</nsdext:type>
<nsdext:id>PASS_04_55582007</nsdext:id>
<nsdext:id>PASS_04 55582007</nsdext:id>
<nsdext:name> </nsdext:name>
<nsdext:country countryScheme="http://www.fpml.org/ext/iso3166">RU</nsdext:country>
</nsdext:clientDetails>
......
......@@ -7,8 +7,9 @@ class BondForwardTemplate(source: Node) extends TradeTemplate(source) {
<rtsrep:bondForward>
<fpml:productType>{ get(source \\ "trade" \ "bondForward" \ "productType") }</fpml:productType>
<fpml:productId productIdScheme={ get(source \\ "trade" \ "bondForward" \ "productId", "productIdScheme") }>{ get(source \\ "trade" \ "bondForward" \ "productId") }</fpml:productId>
<fpml:buyerPartyReference href={ get(source \\ "trade" \ "bondForward" \ "buyerPartyReference", "href") }/>
<fpml:sellerPartyReference href={ get(source \\ "trade" \ "bondForward" \ "sellerPartyReference", "href") }/>
{ /* Uses dictionary from PartyTemplate for identifier */ }
<fpml:buyerPartyReference href={ parties(get(source \\ "trade" \ "bondForward" \ "buyerPartyReference", "href").mkString)._1 }/>
<fpml:sellerPartyReference href={ parties(get(source \\ "trade" \ "bondForward" \ "sellerPartyReference", "href").mkString)._1 }/>
<rtsrep:underlyer>
<fpml:singleUnderlyer>
<fpml:equity id={ get(source \\ "trade" \ "bondForward" \ "underlyer" \ "singleUnderlyer" \ "equity", "id") }>
......
......@@ -2,7 +2,7 @@ package templates
import scala.xml.Node
class ExecutionStatusReportTemplate(source: Node) extends Template(source) {
class ExecutionStatusReportTemplate(source: Node) extends PartyTemplate(source) {
def template: Node = {
<rtsrep:executionStatusReportRegistration xmlns:fpml="http://www.fpml.org/FpML-5/recordkeeping"
......
......@@ -2,7 +2,7 @@ package templates
import scala.xml.Node
class FairValueReportTemplate(source: Node) extends Template(source) {
class FairValueReportTemplate(source: Node) extends PartyTemplate(source) {
def template: Node = {
<rtsrep:fairValueReportRegistration xmlns:fpml="http://www.fpml.org/FpML-5/recordkeeping"
......
......@@ -7,7 +7,7 @@ import scala.xml.{NodeSeq, Text}
trait Logger {
this: Template =>
private[this] val data = {
private[this] lazy val data = {
val m: mutable.LinkedHashMap[Int, mutable.Queue[(String, String, mutable.LinkedHashMap[Int, (String, String)])]] =
mutable.LinkedHashMap()
val items = source \\ "_"
......
package templates
import scala.xml.Node
abstract class PartyTemplate(source: Node) extends Template(source) {
protected[this] val parties = {
val p1 =
for { s <- source \ "party"
id = get(s, "id").mkString
if id != "Sender" && id != "UTIGeneratingParty"} yield {
val partyId0 = get(s \ "partyId").mkString.filterNot(_.isWhitespace)
if (partyId0 != "NONREF")
id -> (partyId0, msgNotFound)
else {
val partyId1 = get(s \ "partyId", null, 1).mkString.filterNot(_.isWhitespace)
id -> (partyId1, partyId1.split('_').head)
}
}
val p2 =
for { s <- source \\ "trade" \ "nsdSpecificTradeFields" \ "clientDetails"
id = get(s \ "id").mkString
if id != msgNotFound } yield {
val partyId = id.filterNot(_.isWhitespace)
id -> (partyId, partyId.split('_').head)
}
(p1 ++ p2).toMap
}
println(parties)
}
......@@ -2,7 +2,7 @@ package templates
import scala.xml.{Node, NodeSeq}
abstract class RegiAmendTermMasterAgreementTemplate(source: Node) extends Template(source) {
abstract class RegiAmendTermMasterAgreementTemplate(source: Node) extends PartyTemplate(source) {
protected[this] def templateMATerms: NodeSeq
def template: Node = {
......
......@@ -2,7 +2,7 @@ package templates
import scala.xml.Node
abstract class RegiAmendTradeTemplate(source: Node) extends Template(source) {
abstract class RegiAmendTradeTemplate(source: Node) extends PartyTemplate(source) {
protected[this] def templateTrade: Node
def template: Node = {
......@@ -28,20 +28,23 @@ abstract class RegiAmendTradeTemplate(source: Node) extends Template(source) {
<fpml:effectiveDate>{ get(source \ "amendment" \ "effectiveDate") }</fpml:effectiveDate>
</fpml:amendment>
}
{ /* Uses dictionary from PartyTemplate for identifier */ }
{ for { s <- source \ "party"
id = get(s, "id").mkString
if id != "Sender" && id != "UTIGeneratingParty" } yield {
<fpml:party id={ id }>
<fpml:partyId partyIdScheme={ get(s \ "partyId", "partyIdScheme") }>{ get(s \ "partyId") }</fpml:partyId>
<fpml:party id={ parties(id)._1 }>
<fpml:partyId partyIdScheme={ parties(id)._2 }>{ parties(id)._1 }</fpml:partyId>
<fpml:partyName>{ get(s \ "partyName") }</fpml:partyName>
<fpml:country>{ get(s \ "country") }</fpml:country>
<fpml:organizationType>{ get(s \ "classification") }</fpml:organizationType>
</fpml:party>
}
}
{ for (s <- source \\ "trade" \ "nsdSpecificTradeFields" \ "clientDetails") yield {
<fpml:party id={ get(s \ "id") }>
<fpml:partyId>{ get(s \ "id") }</fpml:partyId>
{ for { s <- source \\ "trade" \ "nsdSpecificTradeFields" \ "clientDetails"
id = get(s \ "id").mkString
if id != msgNotFound } yield {
<fpml:party id={ parties(id)._1 }>
<fpml:partyId partyIdScheme={ parties(id)._2 }>{ parties(id)._1 }</fpml:partyId>
<fpml:partyName>{ get(s \ "name") }</fpml:partyName>
<fpml:country>{ get(s \ "country") }</fpml:country>
<fpml:organizationType>{ get(s \ "classification") }</fpml:organizationType>
......
......@@ -52,7 +52,7 @@ abstract class Template(protected[this] val source: Node) {
}
def info(msg: String): String = msg
}
}
object Template {
def apply(source: Node)(implicit templateFactory: Node => Template): Template = templateFactory(source)
......
......@@ -8,19 +8,20 @@ abstract class TradeTemplate(source: Node) extends RegiAmendTradeTemplate(source
protected[this] def templateTrade: Node = {
<fpml:trade>
<fpml:tradeHeader>
{ /* Uses dictionary from PartyTemplate for identifier */ }
{ for { s <- source \\ "trade" \ "tradeHeader" \ "partyTradeIdentifier"
id = get(s \ "partyReference", "href").mkString
if id != "Sender" && id != "UTIGeneratingParty" } yield {
<fpml:partyTradeIdentifier>
<fpml:partyReference href={ id }/>
<fpml:partyReference href={ parties(id)._1 }/>
<fpml:tradeId tradeIdScheme={ get(s \ "tradeId", "tradeIdScheme") }>{ get(s \ "tradeId") }</fpml:tradeId>
</fpml:partyTradeIdentifier>
}
}
<fpml:partyTradeInformation>
<fpml:partyReference href={ get(source \\ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "partyReference", "href") }/>
<fpml:partyReference href={ parties(get(source \\ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "partyReference", "href").mkString)._1 }/>
<fpml:relatedParty>
<fpml:partyReference href={ get(source \\ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "partyReference", "href") } />
<fpml:partyReference href={ parties(get(source \\ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "partyReference", "href").mkString)._1 } />
<fpml:role>ClearingOrganization</fpml:role>
</fpml:relatedParty>
<fpml:category categoryScheme="http://www.fpml.ru/repository/trade-settlement-type">{ get(source \\ "trade" \ "nsdSpecificTradeFields" \ "clearSettlementType") }</fpml:category>
......@@ -34,12 +35,15 @@ abstract class TradeTemplate(source: Node) extends RegiAmendTradeTemplate(source
</fpml:partyTradeInformation>
{ for (s <- source \\ "trade" \ "nsdSpecificTradeFields" \ "clientDetails") yield {
<fpml:partyTradeInformation>
<fpml:partyReference href={ get(s \ "servicingParty", "href") } />
<fpml:relatedParty>
<fpml:partyReference href={ get(s \ "id") } />
<fpml:role>{ if (get(s \ "id").mkString != msgNotFound) "Client" else msgNotFound}</fpml:role>
<fpml:type>{ get(s \ "type") }</fpml:type>
</fpml:relatedParty>
<fpml:partyReference href={ parties(get(s \ "servicingParty", "href").mkString)._1 } />
{ val id = get(s \ "id").mkString
if (id != msgNotFound)
<fpml:relatedParty>
<fpml:partyReference href={ parties(id)._1 } />
<fpml:role>{ "Client" }</fpml:role>
<fpml:type>{ get(s \ "type") }</fpml:type>
</fpml:relatedParty>
}
<fpml:timestamps>
<fpml:timestamp>
<fpml:type>{ if (get(source \\ "trade" \ "nsdSpecificTradeFields" \ "clearedDate").mkString != msgNotFound) "InClearingPool" else msgNotFound}</fpml:type>
......@@ -83,7 +87,10 @@ abstract class TradeTemplate(source: Node) extends RegiAmendTradeTemplate(source
{ templateTradeBody }
<fpml:documentation>
<fpml:masterAgreement>
<fpml:masterAgreementId>{ get(source \\ "trade" \ "tradeHeader" \ "partyTradeIdentifier" \ "linkId") }</fpml:masterAgreementId>
<fpml:masterAgreementId>{
val id = get(source \\ "trade" \ "tradeHeader" \ "partyTradeIdentifier" \ "linkId").mkString
if (id != msgNotFound) id else "NONREF"
}</fpml:masterAgreementId>
</fpml:masterAgreement>
</fpml:documentation>
</fpml:trade>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment