IRdsNonUniqueKeyAttribute.Attribute

Syntax

Attribute: IRdsAttribute;

Attribute: Prognoz.Platform.Interop.Rds.IRdsAttribute;

Description

The Attribute property determines an MDM dictionary non unique key attribute.

Comments

A non unique key is an additional identifier of records in an MDM dictionary. It is used to set up attribute as alternative hierarchy and to set index to link with alternative hierarchies. A key may consist of a single dictionary attribute which values can repeat for each elements and of several attributes which sum of values is not unique.

Example

Executing the example requires that the repository contains a table MDM dictionary with the ATTRIBUTEN identifier where non unique key with three attributes is added.

Add links to the Metabase, Rds system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    Dict: IRdsDictionary;
    UniqueKeys: IRdsNonUniqueKeys;
    UniqueKey: IRdsNonUniqueKey;
    UAttributes: IRdsNonUniqueKeyAttributes;
    UAttribute: IRdsNonUniqueKeyAttribute;
    Attributes: IRdsAttributes;
    Attribute: IRdsAttribute;
    i, j: integer;
Begin
    
// Get current repository
    mb := MetabaseClass.Active;
    
// Get MDM dictionary
    Dict := mb.ItemById("ATTRIBUTEN").Edit As IRdsDictionary;
    
// Get dictionary non unique keys
    UniqueKeys := Dict.NonUniqueKeys;
    
For i := 0 To UniqueKeys.Count - 1 Do
        UniqueKey := UniqueKeys.Item(i);
    
End For;
    
//  Get non unique key attributes
    UAttributes := UniqueKey.Attributes;
    
//  Get dictionary attributes
    Attributes := Dict.Attributes;
    
For i := 0 To Attributes.Count - 1 Do
        Attribute := Attributes.Item(i);
        j := UAttributes.FindByAttribute(Attribute);

        If j >= 0 Then
            UAttribute := UAttributes.Item(j);
        
End If;
    
End For;
    
// Display a list of non unique key attributes to the console window
    Debug.WriteLine("Initial list of non unique key attributes");
    Debug.Indent;
    
For i := 0 To UAttributes.Count - 1 Do
        UAttribute := UAttributes.Item(i);
        Debug.WriteLine(UAttribute.Attribute.Id);
    
End For;
    Debug.Unindent;
    
// Move attributes
    UAttributes.Move(1, UAttributes.Count - 1);
    // Display a list of non unique key attributes to the display window
    Debug.WriteLine("List of non unique key attributes after moving");
    Debug.Indent;
    
For i := 0 To UAttributes.Count - 1 Do
        UAttribute := UAttributes.Item(i);
        Debug.WriteLine(UAttribute.Attribute.Id);
    
End For;
    
// Save dictionary
    (Dict As IMetabaseObject).Save;
End Sub UserProc;

Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    Dict: IRdsDictionary;
    UniqueKeys: IRdsNonUniqueKeys;
    UniqueKey: IRdsNonUniqueKey;
    UAttributes: IRdsNonUniqueKeyAttributes;
    UAttribute: IRdsNonUniqueKeyAttribute;
    Attributes: IRdsAttributes;
    Attribute: IRdsAttribute;
    i, j: integer;
Begin
    
// Get current repository
    mb := Params.Metabase;
    
// Get MDM dictionary
    Dict := mb.ItemById["ATTRIBUTEN"].Edit() As IRdsDictionary;
    
// Get dictionary non unique keys
    UniqueKeys := Dict.NonUniqueKeys;
    
For i := 0 To UniqueKeys.Count - 1 Do
        UniqueKey := UniqueKeys.Item[i];
    
End For;
    
//  Get non unique key attributes
    UAttributes := UniqueKey.Attributes;
    
//  Get dictionary attributes
    Attributes := Dict.Attributes;
    
For i := 0 To Attributes.Count - 1 Do
        Attribute := Attributes.Item[i];
        j := UAttributes.FindByAttribute(Attribute);
//      Debug.WriteLine(j);
        If j >= 0 Then
            UAttribute := UAttributes.Item[j];
        
End If;
    
End For;
    
// Display a list of non unique key attributes to the console window
    System.Diagnostics.Debug.WriteLine("Initial list of non unique key attributes");
    System.Diagnostics.Debug.Indent();
    
For i := 0 To UAttributes.Count - 1 Do
        UAttribute := UAttributes.Item[i];
        System.Diagnostics.Debug.WriteLine(UAttribute.Attribute.Name);
    
End For;
    System.Diagnostics.Debug.Unindent();
    
// Move attributes
    UAttributes.Move(1, UAttributes.Count - 1);
    
//UAttributes.Move(0, 1);
    // Display a list of non unique key attributes to the console window
    System.Diagnostics.Debug.WriteLine("List of non unique key attributes after moving");
    System.Diagnostics.Debug.Indent();
    
For i := 0 To UAttributes.Count - 1 Do
        UAttribute := UAttributes.Item[i];
        System.Diagnostics.Debug.WriteLine(UAttribute.Attribute.Name);
    
End For;
    
// Save dictionary
    (Dict As IMetabaseObject).Save();
End Sub;

After executing the example the console window displays list of non unique key attributes before and after moving them. The second and the last attributes of non unique key will be moved.

See also:

IRdsNonUniqueKeyAttribute