Attribute: IRdsAttribute;
Attribute: Prognoz.Platform.Interop.Rds.IRdsAttribute;
The Attribute property determines an MDM dictionary unique key attribute.
To work with unique key attributes, use the IRdsUniqueKey.Attributes property.
Executing the example requires that the repository contains a table MDM dictionary with the ATTRIBUTE identifier where unique key with two attributes is to be added.
Add links to the Metabase, Rds system assemblies.
Sub UserProc;
Var
mb: IMetabase;
Dict: IRdsDictionary;
UniqueKeys: IRdsUniqueKeys;
UniqueKey: IRdsUniqueKey;
UAttributes: IRdsUniqueKeyAttributes;
UAttribute: IRdsUniqueKeyAttribute;
Attributes: IRdsAttributes;
Attribute: IRdsAttribute;
i, j: integer;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Get MDM dictionary
Dict := mb.ItemById("ATTRIBUTE").Edit As IRdsDictionary;
// Get dictionary unique keys
UniqueKeys := Dict.UniqueKeys;
For i := 0 To UniqueKeys.Count - 1 Do
UniqueKey := UniqueKeys.Item(i);
End For;
// Get 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 unique key attributes to the console window
Debug.WriteLine("Initial list of 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(0, 1);
// Display a list of unique key attributes to the console window
Debug.WriteLine("List of 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;
After executing the example, the console window displays lists of unique key attribute identifiers before and after moving. Unique key attributes will be moved.
The requirements and result of the Fore.NET Example execution match with those in the Fore Example.
Imports Prognoz.Platform.Interop.Rds;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
Dict: IRdsDictionary;
UniqueKeys: IRdsUniqueKeys;
UniqueKey: IRdsUniqueKey;
UAttributes: IRdsUniqueKeyAttributes;
UAttribute: IRdsUniqueKeyAttribute;
Attributes: IRdsAttributes;
Attribute: IRdsAttribute;
i, j: integer;
Begin
// Get the current repository
mb := Params.Metabase;
// Get MDM dictionary
Dict := mb.ItemById["ATTRIBUTE"].Edit() As IRdsDictionary;
// Get dictionary unique keys
UniqueKeys := Dict.UniqueKeys;
For i := 0 To UniqueKeys.Count - 1 Do
UniqueKey := UniqueKeys.Item[i];
End For;
// Get 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 unique key attributes to the console window
System.Diagnostics.Debug.WriteLine("Initial list of 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.Id);
End For;
System.Diagnostics.Debug.Unindent();
// Move attributes
UAttributes.Move(0, 1);
// Display a list of unique key attributes to the console window
System.Diagnostics.Debug.WriteLine("List of 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.Id);
End For;
// Save dictionary
(Dict As IMetabaseObject).Save();
End Sub;
See also: