Skip to content

Commit

Permalink
finos#1052 using the new basket provider and deleting old csv static …
Browse files Browse the repository at this point in the history
…loader
  • Loading branch information
naleeha authored and chrisjstevo committed Jan 4, 2024
1 parent cddecb2 commit 166d52a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 166 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@ import org.finos.toolbox.lifecycle.LifecycleContainer
import org.finos.toolbox.thread.RunOnceLifeCycleRunner
import org.finos.toolbox.time.Clock
import org.finos.vuu.core.module.basket.BasketConstants
import org.finos.vuu.core.module.basket.csv.CsvStaticLoader
import org.finos.vuu.core.module.basket.csv.BasketLoader
import org.finos.vuu.core.table.{DataTable, RowWithData}
import org.finos.vuu.provider.DefaultProvider

class BasketConstituentProvider(val table: DataTable)(implicit lifecycle: LifecycleContainer, clock: Clock) extends DefaultProvider {

private val runner = new RunOnceLifeCycleRunner("BasketConstituentProvider", runOnce)
private val basketLoader = new BasketLoader()

lifecycle(this).dependsOn(runner)

import org.finos.vuu.core.module.basket.BasketModule.BasketConstituentColumnNames._

def runOnce(): Unit = {
val baskets = CsvStaticLoader.load
val baskets = basketLoader.loadBasketIds()
baskets.foreach(basketId => updateBasketConstituents(basketId))
}

def updateBasketConstituents(basketId: String): Unit = {
val list = CsvStaticLoader.loadConstituent(basketId)
val list = basketLoader.loadConstituents(basketId)
list.foreach(row => {

if (row.nonEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import org.finos.toolbox.lifecycle.LifecycleContainer
import org.finos.toolbox.thread.RunOnceLifeCycleRunner
import org.finos.toolbox.time.Clock
import org.finos.vuu.core.module.basket.BasketModule.BasketColumnNames._
import org.finos.vuu.core.module.basket.csv.CsvStaticLoader
import org.finos.vuu.core.module.basket.csv.BasketLoader
import org.finos.vuu.core.table.{DataTable, RowWithData}
import org.finos.vuu.provider.DefaultProvider

class BasketProvider(val table: DataTable)(implicit lifecycle: LifecycleContainer, clock: Clock) extends DefaultProvider {

private val runner = new RunOnceLifeCycleRunner("BasketProvider", runOnce)
private val basketLoader = new BasketLoader()

lifecycle(this).dependsOn(runner)
def runOnce(): Unit = {
val data = CsvStaticLoader.load
val data = basketLoader.loadBasketIds()

data.foreach(id => {
table.processUpdate(id, RowWithData(id, Map(
Expand All @@ -23,7 +24,5 @@ class BasketProvider(val table: DataTable)(implicit lifecycle: LifecycleContaine
)), clock.now())
})
}


override val lifecycleId: String = "org.finos.vuu.core.module.basket.provider.BasketProvider"
}

This file was deleted.

0 comments on commit 166d52a

Please sign in to comment.