Working with ADOMD Cubes and Dictionaries

ADOMD cubes and dictionaries are child objects of ADOMD catalog, therefore they can be called from the application code by the key or using the ItemByIdNamespace property. To get opened instances of objects, as it is used in working with repository objects, use the Open or OpenWithParam methods.

ADOMD Cubes

ADOMD cube structure supports the ICubeModel interface. To be compatible with various Foresight Analytics Platform tools, the ICubeInstance interface is also supported. To do this, use the CubeInstance property of the ADOMD cube open instance. After getting the instance, described by the ICubeInstance interface, the matrix with factual data can be obtained, or other actions can be done.

See below an example of creating express report based on ADOMD cube:

Sub CreateExpress;
Var
    MB: IMetabase;
    CreateInfo: IMetabaseObjectCreateInfo;
    Express: IEaxAnalyzer;
    CubeAdoMd: IAdoMdCubeInstance;
Begin
    MB := MetabaseClass.Active;
    //Information to create ADOMD catalog
    CreateInfo := MB.CreateCreateInfo;
    CreateInfo.Id := MB.GenerateId("ADOMDExpressReport");
    CreateInfo.ClassId := MetabaseObjectClass.KE_CLASS_EXPRESSREPORT;
    CreateInfo.Parent := MB.ItemById("F_ADOMD");
    //Create express report
    Express := MB.CreateObject(CreateInfo).Edit As IEaxAnalyzer;
    //Get ADOMD cube open instance
    CubeAdoMd := MB.ItemByIdNamespace("TEST", MB.GetObjectKeyById("MAS_TEST")).Open(NullAs IAdoMdCubeInstance;
    //Set cube as a data source for express report
    Express.OpenCube(CubeAdoMd.CubeInstance);
    (Express As IMetabaseObject).Save;
End Sub CreateExpress;

On executing the example, a new express report based on the selected ADOMD cube is created. After the express report is opened, the cube executes all necessary actions to extract data, which is displayed in the express report.

ADOMD Dictionaries

ADOMD dictionary structure supports the IDimensionModel interface. To be compatible with various Foresight Analytics Platform tools, the IDimInstance interface is also supported. To do this, use the DimensionInstance property of the ADOMD dictionary open instance. After getting the instance, described by the IDimInstance interface, it is possible to work with dimension elements or make other actions.

See below an example of how to use ADOMD dictionary on the form and to display its elements in the DimensionTree component:

Executing the example requires a form and the UiDimension component named UiDimension1 and the DimensionTree component named DimensionTree1 on the form. Set an event handler of the OnCreate event for the form having the following code:

Class TESTForm: Form
    UiDimension1: UiDimension;
    DimensionTree1: DimensionTree;

    Sub TESTFormOnCreate(Sender: Object; Args: IEventArgs);
    Var
        MB: IMetabase;
        ADOMDDim: IAdoMdDimensionInstance;
        DimInst: IDimInstance;
    Begin
        MB := MetabaseClass.Active;
        ADOMDDim := MB.ItemByIdNamespace("TESTDIM", MB.GetObjectKeyById("MAS_TEST")).Open(NullAs IAdoMdDimensionInstance;
        UiDimension1.Active := False;
        UiDimension1.Instance := ADOMDDim.DimensionInstance;
        DimensionTree1.Dimension := UiDimension1;
    End Sub TESTFormOnCreate;

End Class TESTForm;

When the form is started, an open instance of the ADOMD dictionary is obtained. The instance is loaded to the UiDimension1 component, which is set as a data source for DimensionTree1.

ADOMD dictionaries can be used not only to work with ADOMD cubes. They can also be used by other repository objects: for example, ADOMD dictionaries can be used to build a standard cube, or ADOMD dictionary can serve as a control in regular reports.

See also:

About the AdoMd Assembly