Interface ModelFormulaContextReadWrite

All Superinterfaces:
ModelFormulaContextReadOnly
All Known Subinterfaces:
ModelCalculationFormulaContext, ModelParallelCalculationFormulaInitContext, ModelParallelCalculationFormulaSummaryContext

public interface ModelFormulaContextReadWrite extends ModelFormulaContextReadOnly
  • Method Details

    • addTable

      DatamartContext.Table addTable(String name, Map<String,Object> tableSpecs)
      Add a table in the model. If the table already exists, it is replaced by this new table.

      As with all Field Collections in Pricefx, labels must be unique.

      A Map respecting the structure of DMTable, including:

      • label: the table label
      • fields: a List of Map respecting the structure of DMField, including name, 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"],
                   ]
           ])
       
      Parameters:
      name - The table name to be created in this model
      tableSpecs - The definition of the table to be created, see above.
      Returns:
      The created model table
      Since:
      8.0 Godfather
    • loadTable

      long loadTable(DatamartContext.Table table, DatamartContext.Query query, boolean truncate)
      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)
       
      Parameters:
      table - A table in this model
      query - The query to load into the table
      truncate - If the table should be truncated before loading
      Returns:
      The number of row added
      Since:
      8.0 Godfather
    • loadTable

      long loadTable(DatamartContext.Table table, DatamartContext.SqlQuery query, boolean truncate)
      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)
       
      Parameters:
      table - A table in this model
      query - The query to load into the table
      truncate - If the table should be truncated before loading
      Returns:
      The number of row added
      Since:
      8.0 Godfather
    • truncateTable

      void truncateTable(DatamartContext.Table table)
      Parameters:
      table - A table in the model
      Since:
      8.0 Godfather
    • dropTable

      void dropTable(DatamartContext.Table table)
      Parameters:
      table - A table in the model
      Since:
      8.0 Godfather
    • startJobTriggerCalculation

      void startJobTriggerCalculation(String imageName, String imageTag, String parameters, String jobName)
      It is the responsibility of the caller to serialize parameters however they are required by the image.

      parameters should only contain a few values. Because of infrastructure limitations, it's max length is 131000 bytes. If you need to give a large amount of data, you should consider using model tables.

      jobName should be unique inside the step and model formula calculation that triggers them. Since Job Trigger Calculations are created from within an existing formula calculation, its full name will be constructed from the calculation name and the job name passed to this method: calculationName:jobName. This name can be used to access the Job Trigger Calculation results with ModelFormulaContextReadOnly.outputs(String, String).

      Multiple job trigger calculation in a given formula calculation will run in parallel.

      Parameters:
      imageName - A docker image name, without the tag
      imageTag - A tag for the docker image name
      parameters - Some parameters understood by the image used
      jobName - A name for the job, unique per current step and calculation
      Since:
      8.0 Godfather
    • lookupTablesContext

      ModelLookupTablesContextReadWrite lookupTablesContext()
      Specified by:
      lookupTablesContext in interface ModelFormulaContextReadOnly
      Returns:
      a context for read/write operations on the lookup tables of this model
      Since:
      9.0 Hurricane
    • filterTreesContext

      ModelFilterTreesContextReadWrite filterTreesContext()
      Specified by:
      filterTreesContext in interface ModelFormulaContextReadOnly
      Returns:
      a context for read/write operations on the filter trees of this model
      Since:
      9.0 Hurricane
    • schedulesContext

      ModelSchedulesContextReadWrite schedulesContext()
      Specified by:
      schedulesContext in interface ModelFormulaContextReadOnly
      Returns:
      a context for manipulating Model Schedules
      Since:
      11.0 Paper Plane