Creating a Cube View

Consider the example of creating a virtual cube using the Fore and Fore.NET language. Creating a cube view requires that the repository contains another cube with the Cube_1 identifier. This cube must have a dimension with the CALENDAR identifier in its structure.

The following example creates a new object that is Cube View in the repository root and sets up its parameters:

To execute the example, add links to the Cubes, Dimensions, Matrix, Metabase system assemblies. For Fore.NET example write corresponding Imports strings too.

Fore Example

Sub CreateViewCube;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    ViewCube: ICubeView;
    SourceCube: ICubeModel;
    FixInfo: ICubeDimensionFixInfo;
    DimFix: ICubeDimensionFix;
Begin
    MB := MetabaseClass.Active;
    //Information for creating a new repository object
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_CUBEVIEW;
    CrInfo.Id := "New_View_Cube";
    CrInfo.Name := "New cube view";
    CrInfo.Parent := MB.Root;
    //Set up cube parameters
    MObj := MB.CreateObject(CrInfo).Edit;
    ViewCube := MObj As ICubeView;
    //Specify source cube
    SourceCube := MB.ItemById("CUBE_1").Bind As ICubeModel;
    ViewCube.Cube := SourceCube.Destinations.DefaultDestination;
    //Fix dimension
    FixInfo := ViewCube.FixInfo;
    DimFix := FixInfo.ItemByDim(ViewCube.Cube.Dimensions.FindById("CALENDAR"));
    DimFix.Fixed := True;
    //Specify method for aggregation of values by fixed elements
    DimFix.Operation := BasicAggregatorOperation.Sum;
    //Select the whole level, on which the first element is located
    DimFix.Selection.SelectSiblings(0);
    //Save cube
    MObj.Save;
End Sub CreateViewCube;

Fore.NET Example

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Matrix;
Imports Prognoz.Platform.Interop.Metabase;

Sub CreateViewCube(MB: IMetabase);
Var
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    ViewCube: ICubeView;
    SourceCube: ICubeModel;
    FixInfo: ICubeDimensionFixInfo;
    DimFix: ICubeDimensionFix;
Begin
    //Information for creating a new repository object
    CrInfo := MB.CreateCreateInfo();
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_CUBEVIEW As Integer;
    CrInfo.Id := "New_View_Cube";
    CrInfo.Name := "New cube view";
    CrInfo.Parent := MB.Root;
    //Set up cube parameters
    MObj := MB.CreateObject(CrInfo).Edit();
    ViewCube := MObj As ICubeView;
    //Specify source cube
    SourceCube := MB.ItemById["CUBE_1"].Bind() As ICubeModel;
    ViewCube.Cube := SourceCube.Destinations.DefaultDestination;
    //Fix dimension
    FixInfo := ViewCube.FixInfo;
    DimFix := FixInfo.ItemByDim[ViewCube.Cube.Dimensions.FindById("CALENDAR")];
    DimFix.Fixed := True;
    //Specify method for aggregation of values by fixed items
    DimFix.Operation := BasicAggregatorOperation.baoSum;
    //Select the whole level, on which the first element is located
    DimFix.Selection.SelectSiblings(0);
    //Save cube
    MObj.Save();
End Sub;

See also:

Examples