See below examples of using a table MDM dictionary as a standard cube dimension in the Fore and Fore.NET languages.
Executing the example requires an MDM repository with the RDS_REPO identifier, a database with the DB identifier and a standard cube with the CUBE identifier.
Result of examples execution: a table MDM dictionary that contains unique key is created in the RDS_REPO repository. Then this dictionary is added as a dimension to the CUBE standard cube. Binding is executed by a primary index of the first block of dimension.
Add links to the Metabase, Cubes, Rds, Dimensions, Db system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
Inf: IMetabaseObjectCreateInfo;
Des: IMetabaseObjectDescriptor;
RdsDict: IRdsDictionary;
UniqKey: IRdsUniqueKey;
Cube: IStandardCube;
CubeDims: IStandardCubeDimensions;
Dim: IDimensionModel;
StdDim: IStandardCubeDimension;
i: Integer;
StDataset: IStandardCubeDataset;
StDimBind: IStandardCubeDimensionBinding;
Index: IDimIndex;
Attr: IDimAttribute;
Field: IDatasetModelField;
Dataset: IDatasetModel;
Begin
Mb := MetabaseClass.Active;
// Creating table MDM dictionary.
Inf := Mb.CreateCreateInfo;
Inf.ClassId := MetabaseObjectClass.KE_CLASS_METADICTIONARYRDS;
Inf.Name := Inf.DefaultName;
Inf.Parent := Mb.ItemById("RDS_REPO");
Inf.KeepEdit := True;
Des := Mb.CreateObject(Inf);
RdsDict := Des As IRdsDictionary;
RdsDict.Database := Mb.ItemById("DB").Bind As IDatabase;
// Create dictionary unique key
UniqKey := RdsDict.UniqueKeys.Add;
UniqKey.Id := "UniqKey_1";
UniqKey.Name := Unique key;
UniqKey.Contains(RdsDict.Attributes.Key) := True;
(RdsDict As IMetabaseObject).Save;
// Set this dictionary as a standard cube dimension.
// Binding by primary indexes.
Cube := Mb.ItemById("CUBE").Edit As IStandardCube;
CubeDims := Cube.Dimensions;
Dim := Des As IDimensionModel;
StdDim := CubeDims.Add(Dim);
Index := Dim.Indexes.PrimaryIndex;
Attr := Index.Attributes.Item(0);
For i := 0 To Cube.Datasets.Count - 1 Do
StDataset := Cube.Datasets.Item(i);
StDimBind := StdDim.Binding(StDataset);
Index := Dim.Indexes.PrimaryIndex;
StDimBind.Index := Index;
Dataset := StDataset.Dataset;
Field := Dataset.Fields.Item(0);
StDimBind.Binding(Attr).AsString := (Dataset As IMetabaseObject).Id + "." + Field.Id;
End For;
(Cube As IMetabaseObject).Save;
End Sub UserProc;
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Db;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Rds;
…
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
Inf: IMetabaseObjectCreateInfo;
Des: IMetabaseObjectDescriptor;
RdsDict: IRdsDictionary;
UniqKey: IRdsUniqueKey;
Cube: IStandardCube;
CubeDims: IStandardCubeDimensions;
Dim: IDimensionModel;
StdDim: IStandardCubeDimension;
i: Integer;
StDataset: IStandardCubeDataset;
StDimBind: IStandardCubeDimensionBinding;
Index: IDimIndex;
Attr: IDimAttribute;
Field: IDatasetModelField;
Dataset: IDatasetModel;
Begin
Mb := Params.Metabase;
// Creating table MDM dictionary.
Inf := Mb.CreateCreateInfo();
Inf.ClassId := MetabaseObjectClass.KE_CLASS_METADICTIONARYRDS As integer;
Inf.Name := Inf.DefaultName;
Inf.Parent := Mb.ItemById["RDS_REPO"];
Inf.KeepEdit := True;
Des := Mb.CreateObject(Inf);
RdsDict := Des As IRdsDictionary;
RdsDict.Database := Mb.ItemById["DB"].Bind() As IDatabase;
// Create dictionary unique key
UniqKey := RdsDict.UniqueKeys.Add();
UniqKey.Id := "UniqKey_1";
UniqKey.Name := Unique key;
UniqKey.Contains[RdsDict.Attributes.Key] := True;
(RdsDict As IMetabaseObject).Save();
// Set this dictionary as a standard cube dimension.
// Binding by user indexes.
Cube := Mb.ItemById["CUBE"].Edit() As IStandardCube;
CubeDims := Cube.Dimensions;
Dim := Des As IDimensionModel;
StdDim := CubeDims.Add(Dim);
Index := Dim.Indexes.PrimaryIndex;
Attr := Index.Attributes.Item[0];
For i := 0 To Cube.Datasets.Count - 1 Do
StDataset := Cube.Datasets.Item[i];
StDimBind := StdDim.Binding[StDataset];
StDimBind.Index := Index;
Dataset := StDataset.Dataset;
Field := Dataset.Fields.Item[0];
StDimBind.Binding[Attr].AsString := (Dataset As IMetabaseObject).Id + "." + Field.Id;
End For;
(Cube As IMetabaseObject).Save();
End Sub;
See also: