Skip to content

Commit

Permalink
finos#1415 table meta data to return table columns by default if view…
Browse files Browse the repository at this point in the history
… port def is not explicitly defined
  • Loading branch information
naleeha committed Jul 26, 2024
1 parent 2cb881b commit 23f0a28
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 1 addition & 3 deletions vuu/src/main/scala/org/finos/vuu/api/ViewPortDef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ object ViewPortDef {
new ViewPortDef(columns, service)
}

def default: ViewPortDef = NoViewPortDef
def default(columns: Array[Column]): ViewPortDef = ViewPortDef(columns, NoRpcHandler)
}

class ViewPortDef(val columns: Array[Column], val service: RpcHandler) {}

object NoRpcHandler extends RpcHandler {
override def menuItems(): ViewPortMenu = EmptyViewPortMenu
}

object NoViewPortDef extends ViewPortDef(Array(), NoRpcHandler)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.finos.vuu.core.module

import org.finos.vuu.api.{JoinTableDef, NoViewPortDef, TableDef, ViewPortDef}
import org.finos.vuu.api.{JoinTableDef, TableDef, ViewPortDef}
import org.finos.vuu.core.{IVuuServer, VuuServer}
import org.finos.vuu.core.table.{DataTable, TableContainer}
import org.finos.vuu.net.rest.RestService
Expand Down Expand Up @@ -52,7 +52,7 @@ case class ModuleFactoryNode protected(tableDefs: TableDefs,
) {

def addTable(tableDef: TableDef, func: (DataTable, IVuuServer) => Provider): ModuleFactoryNode = {
val noViewPortDefFunc = (dt: DataTable, prov: Provider, providerContainer: ProviderContainer, tableContainer: TableContainer) => NoViewPortDef
val noViewPortDefFunc = (table: DataTable, _: Provider, _: ProviderContainer, _: TableContainer) => ViewPortDef.default(table.getTableDef.columns)
ModuleFactoryNode(tableDefs.add(tableDef, func), rpc, vsName, staticServedResources, rest, viewPortDefs ++ Map(tableDef.name -> noViewPortDefFunc), tableDefContainer, unrealizedViewPortDefs)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.finos.toolbox.text.AsciiUtil
import org.finos.toolbox.thread.RunInThread
import org.finos.toolbox.time.TimeIt.{timeIt, timeItThen}
import org.finos.toolbox.time.{Clock, TimeIt}
import org.finos.vuu.api.{Link, NoViewPortDef, ViewPortDef}
import org.finos.vuu.api.{Link, ViewPortDef}
import org.finos.vuu.client.messages.ViewPortId
import org.finos.vuu.core.filter.{Filter, FilterSpecParser, NoFilter}
import org.finos.vuu.core.sort._
Expand Down Expand Up @@ -250,7 +250,7 @@ class ViewPortContainer(val tableContainer: TableContainer, val providerContaine
def getViewPortDefinition(table: DataTable): ViewPortDef = {
val viewPortDefFunc = getViewPortDefinitionCreator(table)
if (viewPortDefFunc == null)
ViewPortDef.default
ViewPortDef.default(table.getTableDef.columns)
else
viewPortDefFunc(table.asTable, table.asTable.getProvider, providerContainer, tableContainer)
}
Expand Down
5 changes: 3 additions & 2 deletions vuu/src/test/scala/org/finos/vuu/net/WebSocketApiTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,13 @@ class WebSocketApiTest extends AnyFeatureSpec with BeforeAndAfterAll with GivenW

vuuClient.send(sessionId, tokenId, GetTableMetaRequest(ViewPortTable("TableMetaDefaultVPTest", "TEST")))

Then("return view port columns in response")
Then("return table columns as default view port columns in response")
val response = vuuClient.awaitForMsgWithBody[GetTableMetaResponse]
assert(response.isDefined)

val responseMessage = response.get
responseMessage.columns.length shouldEqual 0
responseMessage.columns.length shouldEqual 1
responseMessage.columns shouldEqual Array("Id")
}

Scenario("client requests to get table metadata for a non existent") {
Expand Down

0 comments on commit 23f0a28

Please sign in to comment.