Creating a Virtual Cube

Consider the example of creating a virtual cube with the use of the Fore language. Executing the example requires that the repository contains two cubes with the Cube_1 and Cube_2 identifiers. Each cube is built in its own fact dimension with the FACTS1 and FACTS2 identifiers respectively.

The following example creates a new object that is Virtual Cube in the repository root and sets up its parameters, fact dimensions are registered.

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

Example

Sub CreateViewCube;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    VCube: IVirtualCube;
    VCubeSources: IVirtualCubeSources;
    CubeModel: ICubeModel;
    CubeDest: ICubeModelDestination;
    VSource1, VSource2: IVirtualCubeSource;
    FixInfo: ICubeDimensionFixInfo;
    Fix: ICubeDimensionFix;
Begin
    MB := MetabaseClass.Active;
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_VIRTUALCUBE;
    CrInfo.Id := "New_Virt_Cube";
    CrInfo.Name := New virtual cube;
    CrInfo.Parent := MB.Root;
    MObj := MB.CreateObject(CrInfo).Edit;
    VCube := MObj As IVirtualCube;
    VCubeSources := VCube.Sources;
    //Add the first cube to data sources
    CubeModel := Mb.ItemById("Cube_1").Bind As ICubeModel;
    CubeDest := CubeModel.Destinations.DefaultDestination;
    VSource1 := VCubeSources.Add(CubeDest);
    //Add the second cube to data sources
    CubeModel := Mb.ItemById("Cube_2").Bind As ICubeModel;
    CubeDest := CubeModel.Destinations.DefaultDestination;
    VSource2 := VCubeSources.Add(CubeDest);
    //Fix elements in fact dimensions of source cubes
    FixInfo := VSource1.FixInfo;
    For Each Fix In FixInfo Do
        If ((Fix.Dimension As IMetabaseObject).Id = "FACTS1"Then
            Fix.Fixed := True;
            Fix.Selection.SelectAll;
        End If;
    End For;
    FixInfo := VSource2.FixInfo;
    For Each Fix In FixInfo Do
        If ((Fix.Dimension As IMetabaseObject).Id = "FACTS2"Then
            Fix.Fixed := True;
            Fix.Selection.SelectAll;
        End If;
    End For;
    MObj.Save;
End Sub CreateViewCube;

See also:

Examples