Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SPB_Exchange_Repo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Amelin Konstantin
SPB_Exchange_Repo
Commits
9872178a
Commit
9872178a
authored
Oct 19, 2018
by
Amelin Konstantin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite render
parent
82523709
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
7 deletions
+13
-7
src/main/scala/Main.scala
+3
-3
src/main/scala/templates/RepoTemplate.scala
+4
-0
src/main/scala/templates/Template.scala
+6
-4
No files found.
src/main/scala/Main.scala
View file @
9872178a
...
...
@@ -6,12 +6,12 @@ import templates._
object
Main
extends
App
{
val
p
=
new
PrettyPrinter
(
140
,
2
)
val
sourceXml
=
XML
.
loadFile
(
"src/main/resources/nsd/Repo NSD
bond
.xml"
)
val
sourceXml
=
XML
.
loadFile
(
"src/main/resources/nsd/Repo NSD
equity
.xml"
)
val
template
=
Template
(
sourceXml
)
val
outputXml
=
XML
.
loadString
(
p
.
format
(
template
.
template
))
val
outputXml
=
XML
.
loadString
(
p
.
format
(
template
.
render
))
//val outputXml = template.template
template
.
log
()
//
template.log()
Try
{
...
...
src/main/scala/templates/RepoTemplate.scala
View file @
9872178a
...
...
@@ -162,11 +162,13 @@ final class RepoTemplate(source: Node) extends TradeTemplate(source) {
<fpmlext:assetReference
href
=
"RU0009109391"
/>
</
fpmlext
:
collateral>
*/
}
{
/*
<rtsrep:deliveryDate>
<fpml:adjustableDate>
<fpml:unadjustedDate>{ get(Try { (source \ "trade" \ "repo" \ "spotLeg" \ "deliveryDate" \\ "unadjustedDate").head }) }</fpml:unadjustedDate>
</fpml:adjustableDate>
</rtsrep:deliveryDate>
*/
}
</
fpmlext
:
spotLeg>
<fpmlext:forwardLeg
xsi:
type
=
"rtsrep:ForwardRepoTransactionLeg"
>
<
fpml
:
buyerPartyReference
href
={
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"forwardLeg"
\
"buyerPartyReference"
).
head
},
"href"
)
}
/>
...
...
@@ -180,11 +182,13 @@ final class RepoTemplate(source: Node) extends TradeTemplate(source) {
<fpml:currency>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
forwardLeg
"
\\
"
currency
"
)
.head
})
}
</fpml:currency>
<fpml:amount>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
forwardLeg
"
\\
"
amount
"
)
.head
})
}
</fpml:amount>
</fpml:settlementAmount>
{
/*
<rtsrep:deliveryDate>
<fpml:adjustableDate>
<fpml:unadjustedDate>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
forwardLeg
"
\
"
deliveryDate
"
\\
"
unadjustedDate
"
)
.head
})
}
</fpml:unadjustedDate>
</fpml:adjustableDate>
</rtsrep:deliveryDate>
*/
}
</fpmlext:forwardLeg>
{
if
(
productType
==
Equity
)
<
fpml
:
equity
id
={
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"equity"
).
head
},
"id"
)
}>
...
...
src/main/scala/templates/Template.scala
View file @
9872178a
...
...
@@ -66,15 +66,17 @@ abstract class Template(protected[this] val source: Node) {
def
render
:
Node
=
{
val
rule
:
RewriteRule
=
new
RewriteRule
{
override
def
transform
(
n
:
Node
)
:
NodeSeq
=
n
match
{
case
v
if
v
.
attributes
.
nonEmpty
&&
v
.
attributes
.
filter
(
_
.
value
.
text
==
msgNotFound
).
nonEmpty
=>
NodeSeq
.
Empty
case
v
if
v
.
child
.
length
==
1
&&
v
.
child
.
head
.
text
==
msgNotFound
=>
case
v
if
v
.
text
==
msgNotFound
=>
NodeSeq
.
Empty
case
v
:
Elem
if
v.attributes.nonEmpty
&&
v.attributes.value.text.contains
(
msgNotFound
)
=>
v
.
copy
(
attributes
=
v
.
attributes
.
filter
(
_
.
value
.
text
!=
msgNotFound
))
case
_
=>
n
}
}
new
RuleTransformer
(
rule
).
transform
(
template
).
head
val
rt
=
new
RuleTransformer
(
rule
)
rt
.
transform
(
template
).
head
}
def
log
()
:
Unit
=
data
.
foreach
(
e
=>
println
(
e
.
_2
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment