-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#862 Added ability to edit baskets join service.
- Loading branch information
1 parent
e39dc90
commit 9c41539
Showing
9 changed files
with
148 additions
and
376 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
.../scala/org/finos/vuu/core/module/basket/service/BasketTradingConstituentJoinService.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package org.finos.vuu.core.module.basket.service | ||
|
||
import com.typesafe.scalalogging.StrictLogging | ||
import org.finos.toolbox.time.Clock | ||
import org.finos.vuu.api.JoinTableDef | ||
import org.finos.vuu.core.module.basket.BasketModule.BasketTradingConstituentColumnNames.InstanceIdRic | ||
import org.finos.vuu.core.table.{DataTable, JoinTable, RowWithData, TableContainer} | ||
import org.finos.vuu.net.ClientSessionId | ||
import org.finos.vuu.net.rpc.{EditRpcHandler, RpcHandler} | ||
import org.finos.vuu.viewport._ | ||
|
||
class BasketTradingConstituentJoinService(val table: DataTable, val tableContainer: TableContainer)(implicit clock: Clock) extends RpcHandler with EditRpcHandler with StrictLogging { | ||
|
||
def onDeleteRow(key: String, vp: ViewPort, session: ClientSessionId): ViewPortEditAction = { | ||
ViewPortEditSuccess() | ||
} | ||
|
||
def onDeleteCell(key: String, column: String, vp: ViewPort, session: ClientSessionId): ViewPortEditAction = { | ||
ViewPortEditSuccess() | ||
} | ||
|
||
def onAddRow(key: String, data: Map[String, Any], vp: ViewPort, session: ClientSessionId): ViewPortEditAction = { | ||
ViewPortEditSuccess() | ||
} | ||
|
||
private def onEditCell(key: String, columnName: String, data: Any, vp: ViewPort, session: ClientSessionId): ViewPortEditAction = { | ||
val joinTable = vp.table.asTable.asInstanceOf[JoinTable] | ||
val baseTableDef = joinTable.getTableDef.asInstanceOf[JoinTableDef].baseTable | ||
joinTable.sourceTables.get(baseTableDef.name) match { | ||
case Some(table: DataTable) => | ||
table.processUpdate(key, RowWithData(key, Map(InstanceIdRic -> key, columnName -> data)), clock.now()) | ||
ViewPortEditSuccess() | ||
case None => | ||
ViewPortEditFailure("Could not find base table") | ||
} | ||
} | ||
|
||
private def onEditRow(key: String, row: Map[String, Any], vp: ViewPort, session: ClientSessionId): ViewPortEditAction = { | ||
val table = vp.table.asTable | ||
table.processUpdate(key, RowWithData(key, row), clock.now()) | ||
ViewPortEditSuccess() | ||
} | ||
|
||
private def onFormSubmit(vp: ViewPort, session: ClientSessionId): ViewPortAction = { | ||
// val table = vp.table.asTable | ||
// val primaryKeys = table.primaryKeys | ||
// val headKey = primaryKeys.head | ||
// val sequencerNumber = table.pullRow(headKey).get("sequenceNumber").asInstanceOf[Int].toLong | ||
// | ||
// if (sequencerNumber > 0) { | ||
// logger.info("I would now send this fix seq to a fix engine to reset, we're all good:" + sequencerNumber) | ||
// CloseDialogViewPortAction(vp.id) | ||
// } else { | ||
// logger.error("Seq number not set, returning error") | ||
// ViewPortEditFailure("Sequencer number has not been set.") | ||
// } | ||
CloseDialogViewPortAction(vp.id) | ||
} | ||
|
||
private def onFormClose(vp: ViewPort, session: ClientSessionId): ViewPortAction = { | ||
CloseDialogViewPortAction(vp.id) | ||
} | ||
|
||
|
||
override def deleteRowAction(): ViewPortDeleteRowAction = ViewPortDeleteRowAction("", this.onDeleteRow) | ||
|
||
override def deleteCellAction(): ViewPortDeleteCellAction = ViewPortDeleteCellAction("", this.onDeleteCell) | ||
|
||
override def addRowAction(): ViewPortAddRowAction = ViewPortAddRowAction("", this.onAddRow) | ||
|
||
override def editCellAction(): ViewPortEditCellAction = ViewPortEditCellAction("", this.onEditCell) | ||
|
||
override def editRowAction(): ViewPortEditRowAction = ViewPortEditRowAction("", this.onEditRow) | ||
|
||
override def onFormSubmit(): ViewPortFormSubmitAction = ViewPortFormSubmitAction("", this.onFormSubmit) | ||
|
||
override def onFormClose(): ViewPortFormCloseAction = ViewPortFormCloseAction("", this.onFormClose) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters