IDimensionModel.IsCalendar

Syntax

IsCalendar: Boolean;

Description

The IsCalendar property determines whether dictionary is used as a calendar one.

Comments

In order the dictionary can be used as a calendar one, its structure should have attributes that execute functions of the following calendar attributes:

Attribute identifiers may differ, comparison is executed in the IDimAsCalendar.Attrs collection.

One should also create a primary index with the following order of mandatory attributes: the first attribute - BLOCK_TYPE, the second attribute - START_DATE, and also NAME, ID, and ORDER. This index should be the first one in the list of dictionary indexes.

Example

Executing the example requires that the repository contains an MDM dictionary with the CUSTOM_CALENDAR identifier. Dictionary structure, along with system attributes, also has attributes with the identifiers: CUSTOM_BLOCK_TYPE, CUSTOM_START_DATE, CUSTOM_ID. Data types of these attributes correspond to data types of calendar dictionary attributes. Dictionary structure also contains two levels.

Add links to the Metabase and Dimensions system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Dim: IDimensionModel;
    DimAttrs: IDimAttributes;
    Levels: IDimLevels;
    DimAsCln: IDimAsCalendar;
    ClnAttrs: IDimAsCalendarAttrs;
    ClnLevels: IDimAsCalendarLevels;
    AttrId: String;
    c, i: Integer;
Begin
    MB := MetabaseClass.Active;
    Dim := MB.ItemById("CUSTOM_CALENDAR").Edit As IDimensionModel;
    DimAttrs := Dim.Attributes;
    Levels := Dim.Levels;
    // Present dictionary as calendar
    DimAsCln := Dim.AsCalendar;
    // Mandatory calendar attributes
    ClnAttrs := DimAsCln.Attrs;
    c := ClnAttrs.Count;
    // Compare calendar attributes and attributes of the current dictionary
    For i := 0 To c - 1 Do
        AttrId := ClnAttrs.ItemId(i);
        Select Case AttrId
            Case "BLOCK_TYPE": ClnAttrs.IdAttr(AttrId) := DimAttrs.FindById("CUSTOM_BLOCK_TYPE");
            Case "START_DATE": ClnAttrs.IdAttr(AttrId) := DimAttrs.FindById("CUSTOM_START_DATE");
            Case "NAME": ClnAttrs.IdAttr(AttrId) := DimAttrs.FindById("NAME");
            Case "ID": ClnAttrs.IdAttr(AttrId) := DimAttrs.FindById("CUSTOM_ID");
            Case "ORDER": ClnAttrs.IdAttr(AttrId) := DimAttrs.FindById("ORD");
        End Select;
    End For;
    // Compare levels via KeyLevel
    ClnLevels := DimAsCln.Levels;
    ClnLevels.KeyLevel(Levels.Item(0).Key) := DimCalendarLevel.Year;
    ClnLevels.KeyLevel(Levels.Item(1).Key) := DimCalendarLevel.Month;
    // or via LevelKey
    ClnLevels.LevelKey(DimCalendarLevel.Year) := Levels.Item(0).Key;
    ClnLevels.LevelKey(DimCalendarLevel.Month) := Levels.Item(1).Key;
    Try
        // Declare dictionary a calendar one
        Dim.IsCalendar := True;
        // Save changes
        (Dim As IMetabaseObject).Save;
    Except On e: Exception Do
        Debug.WriteLine("Dictionary cannot be saved as a calendar one.");
        Debug.WriteLine(e.Message);
    End Try;
End Sub UserProc;

After executing the example MDM dictionary attributes and levels are compared so that the dictionary can be used as a calendar.

See also:

IDimensionModel