ControllingParam: IMsModelParam;
The ControllingParam property determines the controlled parameter.
Executing the example requires that the repository contains a time series database with the TSDB identifier. The database modeling container contains two metamodels with the META_MODEL and META_MODEL_CONTROLLED identifiers.
Add links to the Cubes, Dal, Metabase, Ms system assemblies.
Sub UserParam;
Var
mb: IMetabase;
Catalog: IRubricator;
Transforms: IMetabaseObjectDescriptor;
MetaModel_1, MetaModel_2: IMsMetaModel;
MMParams: IMsModelParams;
pMetaModelParam1, pMetaModelParam2: IMsModelParam;
MainChainEntries: IMsCalculationChainEntries;
pChain: IMsCalculationChainMetaModel;
ParamsControl: IMsModelParamsControl;
pControl: IMsModelParamControl;
ControlledParam: IMsModelParam;
Begin
mb := MetabaseClass.Active;
Catalog := mb.ItemById("TSDB").Bind As IRubricator;
Transforms := Catalog.ModelSpace;
// Get the first metamodel and create a parameter for it
MetaModel_1 := mb.ItemByIdNamespace("META_MODEL", Transforms.Key).Edit As IMsMetaModel;
MMParams := MetaModel_1.Params;
MMParams.Clear;
pMetaModelParam1 := MMParams.Add;
pMetaModelParam1.Name := "Main param";
pMetaModelParam1.Id := "Main_Param";
pMetaModelParam1.Hidden := True;
pMetaModelParam1.DataType := DbDataType.Float;
pMetaModelParam1.DefaultValue := 0.36;
MainChainEntries := MetaModel_1.CalculationChain;
MainChainEntries.Clear;
// Get the second metamodel and create a parameter for it
MetaModel_2 := mb.ItemByIdNamespace("META_MODEL_CONTROLLED", Transforms.Key).Edit As IMsMetaModel;
MMParams := MetaModel_2.Params;
MMParams.Clear;
pMetaModelParam2 := MMParams.Add;
pMetaModelParam2.Name := "Controlled param";
pMetaModelParam2.Id := "Controlled_param";
pMetaModelParam2.Hidden := True;
pMetaModelParam2.DataType := DbDataType.Integer;
pMetaModelParam2.DefaultValue := 1;
(MetaModel_2 As IMetabaseObject).Save;
// Include the second metamodel to calculation chain of the first metamodel and set controlling parameter
pChain := MainChainEntries.AddMetaModel(MetaModel_2);
ParamsControl := pChain.ParamsControl;
pControl := ParamsControl.Item(0);
pControl.ControllingParam := pMetaModelParam1;
pControl.Value := 4;
(MetaModel_1 As IMetabaseObject).Save;
ControlledParam := pControl.ControlledParam;
If (ControlledParam.DataType = DbDataType.Integer)
And (ControlledParam.DefaultValue = 1) Then
Debug.WriteLine(Parameter is set successfully);
End If;
End Sub UserParam;
After executing the example the parameters are determined for metamodels. The META_MODEL_CONTROLLED metamodel is included in the calculation chain of the META_MODEL metamodel. The parameter of the META_MODEL_CONTROLLED metamodel is set as a controlled parameter of calculation chain, the value is determined for it. The result of controlled parameter creation is displayed in the console window.
See also: