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
5bb51892
Commit
5bb51892
authored
Oct 21, 2018
by
Amelin Konstantin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete attrEmpty check from render, delete product type from RepoTemplate
parent
455fe23c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
44 deletions
+26
-44
src/main/scala/templates/RepoTemplate.scala
+24
-37
src/main/scala/templates/Template.scala
+1
-6
src/test/scala/templates/TemplateSpec.scala
+1
-1
No files found.
src/main/scala/templates/RepoTemplate.scala
View file @
5bb51892
...
@@ -4,15 +4,6 @@ import scala.util.Try
...
@@ -4,15 +4,6 @@ import scala.util.Try
import
scala.xml.Node
import
scala.xml.Node
final
class
RepoTemplate
(
source
:
Node
)
extends
TradeTemplate
(
source
)
{
final
class
RepoTemplate
(
source
:
Node
)
extends
TradeTemplate
(
source
)
{
trait
ProductType
case
object
Equity
extends
ProductType
case
object
Bond
extends
ProductType
private
[
this
]
val
productType
=
(
source
\
"trade"
\
"repo"
\
"productType"
).
head
.
text
.
mkString
match
{
case
"Equity:Repo:EquityRepo"
=>
Equity
case
"InterestRate:Repo:BondRepo"
=>
Bond
}
protected
[
this
]
def
templateTrade
:
Node
=
{
protected
[
this
]
def
templateTrade
:
Node
=
{
<
fpml
:
trade>
<
fpml
:
trade>
<fpml:tradeHeader>
<fpml:tradeHeader>
...
@@ -124,26 +115,24 @@ final class RepoTemplate(source: Node) extends TradeTemplate(source) {
...
@@ -124,26 +115,24 @@ final class RepoTemplate(source: Node) extends TradeTemplate(source) {
<fpmlext:repo
xsi:
type
=
"rtsrep:Repo"
>
<fpmlext:repo
xsi:
type
=
"rtsrep:Repo"
>
<
fpml
:
productId>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
productType
"
)
.head
})
}
</fpml:productId>
<
fpml
:
productId>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
productType
"
)
.head
})
}
</fpml:productId>
<fpml:productId
productIdScheme
={
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"productId"
).
head
},
"productIdScheme"
)
}>{
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"productId"
).
head
})
}</
fpml
:
productId>
<fpml:productId
productIdScheme
={
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"productId"
).
head
},
"productIdScheme"
)
}>{
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"productId"
).
head
})
}</
fpml
:
productId>
{
if
(
productType
==
Equity
)
{
<fpmlext:fixedRateSchedule>
<
fpmlext
:
fixedRateSchedule>
<fpml:initialValue>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
fixedRateSchedule
"
\
"
initialValue
"
)
.head
})
}
</fpml:initialValue>
<fpml:initialValue>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
fixedRateSchedule
"
\
"
initialValue
"
)
.head
})
}
</fpml:initialValue>
<step>
<step>
<stepDate>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
fixedRateSchedule
"
\\
"
stepDate
"
)
.head
})
}
</stepDate>
<stepDate>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
fixedRateSchedule
"
\\
"
stepDate
"
)
.head
})
}
</stepDate>
<stepValue>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
fixedRateSchedule
"
\\
"
stepValue
"
)
.head
})
}
</stepValue>
<stepValue>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
fixedRateSchedule
"
\\
"
stepValue
"
)
.head
})
}
</stepValue>
</step>
</step>
</fpmlext:fixedRateSchedule>
</fpmlext:fixedRateSchedule>
<fpmlext:floatingRateCalculation>
else
if
(
productType
==
Bond
)
<fpml:floatingRateIndex>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
floatingRateCalculation
"
\
"
floatingRateIndex
"
)
.head
})
}
</fpml:floatingRateIndex>
<
fpmlext
:
floatingRateCalculation>
<indexTenor>
<fpml:floatingRateIndex>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
floatingRateCalculation
"
\
"
floatingRateIndex
"
)
.head
})
}
</fpml:floatingRateIndex>
<periodMultiplier>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
floatingRateCalculation
"
\\
"
periodMultiplier
"
)
.head
})
}
</periodMultiplier>
<indexTenor>
<period>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
floatingRateCalculation
"
\\
"
period
"
)
.head
})
}
</period>
<periodMultiplier>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
floatingRateCalculation
"
\\
"
periodMultiplier
"
)
.head
})
}
</periodMultiplier>
</indexTenor>
<period>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
floatingRateCalculation
"
\\
"
period
"
)
.head
})
}
</period>
<spreadSchedule>
</indexTenor>
<initialValue>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
floatingRateCalculation
"
\\
"
initialValue
"
)
.head
})
}
</initialValue>
<spreadSchedule>
</spreadSchedule>
<initialValue>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
floatingRateCalculation
"
\\
"
initialValue
"
)
.head
})
}
</initialValue>
<initialRate>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
floatingRateCalculation
"
\\
"
initialRate
"
)
.head
})
}
</initialRate>
</spreadSchedule>
</fpmlext:floatingRateCalculation>
<initialRate>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
floatingRateCalculation
"
\\
"
initialRate
"
)
.head
})
}
</initialRate>
</fpmlext:floatingRateCalculation>
}
}
<fpmlext:dayCountFraction>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
dayCountFraction
"
)
.head
})
}
</fpmlext:dayCountFraction>
<fpmlext:dayCountFraction>
{
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
dayCountFraction
"
)
.head
})
}
</fpmlext:dayCountFraction>
<fpmlext:spotLeg
xsi:
type
=
"rtsrep:RepoTransactionLeg"
>
<fpmlext:spotLeg
xsi:
type
=
"rtsrep:RepoTransactionLeg"
>
...
@@ -192,14 +181,12 @@ final class RepoTemplate(source: Node) extends TradeTemplate(source) {
...
@@ -192,14 +181,12 @@ final class RepoTemplate(source: Node) extends TradeTemplate(source) {
</rtsrep:deliveryDate>
</rtsrep:deliveryDate>
*/
}
*/
}
</fpmlext:forwardLeg>
</fpmlext:forwardLeg>
{
if
(
productType
==
Equity
)
{
<fpml:equity
id
={
get
(
Try
{
(
source
\
"
trade
"
\
"
repo
"
\
"
equity
"
)
.head
},
"
id
"
)
}>
<
fpml
:
equity
id
={
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"equity"
).
head
},
"id"
)
}>
<
fpml
:
instrumentId
instrumentIdScheme
=
""
>{
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"equity"
\
"instrumentId"
).
head
})
}</
fpml
:
instrumentId>
<
fpml
:
instrumentId
instrumentIdScheme
=
""
>{
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"equity"
\
"instrumentId"
).
head
})
}</
fpml
:
instrumentId>
</fpml:equity>
</fpml:equity>
<fpml:bond
id
={
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"bond"
).
head
},
"id"
)
}>
else
if
(
productType
==
Bond
)
<
fpml
:
instrumentId
instrumentIdScheme
=
""
>{
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"bond"
\
"instrumentId"
).
head
})
}</
fpml
:
instrumentId>
<
fpml
:
bond
id
={
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"bond"
).
head
},
"id"
)
}>
</fpml:bond>
<
fpml
:
instrumentId
instrumentIdScheme
=
""
>{
get
(
Try
{
(
source
\
"trade"
\
"repo"
\
"bond"
\
"instrumentId"
).
head
})
}</
fpml
:
instrumentId>
</fpml:bond>
}
}
</
fpmlext
:
repo>
</
fpmlext
:
repo>
<fpml:documentation>
<fpml:documentation>
...
...
src/main/scala/templates/Template.scala
View file @
5bb51892
...
@@ -64,11 +64,6 @@ abstract class Template(protected[this] val source: Node) {
...
@@ -64,11 +64,6 @@ abstract class Template(protected[this] val source: Node) {
def
template
:
Node
def
template
:
Node
def
render
:
Node
=
{
def
render
:
Node
=
{
def
attrIsEmpty
(
n
:
Node
)
:
Boolean
=
n
match
{
case
v
:
Elem
if
v.child.isEmpty
=>
v
.
attributes
.
isEmpty
case
_
=>
n
.
attributes
.
isEmpty
&&
n
.
child
.
forall
(
attrIsEmpty
)
}
val
rule1
:
RewriteRule
=
new
RewriteRule
{
val
rule1
:
RewriteRule
=
new
RewriteRule
{
override
def
transform
(
n
:
Node
)
:
NodeSeq
=
n
match
{
override
def
transform
(
n
:
Node
)
:
NodeSeq
=
n
match
{
case
v
:
Elem
if
v.attributes.nonEmpty
&&
v.attributes.value.text.contains
(
msgNotFound
)
=>
case
v
:
Elem
if
v.attributes.nonEmpty
&&
v.attributes.value.text.contains
(
msgNotFound
)
=>
...
@@ -81,7 +76,7 @@ abstract class Template(protected[this] val source: Node) {
...
@@ -81,7 +76,7 @@ abstract class Template(protected[this] val source: Node) {
override
def
transform
(
n
:
Node
)
:
NodeSeq
=
n
match
{
override
def
transform
(
n
:
Node
)
:
NodeSeq
=
n
match
{
case
v
if
v
.
text
==
msgNotFound
=>
case
v
if
v
.
text
==
msgNotFound
=>
NodeSeq
.
Empty
NodeSeq
.
Empty
case
v
:
Elem
if
attrIsEmpty
(
v
)
&&
v.text.filterNot
(
_
.isWhitespace
)
.isEmpty
=>
case
v
:
Elem
if
v.text.filterNot
(
_
.isWhitespace
)
.isEmpty
=>
NodeSeq
.
Empty
NodeSeq
.
Empty
case
_
=>
n
case
_
=>
n
}
}
...
...
src/test/scala/templates/TemplateSpec.scala
View file @
5bb51892
...
@@ -56,7 +56,7 @@ class TemplateSpec extends WordSpec {
...
@@ -56,7 +56,7 @@ class TemplateSpec extends WordSpec {
{
get
(
Try
{
(
source
\\
"repo"
\
"from"
).
head
})
}
{
get
(
Try
{
(
source
\\
"repo"
\
"from"
).
head
})
}
</
from
>
</
from
>
<
to
href
={
get
(
Try
{
(
source
\\
"repo"
\
"to"
).
head
},
"href"
)
}>
<
to
href
={
get
(
Try
{
(
source
\\
"repo"
\
"to"
).
head
},
"href"
)
}>
{
get
(
Try
{
(
source
\\
"repo"
\
"
notExist
"
).
head
})
}
{
get
(
Try
{
(
source
\\
"repo"
\
"
to
"
).
head
})
}
</
to
>
</
to
>
</
repo
>
</
repo
>
<
notFoundpart
>{
get
(
Try
{
(
source
\\
"notFoundpart"
).
head
})
}</
notFoundpart
>
<
notFoundpart
>{
get
(
Try
{
(
source
\\
"notFoundpart"
).
head
})
}</
notFoundpart
>
...
...
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