Consider the example of creating a data loader using the Fore and Fore.NET language. Executing the example requires that the repository contains two cubes with the Cube_1 and Cube_2 identifiers. The cubes have some structure changes based on the same dictionaries.
The following example creates a new object that is Data Loader in the repository root and sets up its parameters:
The source cube and consumer cube are set.
General dimensions are linked, and dimensions, which are only in the source cube, are fixed.
To execute the example, add links to the Cubes, Dimensions, Matrix and Metabase system assemblies. Write the corresponding Imports strings for the Fore.NET example.
Sub CreateCubeLoader;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
CubeDestination: ICubeModelDestination;
CLoader: ICubeLoader;
FixInfo: ICubeLoaderFixInfo;
DimFix: ICubeLoaderDimensionFix;
DimsSource: ICubeModelDimensions;
Dim, Dim1: IDimensionModel;
MapInfo: ICubeLoaderMapInfo;
MapItem: ICubeLoaderMapItem;
i: Integer;
Begin
MB := MetabaseClass.Active;
CrInfo := Mb.CreateCreateInfo;
CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_CUBELOADER;
CrInfo.Id := "New_Cube_Loader";
CrInfo.Name := "Data loader";
CrInfo.Parent := MB.Root;
MObj := Mb.CreateObject(CrInfo).Edit;
CLoader := MObj As ICubeLoader;
//Source cube
CubeDestination := (MB.ItemById("Cube_1").Bind As ICubeModel).Destinations.DefaultDestination;
CLoader.Source := CubeDestination;
//Dimensions of source cube, which will be searched for dimensions of consumer cube for connection
DimsSource := CubeDestination.Dimensions;
//Consumer cube
CubeDestination := (MB.ItemById("Cube_2").Bind As ICubeModel).Destinations.DefaultDestination;
CLoader.Destination := CubeDestination;
//Link similar dimensions
MapInfo := CLoader.MapInfo;
For i := 0 To MapInfo.Count - 1 Do
MapItem := MapInfo.Item(i);
Dim := MapItem.Dimension;
Dim1 := DimsSource.FindById((Dim As IMetabaseObject).Id);
If Dim1 <> Null Then
MapItem.MapDimension := Dim1;
MapItem.MapIndex := Dim1.Indexes.PrimaryIndex;
MapItem.DimIndex := Dim.Indexes.PrimaryIndex;
MapItem.Method := CubeLoaderMapMethod.ByIndex;
End If;
End For;
//Fix the rest of source cube dimensions
FixInfo := CLoader.FixInfo;
For Each DimFix In CLoader.FixInfo Do
DimFix.Operation := BasicAggregatorOperation.Sum;
DimFix.Selection.SelectAll;
End For;
MObj.Save;
End Sub CreateCubeLoader;
Sub CreateCubeLoader(MB: IMetabase);
Var
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
CubeDestination: ICubeModelDestination;
CLoader: ICubeLoader;
FixInfo: ICubeLoaderFixInfo;
DimFix: ICubeLoaderDimensionFix;
DimsSource: ICubeModelDimensions;
Dim, Dim1: IDimensionModel;
MapInfo: ICubeLoaderMapInfo;
MapItem: ICubeLoaderMapItem;
i: Integer;
Begin
CrInfo := Mb.CreateCreateInfo();
CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_CUBELOADER As Integer;
CrInfo.Id := "New_Cube_Loader";
CrInfo.Name := "Data loader";
CrInfo.Parent := MB.Root;
MObj := Mb.CreateObject(CrInfo).Edit();
CLoader := MObj As ICubeLoader;
//Source cube
CubeDestination := (MB.ItemById["Cube_1"].Bind() As ICubeModel).Destinations.DefaultDestination;
CLoader.Source := CubeDestination;
//Dimensions of source cube, which will be searched for dimensions of consumer cube for connection
DimsSource := CubeDestination.Dimensions;
//Consumer cube
CubeDestination := (MB.ItemById["Cube_2"].Bind() As ICubeModel).Destinations.DefaultDestination;
CLoader.Destination := CubeDestination;
//Link dimensions
MapInfo := CLoader.MapInfo;
For i := 0 To MapInfo.Count - 1 Do
MapItem := MapInfo.Item[i];
Dim := MapItem.Dimension;
Dim1 := DimsSource.FindById((Dim As IMetabaseObject).Id);
If Dim1 <> Null Then
MapItem.MapDimension := Dim1;
MapItem.MapIndex := Dim1.Indexes.PrimaryIndex;
MapItem.DimIndex := Dim.Indexes.PrimaryIndex;
MapItem.Method := CubeLoaderMapMethod.lmmByIndex;
End If;
End For;
//Fix dimensions
FixInfo := CLoader.FixInfo;
For Each DimFix In CLoader.FixInfo Do
DimFix.Operation := BasicAggregatorOperation.baoSum;
DimFix.Selection.SelectAll();
End For;
MObj.Save();
End Sub;
See also: