Creating an Automatic Cube

Consider the example of creating an automatic cube using the Fore and Fore.NET language. To create a cube, the following objects must be in the repository:

  1. A database with the DB identifier.

  2. A facts dictionary with the FACTS identifier.

  3. A countries dictionary with the COUNTRY identifier.

  4. A calendar dictionary with the CALENDAR identifier.

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

To execute examples, add links to the Cubes, Db, Dimensions and Metabase system assemblies. Write the corresponding Imports strings for the Fore.NET example.

Fore Example

Sub CreateAutoCube;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    AutoCube: IAutoCube;
    Dims: IAutoCubeDimensions;
Begin
    MB := MetabaseClass.Active;
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_AUTOCUBE;
    CrInfo.Id := "New_Auto_Cube";
    CrInfo.Name := "New automatic cube";
    CrInfo.Parent := MB.Root;
    MObj := MB.CreateObject(CrInfo).Edit;
    AutoCube := MObj As IAutoCube;
    //Specify the database, which stores cube data
    AutoCube.Database := MB.ItemById("DB").Bind As IDatabase;
    //Set list of cube dimensions
    Dims := AutoCube.Dimensions;
    Dims.Add(MB.ItemById("FACTS").Bind As IDimensionModel);
    Dims.Add(MB.ItemById("COUNTRY").Bind As IDimensionModel);
    Dims.Add(MB.ItemById("CALENDAR").Bind As IDimensionModel);
    MObj.Save;
End Sub CreateAutoCube;

Fore.NET Example

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

Sub CreateAutoCube(MB: IMetabase);
Var
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    AutoCube: IAutoCube;
    Dims: IAutoCubeDimensions;
Begin
    CrInfo := MB.CreateCreateInfo();
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_AUTOCUBE As Integer;
    CrInfo.Id := "New_Auto_Cube";
    CrInfo.Name := "New automatic cube";
    CrInfo.Parent := MB.Root;
    MObj := MB.CreateObject(CrInfo).Edit();
    AutoCube := MObj As IAutoCube;
    //Specify the database, which stores cube data
    AutoCube.Database := MB.ItemById["DB"].Bind() As IDatabase;
    //Set list of cube dimensions
    Dims := AutoCube.Dimensions;
    Dims.Add(MB.ItemById["FACTS"].Bind() As IDimensionModel);
    Dims.Add(MB.ItemById["COUNTRY"].Bind() As IDimensionModel);
    Dims.Add(MB.ItemById["CALENDAR"].Bind() As IDimensionModel);
    MObj.Save();
End Sub;

See also:

Examples