Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6df5586
refresh view port after unfreezing and update tests
tanjjj Aug 7, 2025
9370da2
update test
tanjjj Aug 8, 2025
ab3b00b
add frozen time to hash
tanjjj Aug 8, 2025
d100eaa
revert force refresh after unfreeze
tanjjj Aug 8, 2025
707241e
update tests
tanjjj Aug 8, 2025
ef8cf38
revert force refresh after unfreeze
tanjjj Aug 8, 2025
6094a3e
update tests
tanjjj Aug 8, 2025
e5441c8
add a new way of creating join columns from a table
tanjjj Aug 8, 2025
e9bff5e
exclude default columns when creating join columns
tanjjj Aug 8, 2025
0230ab0
exclude default columns when creating join columns
tanjjj Aug 8, 2025
0ceab32
exclude default columns when creating join columns
tanjjj Aug 8, 2025
7f53cbf
exclude default columns when creating join columns
tanjjj Aug 8, 2025
1e1e1d5
exclude default columns when creating join columns
tanjjj Aug 8, 2025
da5348a
exclude default columns when creating join columns
tanjjj Aug 8, 2025
8bb7948
exclude default columns when creating join columns
tanjjj Aug 8, 2025
7648e5f
exclude default columns when creating join columns
tanjjj Aug 8, 2025
0a5aef1
exclude default columns when creating join columns
tanjjj Aug 8, 2025
50e3a4e
exclude default columns when creating join columns
tanjjj Aug 8, 2025
c008bb4
exclude default columns when creating join columns
tanjjj Aug 8, 2025
8f5dd79
revert dummy test
tanjjj Aug 8, 2025
d8c2e40
revert dummy test
tanjjj Aug 8, 2025
4936bb6
revert name change
tanjjj Aug 8, 2025
4cf28d3
add comment
tanjjj Aug 8, 2025
0217323
revert rename
tanjjj Aug 8, 2025
b73bbdd
refactor
tanjjj Aug 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions vuu/src/main/scala/org/finos/vuu/core/table/Column.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.finos.vuu.core.table

import com.typesafe.scalalogging.StrictLogging
import org.finos.vuu.api.TableDef
import org.finos.vuu.core.table.DefaultColumnNames.{CreatedTimeColumnName, LastUpdatedTimeColumnName, allDefaultColumns}
import org.finos.vuu.core.table.column.CalculatedColumnClause
import org.finos.vuu.util.schema.ExternalEntitySchema
import org.finos.vuu.util.types.{DefaultTypeConverters, TypeConverterContainerBuilder}
Expand Down Expand Up @@ -78,18 +79,26 @@ object Columns {
table.columns.filter(c => names.contains(c.name)).map(c => new JoinColumn(c.name, c.index, c.dataType, table, c))
}

/**
* Note: this method returns all columns of a given table, including the default columns of vuuCreatedTimestamp and vuuUpdatedTimestamp
* @return JoinColumn based on all columns of a given table except the default columns
*/
def allFrom(table: TableDef): Array[Column] = {
table.columns.map(c => new JoinColumn(c.name, c.index, c.dataType, table, c))
allFromExcept(table)
}

def aliased(table: TableDef, aliases: (String, String)*): Array[Column] = {
val aliased = aliases.map(tuple => tuple._1 -> tuple._2).toMap
table.columns.filter(c => aliased.contains(c.name)) map (c => new AliasedJoinColumn(aliased(c.name), c.index, c.dataType, table, c).asInstanceOf[Column])
}

