Skip to content

Commit

Permalink
#1415 returning viewport columns rather than table columns when getti…
Browse files Browse the repository at this point in the history
…ng table metadata
  • Loading branch information
naleeha authored and keikeicheung committed Jul 22, 2024
1 parent 3335381 commit 717d0be
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,11 @@ class CoreServerApiHandler(val viewPortContainer: ViewPortContainer,
if(table == null)
errorMsg(s"No such table found with name ${msg.table.table} in module ${msg.table.module}")(ctx)
else{
val columnNames = table.getTableDef.columns.sortBy(_.index).map(_.name)
val dataTypes = columnNames.map(table.getTableDef.columnForName(_)).map(col => DataType.asString(col.dataType))

val viewPortDef = viewPortContainer.getViewPortDefinition(table)
val columns = viewPortDef.columns.sortBy(_.index)
val columnNames = columns.map(_.name)
val dataTypes = columns.map(col => DataType.asString(col.dataType))
vsMsg(GetTableMetaResponse(msg.table, columnNames, dataTypes, table.getTableDef.keyField))(ctx)
}
}
Expand Down
14 changes: 10 additions & 4 deletions vuu/src/main/scala/org/finos/vuu/viewport/ViewPortContainer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,15 @@ class ViewPortContainer(val tableContainer: TableContainer, val providerContaine
viewPortDefinitions.put(table, vpDefFunc)
}

private def getViewPortDefinition(table: DataTable): (DataTable, Provider, ProviderContainer, TableContainer) => ViewPortDef = {
def getViewPortDefinition(table: DataTable): ViewPortDef = {
val viewPortDefFunc = getViewPortDefinitionCreator(table)
if (viewPortDefFunc == null)
ViewPortDef.default
else
viewPortDefFunc(table.asTable, table.asTable.getProvider, providerContainer, tableContainer)
}

private def getViewPortDefinitionCreator(table: DataTable): (DataTable, Provider, ProviderContainer, TableContainer) => ViewPortDef = {
table match {
case session: SessionTable =>
viewPortDefinitions.get(table.getTableDef.name)
Expand Down Expand Up @@ -560,9 +568,7 @@ class ViewPortContainer(val tableContainer: TableContainer, val providerContaine
plugin => plugin.viewPortTableCreator.create(table, clientSession, groupBy, tableContainer)
}

val viewPortDefFunc = getViewPortDefinition(table.asTable)

val viewPortDef = if (viewPortDefFunc == null) NoViewPortDef else viewPortDefFunc(table.asTable, table.asTable.getProvider, providerContainer, tableContainer)
val viewPortDef = getViewPortDefinition(table.asTable)

val structural = viewport.ViewPortStructuralFields(aTable, columns, viewPortDef, filtAndSort, filterSpec, sortSpecInternal, groupBy, ClosedTreeNodeState, None)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.finos.toolbox.lifecycle.LifecycleContainer
import org.finos.toolbox.time.{Clock, DefaultClock}
import org.finos.vuu.api.{ColumnBuilder, NoRpcHandler, TableDef, ViewPortDef}
import org.finos.vuu.core._
import org.finos.vuu.core.module.{TableDefContainer, TestModule}
import org.finos.vuu.core.module.TableDefContainer
import org.finos.vuu.net.auth.AlwaysHappyAuthenticator
import org.finos.vuu.net.http.VuuHttp2ServerOptions
import org.finos.vuu.net.json.JsonVsSerializer
Expand Down

0 comments on commit 717d0be

Please sign in to comment.