public class StrategicModel
extends java.lang.Object
implements java.io.Closeable
By default, parameters are case insensitive and may not be null or empty unless otherwise specified.
StrategicModel Object has to be invoked with withCloseable for the models opened to be closed when the StrategicModel object goes out of scope. If used without specifying withCloseable the models will not be closed after executing the rule.
StrategicModel Grid Builders:
Example call from Groovy of pushing data from the "Operations US East" Strategic Model to "Operations US East" entity in Planning:
Example call from Groovy of pushing data from 'Operations US' entity in Planning to the 'Operations US' Strategic Model:def smPbcsYearMap = ['2017':'FY17', '2018':'FY18'] def pbcsAccountNames = ['OFS_Product Revenue', 'OFS_Services Revenue', 'OFS_Support Revenue', 'OFS_Discounts', 'OFS_Other Cost of Sales', 'OFS_Salaries', 'OFS_Selling Expense', 'OFS_Depreciation'] List smYears = smPbcsYearMap.collect {it.key} // Collect the values from the smPbcsYearMap into a list. List pbcsYears = smPbcsYearMap.collect {it.value} operation.application.getStrategicModel("Operations US East").withCloseable { smModel-> // Load data from Strategic Model. DataGridDefinitionBuilder builder = smModel.dataGridDefinitionBuilder() builder.addPov(['Scenario'], [ ['Forecast'] ]) builder.addColumn(['Time'], [ ['2017', '2018'] ]) builder.addRow(['Account'], [ ['v1000:010', 'v1000:020', 'v1000:030', 'v1020', 'v1040', 'v1080:010', 'v1080:020', 'v1110'] ]) DataGridDefinition gridDefinition = builder.build() smModel.loadGrid(gridDefinition).withCloseable{ smGrid -> // Construct a data grid to push data to Planning. Cube cube = operation.application.getCube("OEP_FS") DataGridBuilder gridBuilder = cube.dataGridBuilder("MM/DD/YYYY") gridBuilder.addPov('Dec','OEP_Strategic Planning', 'USD', 'Target', 'Operations US East', 'OFS_Direct Input', 'Smart Phone 6 in', 'US Market') gridBuilder.addColumn(pbcsYears as String[]) int k = 0; // Number of items on the column. int numColumns = 2; def rowdata = [] smGrid.dataCellIterator().each { // Scale to millions. rowdata << it.data * 0.000001 // Print the list of members from all dimensions that the cell represents along with its data. println("$it.memberNames, cell data: ${it.data * 0.000001}") // Get entire row - 2 data cells. if (rowdata.size() == numColumns) { gridBuilder.addRow([pbcsAccountNames[k]], rowdata) k++ // Reset the data array to pick next row. rowdata = [] } } // Build a status object which will be filled in when building the DataGrid object. DataGridBuilder.Status status = new DataGridBuilder.Status() gridBuilder.build(status).withCloseable{ planningGrid -> // Print number of cells in the planningGrid to the job console. println("Size of the grid: " + planningGrid.size()) // Print the number of cells accepted/rejected by the builder to the job console. println("Total number of cells accepted: $status.numAcceptedCells") println("Total number of cells rejected: $status.numRejectedCells") println("First $status.numRejectedCells rejected cells: $status.cellsRejected") // Push data to Planning. cube.saveGrid(planningGrid) } // Close the Planning data grid (planningGrid). } // Close Strategic Model data grid (smGrid). } // Close Strategic Model (smModel).
Example call from Groovy of pushing data from multiple entities in Planning to corresponding Strategic Models with the same name:// Load data from Planning. Cube cube = operation.application.getCube("OEP_FS") DataGridDefinitionBuilder defBuilder = cube.dataGridDefinitionBuilder() defBuilder.addPov(['Years', 'Scenario', 'Currency', 'Version', 'Entity', 'Market', 'Plan Element', 'Product'], [ ['FY17'], ['OEP_Strategic Planning'], ['USD'], ['OEP_Working'], ['Operations US'], ['US Market'], ['OFS_Direct Input'], ['Smart Phone 6 in'] ]) defBuilder.addColumn(['Period'], [ ['YearTotal'] ]) defBuilder.addRow(['Account'], [ ['OFS_Product Revenue', 'OFS_Services Revenue','OFS_Support Revenue','OFS_Adjustments to Revenue','OFS_Total Cost Of Sales','OFS_Other Revenue'] ]) DataGridDefinition gridDefinition = defBuilder.build() // Collect data to be pushed to Strategic Model. def data = [] cube.loadGrid(gridDefinition, true).withCloseable { grid -> // Scale to millions. double millionsScalingFactor = 0.000001 grid.dataCellIterator().each{ data << it.data / millionsScalingFactor println("$it.memberNames, cell data: $it.data") } } // Close the Planning data grid (grid). // Construct the data grid to push data to Strategic Model. operation.application.getStrategicModel('Operations US').withCloseable { smModel -> DataGridBuilder gridBuilder = smModel.dataGridBuilder() gridBuilder.addPov('Forecast') gridBuilder.addColumn('2017') println("Pushing " + data[0] + "to Product Sales") gridBuilder.addRow(['v1000:010'], [data[0]]) println("Pushing " + data[1] + "to Service Revenue") gridBuilder.addRow(['v1000:020'], [data[1]]) println("Pushing " + data[3] + "to Discounts & Returns") gridBuilder.addRow(['v1020'], [data[3]]) println("Pushing " + data[4] + "to Cost of Goods Sold") gridBuilder.addRow(['v1040'], [data[4]]) double supportRevenue = data[2] double otherRevenue = data[5] double totalSupportOtherRevenue = supportRevenue + otherRevenue println("Pushing " + totalSupportOtherRevenue + "to Other Revenues") gridBuilder.addRow(['v1000:030'], [totalSupportOtherRevenue]) // Build a status object which will be filled in when building the DataGrid object. DataGridBuilder.Status status = new DataGridBuilder.Status() gridBuilder.build(status).withCloseable { smGrid -> // Print the number of cells accepted/rejected by the builder to the job console. println("Total number of cells accepted: $status.numAcceptedCells") println("Total number of cells rejected: $status.numRejectedCells") println("First 100 rejected cells: $status.cellsRejected") // Push data to the Strategic Model. smModel.saveGrid(smGrid) } // Close the Strategic Model data grid (smGrid). } // Close the Strategic Model (smModel).
Example call from Groovy of pushing data from multiple Strategic Models to corresponding entities in Planning with the same name:// Define mappings for Account dimension members between PBCS and Strategic Models. def smToPbcsAccountNameMap = ['v1000:010' : 'OFS_Product Revenue', 'v1000:020' : 'OFS_Services Revenue', 'v1000:030' : 'OFS_Support Revenue', 'v1020' : 'OFS_Discounts', 'v1040' : 'OFS_Total Cost Of Sales'] def smPbcsYearMap = ['2017':'FY17', '2018':'FY18'] // List of strategic modeling years 2017, 2018. List smYears = smPbcsYearMap.collect {it.key} // List of PBCS years - FT17, FY18. List pbcsYears = smPbcsYearMap.collect {it.value} // Reverse the key value pair from the existing maps. def pbcsToSMAccountNameMap = smToPbcsAccountNameMap.collectEntries { k, v -> [v, k]} as Map<String, String> // Map of Planning to Strategic Modeling scenarios. def pbcstoSMScenarioMap = ['OEP_Strategic Planning' : 'Forecast'] String pbcsScenarioName = 'OEP_Strategic Planning' String smScenarioName = pbcstoSMScenarioMap.get(pbcsScenarioName) ?: pbcsScenarioName; ["Operations US East", "Operations US West", "Operations US North", "Operations US South"].each { String modelName -> // Load data from Planning for the current entity (modelName). Cube cube = operation.application.getCube("OEP_FS") DataGridDefinitionBuilder defBuilder = cube.dataGridDefinitionBuilder() defBuilder.addPov(['Period', 'Scenario', 'Currency', 'Version', 'Entity', 'Market', 'Plan Element', 'Product'], [ ['YearTotal'], [pbcsScenarioName], ['USD'], ['OEP_Working'], [modelName], ['US Market'], ['OFS_Direct Input'], ['Smart Phone 6 in'] ]) defBuilder.addColumn(['Years'], [ ['FY17', 'FY18'] ]) defBuilder.addRow(['Account'], [ ['OFS_Product Revenue', 'OFS_Services Revenue','OFS_Support Revenue','OFS_Discounts','OFS_Total Cost Of Sales','OFS_Other Revenue'] ]) DataGridDefinition gridDefinition = defBuilder.build() cube.loadGrid(gridDefinition, true).withCloseable { grid -> operation.application.getStrategicModel(modelName).withCloseable { smModel -> // Construct a data grid for the current model (modelName) to push data to Strategic Model. DataGridBuilder gridBuilder = smModel.dataGridBuilder() gridBuilder.addPov(smScenarioName) // Push the years list as String array. gridBuilder.addColumn(smYears as String[]) // Scale to million. double millionsScalingFactor = 0.000001 grid.dataCellIterator('OFS_Product Revenue', 'FY17').each { DataCell productRevenue18 = it.crossDimCell('OFS_Product Revenue', 'FY18') gridBuilder.addRow([pbcsToSMAccountNameMap[it.accountName]], [it.data / millionsScalingFactor, productRevenue18.data / millionsScalingFactor]) println(it.yearName + ", " + pbcsToSMAccountNameMap[it.accountName] + ", " + it.data / millionsScalingFactor + ", " + productRevenue18.data / millionsScalingFactor) DataCell servicesRevenue = it.crossDimCell('OFS_Services Revenue', 'FY17') DataCell servicesRevenue18 = it.crossDimCell('OFS_Services Revenue', 'FY18') gridBuilder.addRow([pbcsToSMAccountNameMap[servicesRevenue.accountName]], [servicesRevenue.data / millionsScalingFactor, servicesRevenue18.data / millionsScalingFactor]) println(it.yearName + ", " + pbcsToSMAccountNameMap[servicesRevenue.accountName] + ", " + servicesRevenue.data / millionsScalingFactor + ", " + servicesRevenue18.data / millionsScalingFactor) DataCell adjRevenue = it.crossDimCell('OFS_Discounts', 'FY17') DataCell adjRevenue18 = it.crossDimCell('OFS_Discounts', 'FY18') gridBuilder.addRow([pbcsToSMAccountNameMap[adjRevenue.accountName]], [adjRevenue.data / millionsScalingFactor, adjRevenue18.data / millionsScalingFactor]) println(it.yearName + ", " + pbcsToSMAccountNameMap[adjRevenue.accountName] + ", " + adjRevenue.data / millionsScalingFactor + ", " + adjRevenue18.data / millionsScalingFactor) DataCell cosRevenue = it.crossDimCell('OFS_Total Cost Of Sales', 'FY17') DataCell cosRevenue18 = it.crossDimCell('OFS_Total Cost Of Sales', 'FY18') gridBuilder.addRow([pbcsToSMAccountNameMap[cosRevenue.accountName]], [cosRevenue.data / millionsScalingFactor, cosRevenue18.data / millionsScalingFactor]) println(it.yearName + ", " + cosRevenue.accountName + ": " + pbcsToSMAccountNameMap[cosRevenue.accountName] + ", " + cosRevenue.data / millionsScalingFactor + ", " + cosRevenue18.data / millionsScalingFactor) DataCell supportRevenue = it.crossDimCell('OFS_Support Revenue', 'FY17') DataCell otherRevenue = it.crossDimCell('OFS_Other Revenue', 'FY17') DataCell supportRevenue18 = it.crossDimCell('OFS_Support Revenue', 'FY18') DataCell otherRevenue18 = it.crossDimCell('OFS_Other Revenue', 'FY18') def totalRev17 = (supportRevenue.data / millionsScalingFactor) + (otherRevenue.data / millionsScalingFactor) def totalRev18 = (supportRevenue18.data / millionsScalingFactor) + (otherRevenue18.data / millionsScalingFactor) gridBuilder.addRow([pbcsToSMAccountNameMap[supportRevenue.accountName]], [totalRev17, totalRev18]) println(it.yearName + ", " + pbcsToSMAccountNameMap[supportRevenue.accountName] + ", " + totalRev17 + "," + totalRev18) } // Build a status object which will be filled in when building the DataGrid object. DataGridBuilder.Status status = new DataGridBuilder.Status() gridBuilder.build(status).withCloseable { smGrid -> // Print the number of cells accepted/rejected by the builder to the job console. println("Total number of cells accepted: $status.numAcceptedCells") println("Total number of cells rejected: $status.numRejectedCells") println("First 10 rejected cells: $status.cellsRejected") // Push data to Strategic Model. smModel.saveGrid(smGrid) } // Close the Strategic Model data grid (smGrid). } // Close the Strategic Model (smModel). } // Close the Planning data grid (grid). } // For each entity.
Example call from Groovy of pushing data to the 'Retail AC' Strategic Model using the options to treat missing values and to preserve input/output cells in the Strategic Model:// Define mappings for Account dimension members between PBCS and Strategic Models. def smToPbcsAccountNameMap = ['v1000:010' : 'OFS_Product Revenue', 'v1000:020' : 'OFS_Services Revenue', 'v1000:030' : 'OFS_Support Revenue', 'v1020' : 'OFS_Discounts', 'v1040' : 'OFS_Other Cost of sales', 'v1080:010' : 'OFS_Salaries', 'v1080:020' : 'OFS_Selling Expense', 'v1110' : 'OFS_Depreciation'] def smToPbcsScenarioNameMap = ['Forecast' : 'Target'] def smPbcsYearMap = ['2017':'FY17', '2018':'FY18'] List smYears = smPbcsYearMap.collect {it.key} List pbcsYears = smPbcsYearMap.collect {it.value} // Load data from Strategic Models to Planning entities. ["Operations US East", "Operations US West", "Operations US North", "Operations US South"].each { String modelName -> def pbcsEntityName = modelName operation.application.getStrategicModel(modelName).withCloseable { smModel -> String smScenarioName = 'Forecast' def pbcsScenarioName = smToPbcsScenarioNameMap.get(smScenarioName) ?: smScenarioName // Load data for the current Strategic Model (modelName). DataGridDefinitionBuilder builder = smModel.dataGridDefinitionBuilder() builder.addPov(['Scenario'], [ [smScenarioName] ]) builder.addColumn(['Time'], [ smYears ]) builder.addRow(['Account'], [ ['v1000:010', 'v1000:020', 'v1000:030', 'v1020', 'v1040', 'v1080:010', 'v1080:020', 'v1110'] ]) DataGridDefinition gridDefinition = builder.build() smModel.loadGrid(gridDefinition).withCloseable { smGrid -> // Construct a data grid to push data to Planning for the current entity (pbcsEntityName). Cube cube = operation.application.getCube("OEP_FS") DataGridBuilder gridBuilder = cube.dataGridBuilder("MM/DD/YYYY") gridBuilder.addPov('Dec','OEP_Strategic Planning', 'USD', pbcsScenarioName, pbcsEntityName, 'OFS_Direct Input', 'Smart Phone 6 in', 'US Market') gridBuilder.addColumn(pbcsYears as String[]) // Number of items on column. def numDataCols = 2; def rowData = [] smGrid.dataCellIterator().each { // Scale to millions. rowData << it.data * 0.000001 // Get the entire row - 2 data cells. if (rowData.size() == numDataCols) { def pbcsAccountName = smToPbcsAccountNameMap[it.accountName] ?: it.accountName gridBuilder.addRow([pbcsAccountName], rowData) // Reset the data array to pick next row. rowData = [] } } // Build a status object which will be filled in when building the DataGrid object. DataGridBuilder.Status status = new DataGridBuilder.Status() gridBuilder.build(status).withCloseable { DataGrid pbcsGrid -> // Print the number of cells accepted/rejected by the builder to the job console. println("Total number of cells accepted: $status.numAcceptedCells") println("Total number of cells rejected: $status.numRejectedCells") println("First 100 rejected cells: $status.cellsRejected") // Push data to Planning. cube.saveGrid(pbcsGrid) } // Close the Planning data grid (pbcsGrid). } // Close the Strategic Model data grid (smGrid). } // Close each Strategic Model (smModel). } // For each model.
['Retail AC'].each { String smModelName -> operation.application.getStrategicModel(smModelName).withCloseable { model -> // Verify that the data did not get saved for read only cells ['Expected', 'Upside','Downside'].each { String smScenarioName -> DataGridBuilder builder = model.dataGridBuilder(ZERO, PRESERVE_INPUT_VALUES) builder.addPov(smScenarioName) builder.addColumn('Apr06', 'Aug06', 'Apr07') builder.addRow(['v0325:585|south'], [20.00, 11.00, '#Missing']) builder.addRow(['v0325:585|east'], [7.00, 8.00, 9.00]) builder.addRow(['v0325:585|west'], [4.00, 5.00, 12.00]) builder.addRow(['v0325:585|canada'], [9.00, 14.00, '#Missing']) DataGridBuilder.Status status = new DataGridBuilder.Status() DataGrid grid = builder.build( status ) model.saveGrid( grid ) } } }
Modifier and Type | Method and Description |
---|---|
void |
close()
Releases system resources associated with SM.
|
DataGridBuilder |
dataGridBuilder()
Returns a data grid builder for this model.
|
DataGridBuilder |
dataGridBuilder(boolean writeToInputMeasure)
Returns a data grid builder for this model.
|
DataGridBuilder |
dataGridBuilder(boolean writeToInputMeasure,
StrategicModelMissingValueOption missingValueOption,
StrategicModelPreserveValueOption modelInitializationOption)
Returns a data grid builder for this model.
|
DataGridBuilder |
dataGridBuilder(StrategicModelMissingValueOption missingValueOption,
StrategicModelPreserveValueOption modelInitializationOption)
Returns a data grid builder for this model.
|
DataGridDefinitionBuilder |
dataGridDefinitionBuilder()
Returns a grid definition builder.
|
DataGridDefinitionBuilder |
dataGridDefinitionBuilder(boolean ignoreUnknownMembers)
Returns a grid definition builder.
|
DataGridDefinitionBuilder |
dataGridDefinitionBuilder(boolean ignoreUnknownMembers,
boolean readFromInputMeasure)
Returns a grid definition builder.
|
DataGrid |
loadGrid(DataGridDefinition gridDefinition)
Returns a data grid for the specified region.
|
void |
saveGrid(DataGrid grid)
Save the data specified in the grid.
|
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public DataGridBuilder dataGridBuilder()
This builder can be used to build a grid that retrieves metadata for the POV/Row/Column header cells as well as the data cells. In addition, the grid also provides smart iterators to iterate over the data cells for the grid.
public DataGridBuilder dataGridBuilder(boolean writeToInputMeasure)
This builder can be used to build a grid that retrieves metadata for the POV/Row/Column header cells as well as the data cells. In addition, the grid also provides smart iterators to iterate over the data cells for the grid.
writeToInputMeasure
- if true write to the input measurepublic DataGridBuilder dataGridBuilder(boolean writeToInputMeasure, StrategicModelMissingValueOption missingValueOption, StrategicModelPreserveValueOption modelInitializationOption)
This builder can be used to build a grid that retrieves metadata for the POV/Row/Column header cells as well as the data cells. In addition, the grid also provides smart iterators to iterate over the data cells for the grid.
writeToInputMeasure
- if true write to the input measuremissingValueOption
- option to set the #Missing values in the respective target cellsmodelInitializationOption
- option whether to preserve inputs or preserve output cells in the region around the target cellpublic DataGridBuilder dataGridBuilder(StrategicModelMissingValueOption missingValueOption, StrategicModelPreserveValueOption modelInitializationOption)
This builder can be used to build a grid that retrieves metadata for the POV/Row/Column header cells as well as the data cells. In addition, the grid also provides smart iterators to iterate over the data cells for the grid.
missingValueOption
- option to set the #Missing values in the respective target cellsmodelInitializationOption
- option whether to preserve inputs or preserve output cells in the region around the target cellpublic DataGridDefinitionBuilder dataGridDefinitionBuilder()
This builder can be used to build a DataGridDefinition object used to define a region to export data from.
public DataGridDefinitionBuilder dataGridDefinitionBuilder(boolean ignoreUnknownMembers)
This builder can be used to build a DataGridDefinition object used to define a region to export data from. Provides option to ignore unknown members if any.
ignoreUnknownMembers
- ignore unknown members in the gridpublic DataGridDefinitionBuilder dataGridDefinitionBuilder(boolean ignoreUnknownMembers, boolean readFromInputMeasure)
This builder can be used to build a DataGridDefinition object used to define a region to export data from. Provides option to ignore unknown members if any and option to read from the input measure.
ignoreUnknownMembers
- ignore unknown members in the gridreadFromInputMeasure
- if true read from the input measurepublic DataGrid loadGrid(DataGridDefinition gridDefinition) throws java.lang.Exception
This grid can be used to retrieve metadata for the POV/Row/Column header cells as well as the data cells. In addition, the grid also provides smart iterators to iterate over the data cells for the grid.
gridDefinition
- the slice definition for which to export datajava.lang.Exception
- if an unexpected fault occurspublic void saveGrid(DataGrid grid)
grid
- data gridCopyright © 2017, 2024, Oracle and/or its affiliates. All rights reserved.