Skip to content

Commit

Permalink
Merge branch 'keikeicheung-main'
Browse files Browse the repository at this point in the history
  • Loading branch information
keikeicheung committed Jun 28, 2024
2 parents d161340 + 0737c1a commit c3c61ae
Show file tree
Hide file tree
Showing 20 changed files with 215 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ object BasketModule extends DefaultModule {
BT.Status.string(), BT.Units.int(), BT.FilledPct.double(), BT.FxRateToUsd.double(),
BT.TotalNotional.double(), BT.TotalNotionalUsd.double(), BT.Side.string()
), // we can join to instruments and other tables to get the rest of the data.....
VisualLinks(),
VisualLinks(
Link(BT.InstanceId, BasketTradingTable, BT.InstanceId)
),
indices = Indices(
Index(BT.InstanceId)
),
joinFields = BT.BasketId
),
(table, vs) => new BasketTradingProvider(table, vs.tableContainer),
Expand All @@ -87,7 +92,10 @@ object BasketModule extends DefaultModule {
BTC.OrderStatus.string()
),// we can join to instruments and other tables to get the rest of the data.....
VisualLinks(
Link(BTC.InstanceId, BasketTradingTable, BT.InstanceId),
Link(BTC.BasketId, BasketTradingTable, BT.BasketId),
),
indices = Indices(
Index(BTC.BasketId)
),
joinFields = BTC.InstanceIdRic, BTC.Ric
),
Expand Down Expand Up @@ -124,6 +132,9 @@ object BasketModule extends DefaultModule {
name = BasketTradingConstituentJoin,
baseTable = tableDefs.get(NAME, BasketTradingConstituentTable),
joinColumns = Columns.allFrom(tableDefs.get(NAME, BasketTradingConstituentTable)) ++ Columns.allFromExcept(tableDefs.get(PriceModule.NAME, "prices"), "ric"),
VisualLinks(
Link(BTC.BasketId, BasketTradingTable, BT.BasketId)
),
joins =
JoinTo(
table = tableDefs.get(PriceModule.NAME, PriceModule.PriceTable),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ object SimulationModule extends DefaultModule {
table = tableDefs.get(PriceModule.NAME, "prices"),
joinSpec = JoinSpec(left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
))
.addJoinTable(tableDefs =>
Expand All @@ -256,6 +257,7 @@ object SimulationModule extends DefaultModule {
table = tableDefs.get(PriceModule.NAME, "prices"),
joinSpec = JoinSpec(left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
))
.addJoinTable(tableDefs =>
Expand All @@ -268,6 +270,7 @@ object SimulationModule extends DefaultModule {
table = tableDefs.get(PriceModule.NAME, "prices"),
joinSpec = JoinSpec(left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
))
.asModule()
Expand Down
4 changes: 2 additions & 2 deletions vuu/src/main/scala/org/finos/vuu/api/TableDef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ case class AvailableViewPortVisualLink(parentVpId: String, link: Link) {
override def toString: String = "(" + parentVpId.split("-").last + ")" + link.fromColumn + " to " + link.toTable + "." + link.toColumn
}

class JoinSessionTableDef(name: String, baseTable: TableDef, joinColumns: Array[Column], joinFields: Seq[String], joins: JoinTo*) extends JoinTableDef(name, baseTable, joinColumns, joinFields) with VuuInMemPluginLocator
class JoinSessionTableDef(name: String, baseTable: TableDef, joinColumns: Array[Column], joinFields: Seq[String], joins: JoinTo*) extends JoinTableDef(name, baseTable, joinColumns, links = VisualLinks(), joinFields) with VuuInMemPluginLocator

class SessionTableDef(name: String,
keyField: String,
Expand Down Expand Up @@ -178,7 +178,7 @@ case class JoinSpec(left: String, right: String, joinType: JoinType = InnerJoin)

case class JoinTo(table: TableDef, joinSpec: JoinSpec)

case class JoinTableDef(override val name: String, baseTable: TableDef, joinColumns: Array[Column], override val joinFields: Seq[String], joins: JoinTo*) extends TableDef(name, baseTable.keyField, joinColumns, joinFields, indices = Indices()) with VuuInMemPluginLocator{
case class JoinTableDef(override val name: String, baseTable: TableDef, joinColumns: Array[Column], override val links: VisualLinks, override val joinFields: Seq[String], joins: JoinTo*) extends TableDef(name, baseTable.keyField, joinColumns, joinFields, indices = Indices(), autosubscribe = false) with VuuInMemPluginLocator{

lazy val joinTableColumns = getJoinDefinitionColumnsInternal()
lazy val rightTables = joins.map(join => join.table.name).toArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ object TestModule2 extends DefaultModule {
right = "ric",
LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
))
.addRpcHandler( vs => new TestRpcHandler(vs.tableContainer))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.finos.vuu.core.module.modulefrommodule

import org.finos.toolbox.lifecycle.LifecycleContainer
import org.finos.toolbox.time.Clock
import org.finos.vuu.api.{JoinSpec, JoinTableDef, JoinTo, LeftOuterJoin}
import org.finos.vuu.api.{JoinSpec, JoinTableDef, JoinTo, LeftOuterJoin, VisualLinks}
import org.finos.vuu.core.module.{ModuleFactory, TableDefContainer, ViewServerModule}
import org.finos.vuu.core.table.Columns

Expand All @@ -23,6 +23,7 @@ object JoinModule {
table = tableDefs.get(Price.NAME, "price"),
joinSpec = JoinSpec(left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
))
.asModule()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ object TableTestHelper {
table = pricesDef,
joinSpec = JoinSpec( left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class JoinManagerTest extends AnyFeatureSpec with Matchers with StrictLogging wi
table = pricesDef,
joinSpec = JoinSpec(left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq("orderId", "currencyPair", "ric")
)
}
Expand All @@ -146,6 +147,7 @@ class JoinManagerTest extends AnyFeatureSpec with Matchers with StrictLogging wi
name = "orderPricesFx",
baseTable = ordersDef,
joinColumns = Columns.allFrom(ordersDef) ++ Columns.allFromExcept(pricesDef, "ric") ++ Columns.allFromExcept(fxDef, "ric"),
links = VisualLinks(),
joinFields = Seq("orderId"),
JoinTo(
table = pricesDef,
Expand All @@ -168,6 +170,7 @@ class JoinManagerTest extends AnyFeatureSpec with Matchers with StrictLogging wi
table = orderPrices,
joinSpec = JoinSpec(left = "orderId", right = "orderId", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
)
}
Expand All @@ -179,6 +182,7 @@ class JoinManagerTest extends AnyFeatureSpec with Matchers with StrictLogging wi
joinColumns = Columns.allFrom(orders2Def)
++ Columns.allFromExcept(pricesDef, "ric")
++ Columns.allFromExcept(fxRates, "currencyPair"),
links = VisualLinks(),
joinFields = Seq(),
joins =
JoinTo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class JoinTableTest extends AnyFeatureSpec with Matchers with ViewPortSetup {
table = pricesDef,
joinSpec = JoinSpec( left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ class JoinsOfJoinsTableTest extends AnyFeatureSpec with Matchers with ViewPortSe
table = pricesDef,
joinSpec = JoinSpec( left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq("ccyCross", "orderId")
)

val joinDefFx = JoinTableDef(
name = "orderPricesFx",
baseTable = ordersDef,
joinColumns = Columns.allFrom(ordersDef) ++ Columns.allFromExcept(pricesDef, "ric") ++ Columns.allFrom(fxDef),
links = VisualLinks(),
joinFields = Seq("ccyCross", "orderId"),
JoinTo(
table = pricesDef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class MultiJoinTableTest extends AnyFeatureSpec with Matchers with OneInstancePe
Columns.allFromExcept(instrumentDef, "ric") ++
Columns.aliased(fxRatesDef, ("bid","fxBid"), ("ask","fxAsk"), ("ccyPair","ccyPair")),
//Columns.calculated("chris1", "bid * fxBid"),
links = VisualLinks(),
joinFields = Seq(),
joins =
JoinTo(
Expand Down Expand Up @@ -126,6 +127,7 @@ class MultiJoinTableTest extends AnyFeatureSpec with Matchers with OneInstancePe
Columns.allFromExcept(instrumentDef, "ric") ++
Columns.aliased(fxRatesDef, ("bid","fxBid"), ("ask","fxAsk"), ("ccyPair","ccyPair")),
//Columns.calculated("chris1", "bid * fxBid"),
links = VisualLinks(),
joinFields = Seq(),
joins =
JoinTo(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.finos.vuu.viewport

import org.finos.toolbox.jmx.{MetricsProvider, MetricsProviderImpl}
import org.finos.toolbox.jmx.MetricsProvider
import org.finos.toolbox.lifecycle.LifecycleContainer
import org.finos.toolbox.time.{Clock, TestFriendlyClock}
import org.finos.toolbox.time.Clock
import org.finos.vuu.api._
import org.finos.vuu.core.table.{Columns, DataTable, TableContainer}
import org.finos.vuu.feature.inmem.VuuInMemPlugin
Expand All @@ -12,15 +12,15 @@ import org.finos.vuu.provider.{JoinTableProviderImpl, MockProvider, ProviderCont
import org.finos.vuu.util.OutboundRowPublishQueue
import org.scalatest.featurespec.AnyFeatureSpec

object TestTimeStamp{
object TestTimeStamp {
def EPOCH_DEFAULT = 1311544800000L
}

class AbstractViewPortTestCase extends AnyFeatureSpec {


def filterByVpId(vpUps: Seq[ViewPortUpdate], vp: ViewPort): Seq[ViewPortUpdate] = {
vpUps.filter( vpu => vpu.vp.id == vp.id )
vpUps.filter(vpu => vpu.vp.id == vp.id)
}

def setupViewPort(tableContainer: TableContainer, providerContainer: ProviderContainer)(implicit clock: Clock, metrics: MetricsProvider): ViewPortContainer = {
Expand All @@ -36,29 +36,30 @@ class AbstractViewPortTestCase extends AnyFeatureSpec {
def createDefaultViewPortInfra()(implicit clock: Clock, metrics: MetricsProvider): (ViewPortContainer, DataTable, MockProvider, ClientSessionId, OutboundRowPublishQueue) = {
implicit val lifecycle: LifecycleContainer = new LifecycleContainer

val dateTime = 1437728400000L//new LocalDateTime(2015, 7, 24, 11, 0).toDateTime.toInstant.getMillis
val dateTime = 1437728400000L //new LocalDateTime(2015, 7, 24, 11, 0).toDateTime.toInstant.getMillis

val ordersDef = TableDef(
name = "orders",
keyField = "orderId",
columns = Columns.fromNames("orderId:String", "trader:String", "ric:String", "tradeTime:Long", "quantity:Int"),
joinFields = "ric", "orderId")
name = "orders",
keyField = "orderId",
columns = Columns.fromNames("orderId:String", "trader:String", "ric:String", "tradeTime:Long", "quantity:Int"),
joinFields = "ric", "orderId")

val pricesDef = TableDef("prices", "ric", Columns.fromNames("ric:String", "bid:Double", "ask:Double", "last:Double", "open:Double", "close:Double"), "ric")

val joinDef = JoinTableDef(
name = "orderPrices",
baseTable = ordersDef,
joinColumns = Columns.allFrom(ordersDef) ++ Columns.allFromExcept(pricesDef, "ric"),
joins =
JoinTo(
table = pricesDef,
joinSpec = JoinSpec( left = "ric", right = "ric", LeftOuterJoin)
),
joinFields = Seq()
name = "orderPrices",
baseTable = ordersDef,
joinColumns = Columns.allFrom(ordersDef) ++ Columns.allFromExcept(pricesDef, "ric"),
joins =
JoinTo(
table = pricesDef,
joinSpec = JoinSpec(left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
)

val joinProvider = JoinTableProviderImpl()
val joinProvider = JoinTableProviderImpl()

val tableContainer = new TableContainer(joinProvider)

Expand All @@ -85,11 +86,10 @@ class AbstractViewPortTestCase extends AnyFeatureSpec {
}



def createDefaultOrderPricesViewPortInfra()(implicit clock: Clock, metrics: MetricsProvider): (ViewPortContainer, DataTable, MockProvider, DataTable, MockProvider, ClientSessionId, OutboundRowPublishQueue) = {
implicit val lifecycle = new LifecycleContainer

val dateTime = 1437728400000L//new LocalDateTime(2015, 7, 24, 11, 0).toDateTime.toInstant.getMillis
val dateTime = 1437728400000L //new LocalDateTime(2015, 7, 24, 11, 0).toDateTime.toInstant.getMillis

val ordersDef = TableDef(
name = "orders",
Expand All @@ -101,24 +101,25 @@ class AbstractViewPortTestCase extends AnyFeatureSpec {
indices = Indices(
Index("ric")
),
joinFields = "ric", "orderId"
joinFields = "ric", "orderId"
)

val pricesDef = TableDef("prices", "ric", Columns.fromNames("ric:String", "bid:Double", "ask:Double", "last:Double", "open:Double", "close:Double", "exchange:String"), "ric")

val joinDef = JoinTableDef(
name = "orderPrices",
baseTable = ordersDef,
joinColumns = Columns.allFrom(ordersDef) ++ Columns.allFromExcept(pricesDef, "ric"),
joins =
name = "orderPrices",
baseTable = ordersDef,
joinColumns = Columns.allFrom(ordersDef) ++ Columns.allFromExcept(pricesDef, "ric"),
joins =
JoinTo(
table = pricesDef,
joinSpec = JoinSpec( left = "ric", right = "ric", LeftOuterJoin)
joinSpec = JoinSpec(left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
)

val joinProvider = JoinTableProviderImpl()
val joinProvider = JoinTableProviderImpl()

val tableContainer = new TableContainer(joinProvider)

Expand Down Expand Up @@ -147,12 +148,13 @@ class AbstractViewPortTestCase extends AnyFeatureSpec {
def createPricesRow(pricesProvider: MockProvider, ric: String, bid: Double, ask: Double, last: Double, close: Double): Unit = {
pricesProvider.tick(ric, Map("ric" -> ric, "bid" -> bid, "ask" -> ask, "last" -> last, "close" -> close))
}

def createPricesRow(pricesProvider: MockProvider, ric: String, bid: Double, ask: Double, last: Double, close: Double, exchange: String): Unit = {
pricesProvider.tick(ric, Map("ric" -> ric, "bid" -> bid, "ask" -> ask, "last" -> last, "close" -> close, "exchange" -> exchange))
}

def createNOrderRows(ordersProvider: MockProvider, n: Int, ric: String = "VOD.L", idOffset: Int = 0)(implicit clock: Clock): Unit = {
(0 until n).foreach(i=>{
(0 until n).foreach(i => {
val iAsString = (idOffset + i).toString
val orderId = "NYC-" + "0".padTo(4 - iAsString.length, "0").mkString + iAsString
val quantity = 100 + i
Expand All @@ -162,7 +164,7 @@ class AbstractViewPortTestCase extends AnyFeatureSpec {
}

def createNOrderRows(ordersProvider: MockProvider, n: Int)(implicit clock: Clock): Unit = {
(0 until n).foreach(i=>{
(0 until n).foreach(i => {
val iAsString = i.toString
val orderId = "NYC-" + "0".padTo(4 - iAsString.length, "0").mkString + iAsString
val quantity = 100 + i
Expand All @@ -181,7 +183,7 @@ class AbstractViewPortTestCase extends AnyFeatureSpec {
})
}

def buildOrderRowUpdate(i : Int, quantity: Int): (String, Map[String, Any]) = {
def buildOrderRowUpdate(i: Int, quantity: Int): (String, Map[String, Any]) = {
val iAsString = i.toString
val orderId = "NYC-" + "0".padTo(4 - iAsString.length, "0").mkString + iAsString
val update = Map("orderId" -> orderId, "quantity" -> quantity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class AmendViewPortToTreeTest extends AnyFeatureSpec with ViewPortSetup {
table = pricesDef,
joinSpec = JoinSpec(left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
)

Expand Down Expand Up @@ -156,6 +157,7 @@ class AmendViewPortToTreeTest extends AnyFeatureSpec with ViewPortSetup {
table = pricesDef,
joinSpec = JoinSpec(left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.finos.vuu.viewport
import org.finos.toolbox.jmx.{MetricsProvider, MetricsProviderImpl}
import org.finos.toolbox.lifecycle.LifecycleContainer
import org.finos.toolbox.time.{Clock, TestFriendlyClock}
import org.finos.vuu.api.{JoinSpec, JoinTableDef, JoinTo, LeftOuterJoin, TableDef}
import org.finos.vuu.api.{JoinSpec, JoinTableDef, JoinTo, LeftOuterJoin, TableDef, VisualLinks}
import org.finos.vuu.client.messages.RequestId
import org.finos.vuu.core.table.TableTestHelper.combineQs
import org.finos.vuu.core.table.{Columns, TableContainer, ViewPortColumnCreator}
Expand Down Expand Up @@ -231,6 +231,7 @@ class CalculatedColumnsViewPortTest extends AbstractViewPortTestCase with Matche
table = pricesDef,
joinSpec = JoinSpec(left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ChangeViewPortTest extends AnyFeatureSpec{
table = pricesDef,
joinSpec = JoinSpec( left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ object OrdersAndPricesScenarioFixture {
table = pricesDef,
joinSpec = JoinSpec( left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ trait ViewPortSetup {
table = pricesDef,
joinSpec = JoinSpec( left = "ric", right = "ric", LeftOuterJoin)
),
links = VisualLinks(),
joinFields = Seq()
)

Expand Down
Loading

0 comments on commit c3c61ae

Please sign in to comment.