LinkedObject: IMetabaseObjectDescriptor;
LinkedObject: Prognoz.Platform.Interop.Metabase.IMetabaseObjectDescriptor;
The LinkedObject property determines dictionary used to determine parameter value.
To determine parameter type, use the ITsModelParam.ParamType property.
Executing the example requires that the repository contains a time series database with the TSDB identifier containing mandatory series attribute with the CITY identifier. This attribute is a reference to the dictionary. Internal modeling container of time series database must contain a metamodel with the METAMODEL identifier. This metamodel must contain only a model based on attributes of the TSDB time series database in the calculation chain.
Add links to the Cubes, Dal, Dimensions, Metabase, Ms, Rds, Transfrom system assemblies.
Sub MetaModelParams;
Var
mb: IMetabase;
TSDB: IRubricator;
Ms: IMetabaseObjectDescriptor;
MetaModel: IMsMetaModel;
Params: ITsModelParams;
Param: ITsModelParam;
Atts: IMetaAttributes;
Dict: IMetabaseObjectDescriptor;
DimInst: IDimInstance;
Model: IMsModel;
Slices: IMsFormulaTransformSlices;
ParamDim: IMsParametrizedDimension;
Begin
mb := MetabaseClass.Active;
// Get time series database
TSDB := mb.ItemById("TSDB").Bind As IRubricator;
// Get time series attributes
Atts := TSDB.Facts.Attributes;
// Get dictionary that determines values of the CITY attribute
Dict := Atts.FindById("CITY").ValuesObject;
DimInst := Dict.Open(Null) As IDimInstance;
// Get internal modeling container
Ms := TSDB.ModelSpace;
// Get metamodel
MetaModel := mb.ItemByIdNamespace("METAMODEL", Ms.Key).Edit As IMsMetaModel;
// Get collection of metamodel parameters
Params := MetaModel.Params As ITsModelParams;
// Clear collection
Params.Clear;
// Add parameter
Param := Params.Add;
// Define parameter settings
Param.Name := "City";
Param.Id := "CITY_PARAM";
Param.Hidden := False;
Param.DataType := DbDataType.Integer;
// Set the dictionary values of which are used as parameter values
Param.LinkedObject := Dict;
// Set default value
Param.DefaultValue := DimInst.Elements.Elements.Element(0);
// Specify dictionary attribute that will be used for restoring selection
Param.SelectionAttrID := "KEY";
// Save metamodel
(MetaModel As IMetabaseObject).Save;
// Get first model in metamodel calculation chain
Model := (MetaModel.CalculationChain.Item(0) As IMsCalculationChainModel).EditModel;
// Get output variable slice
Slices := Model.Transform.Outputs.Item(0).Slices;
// Set attribute parameter that determines values of the CITY attribute
ParamDim := Slices.Item(0).ParametrizedDimensions.FindById(Dict.Id);
ParamDim.Parameter := Param As IMsModelParam;
// Save model changes
(Model As IMetabaseObject).Save;
End Sub MetaModelParams;
After executing the example the parameter is added to the METAMODEL metamodel, values of this parameter are determined by elements of the dictionary used by the CITY series attribute. The parameter has the default value. This parameter will be used in the model contained in the METAMODEL metamodel, to set value of the CITY attribute of the output variable.
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.Dal;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Rds;
Imports Prognoz.Platform.Interop.Transform;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
TSDB: IRubricator;
Ms: IMetabaseObjectDescriptor;
MetaModel: IMsMetaModel;
MParams: ITsModelParams;
Param: ITsModelParam;
Atts: IMetaAttributes;
Dict: IMetabaseObjectDescriptor;
DimInst: IDimInstance;
Model: IMsModel;
Slices: IMsFormulaTransformSlices;
ParamDim: IMsParametrizedDimension;
Begin
mb := Params.Metabase;
// Get time series database
TSDB := mb.ItemById["TSDB"].Bind() As IRubricator;
// Get time series attributes
Atts := TSDB.Facts.Attributes;
// Get dictionary that determines values of the CITY attribute
Dict := Atts.FindById("CITY").ValuesObject;
DimInst := Dict.Open(Null) As IDimInstance;
// Get internal modeling container
Ms := TSDB.ModelSpace;
// Get metamodel
MetaModel := mb.ItemByIdNamespace["METAMODEL", Ms.Key].Edit() As IMsMetaModel;
// Get collection of metamodel parameters
MParams := MetaModel.Params As ITsModelParams;
// Clear collection
MParams.Clear();
// Add parameter
Param := MParams.Add();
// Define parameter settings
Param.Name := "City";
Param.Id := "CITY_PARAM";
Param.Hidden := False;
Param.DataType := DbDataType.ddtInteger;
// Set the dictionary values of which are used as parameter values
Param.LinkedObject := Dict;
// Set default value
Param.DefaultValue := DimInst.Elements.Elements.Element[0];
// Specify dictionary attribute that will be used for restoring selection
Param.SelectionAttrID := "KEY";
// Save metamodel
(MetaModel As IMetabaseObject).Save();
// Get first model in metamodel calculation chain
Model := (MetaModel.CalculationChain.Item[0] As IMsCalculationChainModel).EditModel;
// Get output variable slice
Slices := Model.Transform.Outputs.Item[0].Slices;
// Set attribute parameter that determines values of the CITY attribute
ParamDim := Slices.Item[0].ParametrizedDimensions.FindById(Dict.Id);
ParamDim.Parameter := Param As IMsModelParam;
// Save model changes
(Model As IMetabaseObject).Save();
End Sub;
See also: