Commit f75aa9ff by Amelin Konstantin

Change Main. Add dynamically formed output file name.

parent 26fae532
...@@ -16,8 +16,9 @@ object Main extends App { ...@@ -16,8 +16,9 @@ object Main extends App {
} }
} }
val sourceName = "Repo NSD bond"
val p = new PrettyPrinter(140, 2) val p = new PrettyPrinter(140, 2)
val sourceXml = XML.loadFile("src/main/resources/nsd/Repo Client equity.xml") val sourceXml = XML.loadFile("src/main/resources/nsd/" + sourceName + ".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
...@@ -38,6 +39,6 @@ object Main extends App { ...@@ -38,6 +39,6 @@ object Main extends App {
case Failure(ex) => println(s"Output xml isn`t wellformed or invalid: ${ex.getMessage}") case Failure(ex) => println(s"Output xml isn`t wellformed or invalid: ${ex.getMessage}")
} }
XML.save("output/Output repo RTS.xml", outputXml, xmlDecl = true) XML.save("output/" + sourceName + "_RTS.xml", outputXml, xmlDecl = true)
} }
...@@ -44,52 +44,52 @@ abstract class TradeTemplate(source: Node) extends Template(source) { ...@@ -44,52 +44,52 @@ abstract class TradeTemplate(source: Node) extends Template(source) {
<fpml:executionDateTime>{ get(source \ "trade" \ "tradeHeader" \ "tradeDate") + "T00:00:00" }</fpml:executionDateTime> <fpml:executionDateTime>{ get(source \ "trade" \ "tradeHeader" \ "tradeDate") + "T00:00:00" }</fpml:executionDateTime>
<fpml:reportingRegime> <fpml:reportingRegime>
<fpml:name>{ get(source \ "trade" \ "tradeHeader" \ "partyTradeInformation" \ "reportingRegime" \ "name") }</fpml:name> <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:mandatorilyClearable>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "cleared").mkString.contains("Y")) "true" else msgNotFound }</fpml:mandatorilyClearable>
</fpml:reportingRegime> </fpml:reportingRegime>
</fpml:partyTradeInformation> </fpml:partyTradeInformation>
{ for (s <- source \ "trade" \ "nsdSpecificTradeFields" \ "clientDetails") yield { { for (s <- source \ "trade" \ "nsdSpecificTradeFields" \ "clientDetails") yield {
<fpml:partyTradeInformation> <fpml:partyTradeInformation>
<fpml:partyReference href={ get(s \ "servicingParty", "href") } /> <fpml:partyReference href={ get(s \ "servicingParty", "href") } />
<fpml:relatedParty> <fpml:relatedParty>
<fpml:partyReference href={ get(s \ "id") } /> <fpml:partyReference href={ get(s \ "id") } />
<fpml:role>{ if (get(s \ "id").mkString != msgNotFound) "Client" else msgNotFound}</fpml:role> <fpml:role>{ if (get(s \ "id").mkString != msgNotFound) "Client" else msgNotFound}</fpml:role>
<fpml:type>{ get(s \ "type") }</fpml:type> <fpml:type>{ get(s \ "type") }</fpml:type>
</fpml:relatedParty> </fpml:relatedParty>
<fpml:timestamps> <fpml:timestamps>
<fpml:timestamp> <fpml:timestamp>
<fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearedDate").mkString != msgNotFound) "InClearingPool" else msgNotFound}</fpml:type> <fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearedDate").mkString != msgNotFound) "InClearingPool" else msgNotFound}</fpml:type>
<fpml:value>{ <fpml:value>{
val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearedDate") val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "clearedDate")
if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound
}</fpml:value> }</fpml:value>
</fpml:timestamp> </fpml:timestamp>
<fpml:timestamp> <fpml:timestamp>
<fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "startAgreementDate").mkString != msgNotFound) "InPortfolio" else msgNotFound}</fpml:type> <fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "startAgreementDate").mkString != msgNotFound) "InPortfolio" else msgNotFound}</fpml:type>
<fpml:value>{ <fpml:value>{
val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "startAgreementDate") val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "startAgreementDate")
if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound
}</fpml:value> }</fpml:value>
</fpml:timestamp> </fpml:timestamp>
<fpml:timestamp> <fpml:timestamp>
<fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "endAgreementDate").mkString != msgNotFound) "OutPortfolio" else msgNotFound}</fpml:type> <fpml:type>{ if (get(source \ "trade" \ "nsdSpecificTradeFields" \ "endAgreementDate").mkString != msgNotFound) "OutPortfolio" else msgNotFound}</fpml:type>
<fpml:value>{ <fpml:value>{
val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "endAgreementDate") val d = get(source \ "trade" \ "nsdSpecificTradeFields" \ "endAgreementDate")
if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound if (d.mkString != msgNotFound) d + "T00:00:00" else msgNotFound
}</fpml:value> }</fpml:value>
</fpml:timestamp> </fpml:timestamp>
</fpml:timestamps> </fpml:timestamps>
<fpml:collateralizationType>{ <fpml:collateralizationType>{
get(source \ "trade" \ "collateral" \ "marginType").mkString match { get(source \ "trade" \ "collateral" \ "marginType").mkString match {
case v if v == "FC" => "Fully" case "FC" => "Fully"
case v if v == "PC" => "Partially" case "PC" => "Partially"
case v if v == "OC" => "OneWay" case "OC" => "OneWay"
case v if v == "U" => "Uncollateralized" case "U" => "Uncollateralized"
case _ => msgNotFound case _ => msgNotFound
} }
}</fpml:collateralizationType> }</fpml:collateralizationType>
<fpml:collateralPortfolio>{ get(source \ "trade" \ "collateral" \ "collateralForm") }</fpml:collateralPortfolio> <fpml:collateralPortfolio>{ get(source \ "trade" \ "collateral" \ "collateralForm") }</fpml:collateralPortfolio>
</fpml:partyTradeInformation> </fpml:partyTradeInformation>
} }
} }
</fpml:tradeHeader> </fpml:tradeHeader>
{ templateTradeBody } { templateTradeBody }
......
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