Published Jan 06
Model Logic Key Methods
Model Evaluation Logic Methods:
Include a Configurator:
api.inlineConfigurator(“ConfiguratorName”, "LogicName")
Get an Input from the Configurator:
input[“ConfiguratorName”][“inputName”]
Read tables:
def query = api.getDatamartContext().newQuery(model.table(“tableName”), false)
Model Calculation Logic Methods:
Get an Input from the Configurator:
def ConfiguratorName = model.inputs("stepName","tabName").getAt(“ConfiguratorName”)
input = ConfiguratorName[“inputName”]
Create Table:
def dataTable = model.addTable(”TableName”, [
label : “TableLabel”,
fields: fieldsMapList,
])
Read Table:
def query = api.getDatamartContext().newQuery(model.table(“tableName”), false)
Read Table with SQL:
sql = “
SELECT T1.*, T2.* FROM T1 LEFT JOIN T2 ON ...
”
def sqlQuery = dmCtx.newSqlQuery()
.addSource(query1).addSource(query2).addSource(query3).….setQuery(sql)
Load Table:
model.loadTable(dataTable, query, true)
Load Table with SQL:
model.loadTable(dataTable, sqlQuery, true)
Load Table by Row:
def dmCtx = api.datamartContext
def loader = dmCtx.newDataLoader(dataTable)
finalMapList.each {
loader.addRow(it)
}
loader.flush()
Get the Output in the Same Calculation:
Out[“ElementName”]
Get the Output of Another Calculation:
model.outputs("StepName","CalculationName")[“ElementName”]
Model Parallel Calculation Logic Methods:
Add Items in the Init Phase:
model.addCalculationItem(“keyvalue”,itemMap)
Get Items in the Item Phase:
def itemMap = model.calculationItem()
itemMap.key()
itemMap.inputs()
Add Items in the Item Phase:
def itemMapList = [[:]]
...
resultItemMap.put("itemMapList", itemMapList)
return resultItemMap
Retrieve Items in the Summary Phase:
def items = model.calculationItems()
def calculationItemList = items.toList()
def finalMapList = []
calculationItemList.each { calculationItem ->
if (calculationItem.status() == ModelParallelCalculationFormulaSummaryContext.CalculationItem.Status.CALCULATED) {
if (calculationItem?.outputs()?.keySet().size() > 0) {
def resultItemMap = calculationItem?.outputs()?.get("ItemElementName")
finalMapList.addAll(resultItemMap.getAt("itemMapList"))
}
}
}
, multiple selections available,
Related content
Model Evaluation Logic
Model Evaluation Logic
Read with this
Model Calculation Logic
Model Calculation Logic
More like this
Model Evaluation Configurator Logic
Model Evaluation Configurator Logic
Read with this
Model Classes and Models Overview
Model Classes and Models Overview
Read with this
Model Parallel Calculation Logic
Model Parallel Calculation Logic
Read with this
Model Object (MO)
Model Object (MO)
Read with this
Found an issue in documentation? Write to us.