IRdsLoaderBindings.Add

Syntax

Add(BindingType: RdsLoaderBindingType): IRdsBaseBinding;

Parameters

BindingType. Type of created binding.

Description

The Add method creates a binding with a specified type.

Comments

According to the defined type, specify appropriate dictionary attribute in the created binding. The binding can be cast to required type, and specific properties can be defined for the binding. The following types of binding are available:

Example

Executing the example requires that the repository contains the objects:

Add links to the Dal, Db, Metabase, Rds system assemblies.

Description of required structure and data for used objects:

The T_DICTIONARY table

The T_ATTRVALUES table

The DICT_LINKED MDM dictionary

Sub UserProc;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    LinkDictionary: IRdsDictionary;
    RdsLoader: IMetaRdsLoader;
    Bindings: IRdsLoaderBindings;
    PredBinding: IRdsPredefinedBinding;
    LinkBinding: IRdsLinkedBinding;
    ImportBinding: IRdsImportedBinding;
    MultiValueBinding: IRdsBaseBinding;


Begin
    // Get the current repository
    MB := MetabaseClass.Active;
    // Get dictionary, with which link is created
    LinkDictionary := MB.ItemById("DICT_LINKED").Bind As IRdsDictionary;
    // Create an object to create an MDM dictionary and to load data to it
    RdsLoader := New MetaRdsLoader.Create;
    // Specify a table, from which data will be loaded
    RdsLoader.TableSource := MB.ItemById("T_DICTIONARY").Bind As ITable;
    // Get bindings between fields of source table and created MDM dictionary
    Bindings := RdsLoader.Bindings;
    // Set bindings of mandatory system attributes of MDM dictionary


    Bindings.KeyBinding.Field := "KEY";
    Bindings.NameBinding.Field := "NAME";
    Bindings.OrderBinding.Field := "ORD";
    // Set binding for the Owner attribute in MDM dictionary
    PredBinding := Bindings.Add(RdsLoaderBindingType.Predefined) As IRdsPredefinedBinding;
    PredBinding.PredefinedType := RdsPredefinedAttribute.ParentKey;
    PredBinding.Field := "PARENT";
    // Set binding for the attribute that will be used for linking with another dictionary


    LinkBinding := Bindings.Add(RdsLoaderBindingType.Linked) As IRdsLinkedBinding;
    // Set name and identifier of attribute
    LinkBinding.Id := "FORLINK";
    LinkBinding.Name := "For link";
    // Specify that link will be created by key
    LinkBinding.Reference := LinkDictionary.Attributes.Key;
    // Specify field in source table that contains values of this attribute
    LinkBinding.Field := "FORLINK";
    // Create an imported attribute from linked dictionary
    ImportBinding := Bindings.Add(RdsLoaderBindingType.Imported) As IRdsImportedBinding;


    // Set name and identifier of attribute
    ImportBinding.Id := "NAME_LINKEDDICT";
    ImportBinding.Name := "Capital";
    // Specify binding, which describes tha attribute used for linking with another dictionary
    ImportBinding.LinkBinding := LinkBinding;
    // Specify that imported attribute will display
    // names of elements from linked dictionary
    ImportBinding.Lookup := LinkBinding.Dictionary.Attributes.Name;
    // Set binding for attribute with multiple values
    MultiValueBinding := Bindings.Add(RdsLoaderBindingType.UserAttribute);


    // Set name and identifier of attribute
    MultiValueBinding.Id := "MULTIATTR";
    MultiValueBinding.Name := "Official languages";
    // Specify field in source table that contains values of this attribute
    MultiValueBinding.Field := "MULTIATTR";
    // Set attribute data type
    MultiValueBinding.DataType := DbDataType.String;
    // Specify that attribute can  have multiple values
    MultiValueBinding.HasMultipleValues := True;
    // Specify the table, which stores multiple values
    MultiValueBinding.DetailTableObject := MB.ItemById("T_ATTRVALUES");


    // Set used fields with data from the table, which stores multiple values
    MultiValueBinding.KeyField := "KEY";
    MultiValueBinding.OrderField := "ORDER";
    MultiValueBinding.ValueField := "VALUE";
    // Specify that multiple attribute can contain empty values
    MultiValueBinding.Nullable := True;
    // Set information about created dictionary
    CrInfo := MB.CreateCreateInfo;
    CrInfo.Parent := MB.ItemById("MDM");
    CrInfo.Id := MB.GenerateId("Dict", CrInfo.Parent.Key);


    // Create and save dictionary
    (RdsLoader.CreateObject(CrInfo) As IMetabaseObject).Save;
    // Load data
    RdsLoader.Load(UpdateLoadMode.Insert);
End Sub UserProc;

Executing the example sets up the object that is used to create MDM dictionaries and to load data to them. Data source is specified in the object settings, and bindings for various attribute types are created. After it the dictionary of countries is created and data about capitals and national languages are loaded to it.

See also:

IRdsLoaderBindings