Class ModelCalculationFormulaContext.ForFormulaDeployment
- Object
-
- ForFormulaDeployment
-
- All Implemented Interfaces:
ModelCalculationFormulaContext
,ModelFormulaContextReadOnly
,ModelFormulaContextReadWrite
- Enclosing interface:
- ModelCalculationFormulaContext
public static final class ModelCalculationFormulaContext.ForFormulaDeployment extends Object implements ModelCalculationFormulaContext
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface ModelCalculationFormulaContext
ModelCalculationFormulaContext.ForFormulaDeployment
-
-
Constructor Summary
Constructors Constructor Description ForFormulaDeployment()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Table
addTable(String name, Map<String,Object> tableSpecs)
Add a table in the model.void
dropTable(Table table)
String
label()
long
loadTable(Table table, DMSqlQuery source, boolean truncate)
Sample code:long
loadTable(Table table, Query source, boolean truncate)
Sample code:void
startJobTriggerCalculation(String imageName, String imageTag, String parameters, String calculationContext)
It is the responsibility of the caller to serializeparameters
however they are required by the image.Map<String,Object>
state()
Table
table(String name)
void
truncateTable(Table table)
String
uniqueName()
-
-
-
Method Detail
-
uniqueName
public String uniqueName()
- Specified by:
uniqueName
in interfaceModelFormulaContextReadOnly
- Returns:
- The unique name of this model
-
label
public String label()
- Specified by:
label
in interfaceModelFormulaContextReadOnly
- Returns:
- The label of this model
-
state
public Map<String,Object> state()
- Specified by:
state
in interfaceModelFormulaContextReadOnly
- Returns:
- The state of this model
-
table
public Table table(String name)
- Specified by:
table
in interfaceModelFormulaContextReadOnly
- Parameters:
name
- The table name in this model- Returns:
- The existing model table or
null
if it doesn't exist
-
startJobTriggerCalculation
public void startJobTriggerCalculation(String imageName, String imageTag, String parameters, String calculationContext)
Description copied from interface:net.pricefx.formulaengine.optimization.ModelFormulaContextReadWrite
It is the responsibility of the caller to serializeparameters
however they are required by the image.calculationContext
should be unique per model formula calculation that triggers them.Multiple job trigger calculation in a given formula calculation will run in parallel.
- Specified by:
startJobTriggerCalculation
in interfaceModelFormulaContextReadWrite
-
addTable
public Table addTable(String name, Map<String,Object> tableSpecs)
Description copied from interface:net.pricefx.formulaengine.optimization.ModelFormulaContextReadWrite
Add a table in the model. If the table already exists, it is replaced by this new table.A
Map
respecting the structure ofDMTable
, including:label
: the table labelfields
: aList
ofMap
respecting the structure ofDMField
, includingname
,label
,type
,format
,key
,dimension
Sample code:
model.addTable("RevenueByProduct", [ label: "Revenue By Product", // the fields must respect DMField structure fields: [ [ name:"productId", label:"Product ID", type:"TEXT", key:true], [ name:"productGroup", label:"ProductGroup", type:"TEXT", dimension:true], [ name:"revenue", label:"Revenue", type:"MONEY"], ] ])
- Specified by:
addTable
in interfaceModelFormulaContextReadWrite
- Parameters:
name
- The table name to be created in this modeltableSpecs
- The definition of the table to be created, see above.- Returns:
- The created model table
-
loadTable
public long loadTable(Table table, Query source, boolean truncate)
Description copied from interface:net.pricefx.formulaengine.optimization.ModelFormulaContextReadWrite
Sample code:def ctx = api.getDatamartContext() def query = ctx.newQuery(ctx.getDataSource("txDS")) .select("sku", "P") .select("SUM(amount)", "R") def table = model.getTable('MyTable') def nbRowAdded = model.loadTable(table, query, false)
- Specified by:
loadTable
in interfaceModelFormulaContextReadWrite
- Parameters:
table
- A table in this modelsource
- The query to load into the tabletruncate
- If the table should be truncated before loading- Returns:
- The number of row added
-
loadTable
public long loadTable(Table table, DMSqlQuery source, boolean truncate)
Description copied from interface:net.pricefx.formulaengine.optimization.ModelFormulaContextReadWrite
Sample code:def ctx = api.getDatamartContext() def t1 = ctx.newQuery(ctx.getDataSource("txDS")) .select("sku", "P") .select("SUM(amount)", "R") def query = ctx.newSqlQuery() query.addSource(t1) query.setQuery('SELECT P, R::numeric as R FROM T1 ORDER BY P') def table = model.getTable('MyTable') def nbRowAdded = model.loadTable(table, query, false)
- Specified by:
loadTable
in interfaceModelFormulaContextReadWrite
- Parameters:
table
- A table in this modelsource
- The query to load into the tabletruncate
- If the table should be truncated before loading- Returns:
- The number of row added
-
truncateTable
public void truncateTable(Table table)
- Specified by:
truncateTable
in interfaceModelFormulaContextReadWrite
- Parameters:
table
- A table in the model
-
dropTable
public void dropTable(Table table)
- Specified by:
dropTable
in interfaceModelFormulaContextReadWrite
- Parameters:
table
- A table in the model
-
-