DimOpenParams: IMsDimOpenParamValue;
DimOpenParams: Prognoz.Platform.Interop.Ms.IMsDimOpenParamValue;
The DimOpenParams property determines the value of the parameter, with which the dimension is opened, by which the selection for calculation of the cycle is set.
To set the selection used to calculate the cycle, use the IMsCalculationChainIterator.Selection property.
Executing the example requires that repository contains:
A modeling container with the MS_PARAM identifier, containing a metamodel with the META_MODEL identifier.
A dictionary with the DICT_PARAM identifier, containing real parameter with the COUNTRY_PARAM identifier.
A standard cube with the CUBE_PARAM identifier, containing parameter with the COUNTRY identifier and a dimension based on the DICT_PARAM dictionary. The COUNTRY parameter controls the COUNTRY_PARAM parameter.
Add links to the Ms, Metabase, Dimensions, Cubes, Dal system assemblies.
Sub UserProc;
Var
mb: IMetabase;
msKey, cubeKey: Integer;
metaModel: IMsMetaModel;
stubParamValue: IMsDimOpenStubParamValue;
dimOpenParamValue: IMsDimOpenParamValue;
openParams: IMetabaseObjectParamValues;
dimInstance: IDimInstance;
iteratorSelection: IDimSelection;
iterator: IMsCalculationChainIterator;
param: IMsModelParam;
dDescr: IMetabaseObjectDescriptor;
Begin
mb := MetabaseClass.Active;
// Get metamodel
msKey := mb.ItemById("MS_PARAM").Key;
metaModel := mb.ItemByIdNamespace("META_MODEL", msKey).Edit As IMsMetaModel;
// Clear the calculation chain of the metamodel
metaModel.CalculationChain.Clear;
// Clear the values of parameters of dimensions used for calculation of the metamodel
metaModel.DimOpenStubParamValues.Clear;
// Clear parameters of the metamodel
metaModel.Params.Clear;
// Create new parameter referring to the DICT_PARAM dictionary param := metaModel.Params.Add;
param.DataType := DbDataType.Integer;
param.LinkedObject := mb.ItemById("DICT_PARAM");
param.DefaultValue := Null;
param.Hidden := True;
{ Create new value of the parameter to change the data source,
used for calculating the metamodel}
cubeKey := mb.ItemById("CUBE_PARAM").Key;
stubParamValue := metaModel.DimOpenStubParamValues.Add(cubeKey);
stubParamValue.StubValues := mb.Item(cubeKey).Bind.ParamValues;
// Add the value of the dimension parameter used to calculate the metamodel
dDescr := mb.ItemById("DICT_PARAM");
dimOpenParamValue := stubParamValue.Values.add(dDescr.Bind As IDimensionModel);
// Set the value for the parameters of the DICT_PARAM dictionary
dimOpenParamValue.Values.FindById("COUNTRY_PARAM").Value := 17724;
// Set the value for the parameter of the data source
stubParamValue.StubValues.FindById("COUNTRY").Value := 17724;
// Get the selection of the dimension considering the value of the parameter
openParams := dDescr.Bind.ParamValues;
openParams.FindById("COUNTRY_PARAM").Value := 17724;
dimInstance := dDescr.Open(openParams) As IDimInstance;
iteratorSelection := dimInstance.CreateSelection;
iteratorSelection.SelectAll;
// Create metamodel cycle
iterator := metaModel.CalculationChain.AddIterator("Cycle 'Dictionary with parameter'");
// Set selection
iterator.Selection := iteratorSelection;
// Set the parameter
iterator.Parameter := param;
// Pass the parameter for opening the dimension by which the selection is performed to the cycle
iterator.DimOpenParams := dimOpenParamValue;
// Save metamodel
(metaModel As IMetabaseObject).Save;
End Sub UserProc;
Example execution result: in the META_MODEL metamodel the cycle is created, and the value of the parameter, with which the dimension is opened, by which the selection is specified for cycle calculation, is set.
Requirements and result of execution of Fore.NET example are the same as Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
msKey, cubeKey: uinteger;
metaModel: IMsMetaModel;
stubParamValue: IMsDimOpenStubParamValue;
dimOpenParamValue: IMsDimOpenParamValue;
openParams: IMetabaseObjectParamValues;
dimInstance: IDimInstance;
iteratorSelection: IDimSelection;
iterator: IMsCalculationChainIterator;
param: IMsModelParam;
dDescr: IMetabaseObjectDescriptor;
Begin
mb := Params.Metabase;
// Get metamodel
msKey := mb.ItemById["MS_PARAM"].Key;
metaModel := mb.ItemByIdNamespace["META_MODEL", msKey].Edit() As IMsMetaModel;
// Clear the calculation chain of the metamodel
metaModel.CalculationChain.Clear();
// Clear the values of parameters of dimensions used for calculation of the metamodel
metaModel.DimOpenStubParamValues.Clear();
// Clear parameters of the metamodel
metaModel.Params.Clear();
// Create new parameter referring to the DICT_PARAM dictionary param := metaModel.Params.Add();
param.DataType := DbDataType.ddtInteger;
param.LinkedObject := mb.ItemById["DICT_PARAM"];
param.DefaultValue := Null;
param.Hidden := True;
{ Create new value of the parameter to change the data source,
used for calculating the metamodel}
cubeKey := mb.ItemById["CUBE_PARAM"].Key;
stubParamValue := metaModel.DimOpenStubParamValues.Add(cubeKey);
stubParamValue.StubValues := mb.Item[cubeKey].Bind().ParamValues;
// Add the value of the dimension parameter used to calculate the metamodel
dDescr := mb.ItemById["DICT_PARAM"];
dimOpenParamValue := stubParamValue.Values.add(dDescr.Bind() As IDimensionModel);
// Set the value for the parameters of the DICT_PARAM dictionary
dimOpenParamValue.Values.FindById("COUNTRY_PARAM").Value := 17724;
// Set the value for the parameter of the data source
stubParamValue.StubValues.FindById("COUNTRY").Value := 17724;
// Get the selection of the dimension considering the value of the parameter
openParams := dDescr.Bind().ParamValues;
openParams.FindById("COUNTRY_PARAM").Value := 17724;
dimInstance := dDescr.Open(openParams) As IDimInstance;
iteratorSelection := dimInstance.CreateSelection();
iteratorSelection.SelectAll();
// Create metamodel cycle
iterator := metaModel.CalculationChain.AddIterator("Cycle 'Dictionary with parameter'");
// Set selection
iterator.Selection := iteratorSelection;
// Set the parameter
iterator.Parameter := param;
// Pass the parameter for opening the dimension by which the selection is performed to the cycle
iterator.DimOpenParams := dimOpenParamValue;
// Save metamodel
(metaModel As IMetabaseObject).Save();
End Sub;
See also: