IRdsImportSchema.AddCrossVersions

Syntax

AddCrossVersions: Boolean;

Description

The AddCrossVersions property determines whether new versions of the element, which actual period intersects with periods of other versions of this element, are added.

Comments

It is used if import is executed to a version MDM dictionary, and the update options are selected: Add New (Missing) Elements or Add New Elements and Update Existing Ones.

Available values:

Example

Executing the example requires that the repository contains a version MDM dictionary with the NSI_DICT identifier, which contains an import schema with the IMPORTSCHEMA identifier. Import schema's data source is a table with the KEY, NAME, INDATE, OUTDATE, VERSION fields related linked with corresponding attributes of the MDM dictionary in import schema settings. The Add New Elements and Update Existing Ones update option should be selected in the import schema. Versions are added if the KEY attribute has identical values and the VERSION attribute has different values.

Add links to the Metabase and Rds system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Obj: IMetabaseObject;
    Dict: IRdsDictionary;
    DictInst: IRdsDictionaryInstance;
    Schema: IRdsImportSchema;
    Attrs: IRdsAttributes;
    Elements: IRdsDictionaryElements;
    Hist: IRdsDictionaryElementHistory;
    InDate, OutDate, Name, i, j: Integer;
Begin
    // Get the current repository
    MB := MetabaseClass.Active;
    // Get version MDM dictionary
    Obj := MB.ItemById("NSI_DICT").Edit;
    Dict := Obj As IRdsDictionary;
    // Get MDM dictionary data
    DictInst := Dict.Open(NullAs IRdsDictionaryInstance;
    // Get collection of attributes
    Attrs := Dict.Attributes;
    // Get key of the Start Date attribute
    InDate := Attrs.InDate.Key;
    // Get key of the End Date attribute
    OutDate := Attrs.OutDate.Key;
    // Get key of the Name attribute
    Name := Attrs.Name.Key;
    // Get collection of dictionary elements
    Elements := DictInst.Elements;
    // Display names element names and values of their attributes before import schema application in the console
    Debug.WriteLine("Element versions before import schema application");
    For i := 1 To Elements.Count - 1 Do
        Hist := Elements.Item(i).History;
        Debug.WriteLine(Elements.Item(i).Name);
            For j := 0 To Hist.Count - 1 Do
                Debug.Write("Start date: " + Hist.Attribute(j, InDate));
                Debug.Write(" End date: " + Hist.Attribute(j, OutDate));
                Debug.WriteLine(" Value at this interval: " + Hist.Attribute(j, Name));
            End For;
    End For;
    // Get import schema
    Schema := Dict.ImportSchemas.FindById("IMPORTSCHEMA");
    // Determine whether new element versions with intersecting periods are added
    Schema.AddCrossVersions := True;
    // Import data from import schema
    DictInst.ImportData(Schema);
    // Display element names and values of their attributes after import schema application
    Debug.WriteLine("Element versions after import schema application");
    For i := 1 To Elements.Count - 1 Do
        Hist := Elements.Item(i).History;
        Debug.WriteLine(Elements.Item(i).Name);
            For j := 0 To Hist.Count - 1 Do
                Debug.Write("Start date: " + Hist.Attribute(j, InDate));
                Debug.Write(" End date: " + Hist.Attribute(j, OutDate));
                Debug.WriteLine(" Value at this interval: " + Hist.Attribute(j, Name));
            End For;
    End For;
    // Save changes
    Obj.Save;
End Sub UserProc;

After executing the example, new versions of MDM dictionary elements are added, and the console displays information about element versions before and after import schema application. For example:

Elements versions before import schema application

Element 1

Start date: 25.07.2024 End date: 30.07.2024 Value at this interval: Element 1

Element versions after import schema application

Element 1

Start date: 25.07.2024 End date: 27.07.2024 Value at this interval: Element 1

Start date: 29.07.2024 End date: 30.07.2024 Value at this interval: Element 2

Start date: 27.07.2024 End date: 29.07.2024 Value at this interval: Element 3

See also:

IRdsImportSchema