Creating a Data Loader

Consider the exmaple of creating a data loader with the use of the Fore language. Executing the example requires that the repository contains two cubes with the 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:

To execute the examples, add links to the Cubes, Dimensions, Matrix, and Metabase system assemblies.

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;

See also:

Examples