/**
* Note: this method excludes the default columns of vuuCreatedTimestamp and vuuUpdatedTimestamp
*/
def allFromExcept(table: TableDef, excludeColumns: String*): Array[Column] = {
val columnsToExclude = excludeColumns ++ allDefaultColumns

val excluded = excludeColumns.map(s => s -> 1).toMap
val excluded = columnsToExclude.map(s => s -> 1).toMap

table.columns.filterNot(c => excluded.contains(c.name)).map(c => new JoinColumn(c.name, c.index, c.dataType, table, c))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package org.finos.vuu.core.table
object DefaultColumnNames {
val CreatedTimeColumnName: String = "vuuCreatedTimestamp"
val LastUpdatedTimeColumnName: String = "vuuUpdatedTimestamp"
val allDefaultColumns: Array[String] = Array(CreatedTimeColumnName, LastUpdatedTimeColumnName)
}
2 changes: 1 addition & 1 deletion vuu/src/main/scala/org/finos/vuu/viewport/ViewPort.scala
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class ViewPortImpl(val id: String,


override def getStructuralHashCode(): Int = {
37 * filterAndSort.hashCode() ^ getGroupBy.hashCode() ^ getColumns.hashCode() ^ permissionChecker().hashCode()
37 * filterAndSort.hashCode() ^ getGroupBy.hashCode() ^ getColumns.hashCode() ^ permissionChecker().hashCode() ^ viewPortFrozenTimestamp.hashCode()
}

private def getTreeNodeStateHash(): Int = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import org.scalatest.GivenWhenThen
import org.scalatest.featurespec.AnyFeatureSpec
import org.scalatest.matchers.should.Matchers

class ModuleSyntaxTest extends AnyFeatureSpec with Matchers with GivenWhenThen{
class ModuleSyntaxTest extends AnyFeatureSpec with Matchers with GivenWhenThen {

Feature("check the new builder syntax for view server modules"){
Feature("check the new builder syntax for view server modules") {

Scenario("check we can parse the module"){
Scenario("check we can parse the module") {

Given("A test module which several tables defined, which takes some parameters (these are simple example params but could be complicated lifecycle stuff)")
implicit val tableDefContainer: TableDefContainer = new TableDefContainer(Map())
val module = TestModule2.apply("foo", 100)
module.tableDefs.size should be (3)
module.tableDefs.size should be(3)
module.name should equal("TEST")

val instruments = module.tableDefs.head
Expand All @@ -33,16 +33,16 @@ class ModuleSyntaxTest extends AnyFeatureSpec with Matchers with GivenWhenThen{
)
)
instruments.joinFields should equal(Seq("ric"))

val prices = module.tableDefs.tail.head
prices.name should equal("prices")
prices.columns.size should equal(9)
prices.joinFields should equal(Seq("ric"))

val instrumentPrices = module.tableDefs.tail.tail.head
instrumentPrices.name should equal("instrumentPrices")
// TODO once https://github.com/finos/vuu/issues/1653 is done, review the expected value of columns.size in the next line
instrumentPrices.columns.size should equal(prices.columns.size + instruments.columns.size - 1 + 2)
instrumentPrices.columns.size should equal((prices.columns.size - 2) + (instruments.columns.size - 2) - 1 + 2)
// exclude default columns in left and right table and exclude join column, and add default columns to the join table itself

instrumentPrices.joinFields should equal(Seq())
}
Expand Down
38 changes: 38 additions & 0 deletions vuu/src/test/scala/org/finos/vuu/core/table/ColumnTest.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.finos.vuu.core.table

import org.finos.vuu.api.{ColumnBuilder, TableDef}
import org.finos.vuu.util.types.TypeUtils
import org.scalatest.featurespec.AnyFeatureSpec
import org.scalatest.matchers.should.Matchers
Expand Down Expand Up @@ -41,4 +42,41 @@ class ColumnTest extends AnyFeatureSpec with Matchers {

}

Feature("Columns.allFromExceptDefaultColumns") {
Scenario("Create join columns for all columns in table def except default columns") {
val tableDef = TableDef(
name = "TestTable",
keyField = "Id",
columns =
new ColumnBuilder()
.addString("Id")
.addString("Name")
.addInt("Account")
.build()
)

val joinColumns = Columns.allFrom(tableDef)
joinColumns.length shouldEqual 3
joinColumns.map(_.name) should contain theSameElementsAs Array("Id", "Name", "Account")
}
}

Feature("Columns.allFromExcept") {
Scenario("Create join columns for all columns in table def except given columns and default columns") {
val tableDef = TableDef(
name = "TestTable",
keyField = "Id",
columns =
new ColumnBuilder()
.addString("Id")
.addString("Name")
.addInt("Account")
.build()
)

val joinColumns = Columns.allFromExcept(tableDef, "Name")
joinColumns.length shouldEqual 2
joinColumns.map(_.name) should contain theSameElementsAs Array("Id", "Account")
}
}
}
Loading
Loading