RefreshAttributesStructure;
RefreshAttributesStructure();
The RefreshAttributesStructure method refreshes the structure of attributes of the model.
The method is relevant if the model is based on attributes.
Executing the example requires a time series database with the TSDB identifier, containing the model of the determinate equation with the MODEL_ATTR identifier in the internal modeling container.
To execute the example, add links to the Cubes, Metabase, Ms system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
RubrDescr: IMetabaseObjectDescriptor;
Rubr: IRubricator;
MsDescr: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
TransformVarables: IMsFormulaTransformVariables;
Coord: IMsFormulaTransformCoord;
Calc: IMsMethodCalculation;
Period: IMsModelPeriod;
Formula: IMsFormula;
Begin
// Get time series database
Mb := MetabaseClass.Active;
RubrDescr := Mb.ItemById("TSDB");
Rubr := RubrDescr.Bind As IRubricator;
// Get the internal modeling container
MsDescr := Rubr.ModelSpace;
// Get the model
Model := Mb.ItemByIdNamespace("MODEL_ATTR", MsDescr.Key).Edit As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Set the parameters for calculation of the model
TransformVarables := Transform.Outputs;
Coord := Transform.CreateCoord(TransformVarables.Item(0));
Calc := Transform.CreateCalculation;
Period := Calc.Period;
Period.IdentificationStartDate := Model.Period.IdentificationStartDate;
Period.IdentificationEndDate := Model.Period.IdentificationEndDate;
Period.ForecastStartDate := Model.Period.ForecastStartDate;
Period.ForecastEndDate := Model.Period.ForecastEndDate;
Calc.CurrentPoint := Model.Period.IdentificationStartDate;
// Update structure of attributes of the model
Transform.RefreshAttributesStructure;
// Perform calculation of the model
Formula := Transform.FormulaItem(0);
(Formula.Method As IMsDeterministicTransform).Execute(Calc, Coord);
// Save changes
(Model As IMetabaseObject).Save;
End Sub UserProc;
Example execution result: the structure of attributes of the MODEL_ATTR model is updated, the model is calculated.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
RubrDescr: IMetabaseObjectDescriptor;
Rubr: IRubricator;
MsDescr: IMetabaseObjectDescriptor;
Model: IMsModel;
Transform: IMsFormulaTransform;
TransformVarables: IMsFormulaTransformVariables;
Coord: IMsFormulaTransformCoord;
Calc: IMsMethodCalculation;
Period: IMsModelPeriod;
Formula: IMsFormula;
Begin
// Get time series database
Mb := Params.Metabase;
RubrDescr := Mb.ItemById["TSDB"];
Rubr := RubrDescr.Bind() As IRubricator;
// Get the internal modeling container
MsDescr := Rubr.ModelSpace;
// Get the model
Model := Mb.ItemByIdNamespace["Model_ATTR", MsDescr.Key].Edit() As IMsModel;
// Get model parameters
Transform := Model.Transform;
// Set the parameters for calculation of the model
TransformVarables := Transform.Outputs;
Coord := Transform.CreateCoord(TransformVarables.Item[0]);
Calc := Transform.CreateCalculation();
Period := Calc.Period;
Period.IdentificationStartDate := Model.Period.IdentificationStartDate;
Period.IdentificationEndDate := Model.Period.IdentificationEndDate;
Period.ForecastStartDate := Model.Period.ForecastStartDate;
Period.ForecastEndDate := Model.Period.ForecastEndDate;
Calc.CurrentPoint := Model.Period.IdentificationStartDate;
// Update structure of attributes of the model
Transform.RefreshAttributesStructure();
// Perform calculation of the model
Formula := Transform.FormulaItem[0];
(Formula.Method As IMsDeterministicTransform).Execute(Calc, Coord);
// Save changes
(Model As IMetabaseObject).Save();
End Sub;
See also: