Commit 5cbca951 by Amelin Konstantin

Move general part from RepoTemplate to TradeTemlate. Complete RepoTemplate

parent 5a949c6c
...@@ -17,12 +17,12 @@ object Main extends App { ...@@ -17,12 +17,12 @@ object Main extends App {
} }
val p = new PrettyPrinter(140, 2) val p = new PrettyPrinter(140, 2)
val sourceXml = XML.loadFile("src/main/resources/nsd/Repo NSD equity.xml") val sourceXml = XML.loadFile("src/main/resources/nsd/Repo NSD bond.xml")
val template = Template(sourceXml) val template = Template(sourceXml)
val outputXml = XML.loadString(p.format(template.render)) val outputXml = XML.loadString(p.format(template.render))
//val outputXml = template.template //val outputXml = template.template
template.log() //template.log()
Try { Try {
XMLValid("src/main/resources/nsd/nsd-ext-merged-schema.xsd").loadString(sourceXml.mkString) XMLValid("src/main/resources/nsd/nsd-ext-merged-schema.xsd").loadString(sourceXml.mkString)
......
package templates package templates
import scala.util.Try
import scala.xml.Node import scala.xml.Node
abstract class TradeTemplate(source: Node) extends Template(source) { abstract class TradeTemplate(source: Node) extends Template(source) {
protected[this] def templateTrade: Node protected[this] def templateTradeBody: Node
def template: Node = { def template: Node = {
<signedDocument xmlns="http://www.fpml.ru/repository"> <signedDocument xmlns="http://www.fpml.ru/repository">
...@@ -23,7 +22,72 @@ abstract class TradeTemplate(source: Node) extends Template(source) { ...@@ -23,7 +22,72 @@ abstract class TradeTemplate(source: Node) extends Template(source) {
</fpml:header> </fpml:header>
<fpml:isCorrection>{ get(source \ "isCorrection") }</fpml:isCorrection> <fpml:isCorrection>{ get(source \ "isCorrection") }</fpml:isCorrection>
<fpml:correlationId correlationIdScheme="">{ get(source \ "correlationId") }</fpml:correlationId> <fpml:correlationId correlationIdScheme="">{ get(source \ "correlationId") }</fpml:correlationId>
{ templateTrade } <fpml:trade>
<fpml:tradeHeader>
{ for (s <- source \ "trade" \ "tradeHeader" \ "partyTradeIdentifier") yield {
<fpml:partyTradeIdentifier>
<fpml:partyReference href={ get(s \ "partyReference", "href") }/>
<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:relatedParty>
<fpml:partyReference href={ get(source \ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "partyReference", "href") } />
<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>
<fpml:category categoryScheme="http://www.fpml.ru/repository/trade-settlement-method">{ get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearSettlementMethod") }</fpml:category>
<fpml:executionDateTime>{ get(source \ "trade" \ "tradeHeader" \ "tradeDate") + "T00:00:00" }</fpml:executionDateTime>
<fpml:reportingRegime>
<fpml:name>{ get(source \ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "reportingRegime" \ "name") }</fpml:name>
<fpml:mandatorilyClearable>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "cleared").mkString.contains("Y")) "true" else "" }</fpml:mandatorilyClearable>
</fpml:reportingRegime>
</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 ""}</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 ""}</fpml:type>
<fpml:value>{ get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearedDate") + "T00:00:00" }</fpml:value>
</fpml:timestamp>
<fpml:timestamp>
<fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "startAgreementDate").mkString != msgNotFound) "InPortfolio" else ""}</fpml:type>
<fpml:value>{ get(source \ "trade" \ "nsdSpecificTradeFields" \ "startAgreementDate") + "T00:00:00" }</fpml:value>
</fpml:timestamp>
<fpml:timestamp>
<fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "endAgreementDate").mkString != msgNotFound) "OutPortfolio" else ""}</fpml:type>
<fpml:value>{ get(source \ "trade" \ "nsdSpecificTradeFields" \ "endAgreementDate") + "T00:00:00" }</fpml:value>
</fpml:timestamp>
</fpml:timestamps>
<fpml:collateralizationType>{
get(source \ "trade" \ "collateral" \ "marginType").mkString match {
case v if v == "FC" => "Fully"
case v if v == "PC" => "Partially"
case v if v == "OC" => "OneWay"
case v if v == "U" => "Uncollateralized"
case _ => ""
}
}</fpml:collateralizationType>
<fpml:collateralPortfolio>{ get(source \ "trade" \ "collateral" \ "collateralForm") }</fpml:collateralPortfolio>
</fpml:partyTradeInformation>
}
}
</fpml:tradeHeader>
{ templateTradeBody }
<fpml:documentation>
<fpml:masterAgreement>
<fpml:masterAgreementId>{ get(source \ "trade" \ "tradeHeader" \ "partyTradeIdentifier" \ "linkId") }</fpml:masterAgreementId>
</fpml:masterAgreement>
</fpml:documentation>
</fpml:trade>
{ for (s <- source \ "party") yield { { for (s <- source \ "party") yield {
<fpml:party id={ get(s, "id") }> <fpml:party id={ get(s, "id") }>
<fpml:partyId partyIdScheme={ get(s \ "partyId", "partyIdScheme") }>{ get(s \ "partyId") }</fpml:partyId> <fpml:partyId partyIdScheme={ get(s \ "partyId", "partyIdScheme") }>{ get(s \ "partyId") }</fpml:partyId>
......
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