IRdsLoaderBindings.Add

Fore Syntax

Add(BindingType: RdsLoaderBindingType): IRdsBaseBinding;

Fore.NET Syntax

Add(BindingType: Prognoz.Platform.Interop.Rds.RdsLoaderBindingType): Prognoz.Platform.Interop.Rds.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:

Fore 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 table 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 current repository
    MB := MetabaseClass.Active;
    // Get dictionary, with which a link is created
    LinkDictionary := MB.ItemByIdNamespace("DICT_LINKED", MB.GetObjectKeyById("MDM")).Bind As IRdsDictionary;
    // Create an object to create a table MDM dictionary and load data to it
    RdsLoader := New MetaRdsLoader.Create;
    // Specify table, from which data is loaded
    RdsLoader.TableSource := MB.ItemById("T_DICTIONARY").Bind As ITable;
    // Get bindings between source table fields and created MDM dictionary fields
    Bindings := RdsLoader.Bindings;

    // Set bindings of mandatory system attributes of table MDM dictionary
    Bindings.KeyBinding.Field := "KEY";
    Bindings.NameBinding.Field := "NAME";
    Bindings.OrderBinding.Field := "ORD";
    // Set binding for the Owner attribute in Table 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 to link with other dictionary
    LinkBinding := Bindings.Add(RdsLoaderBindingType.Linked) As IRdsLinkedBinding;

    // Set attribute name and identifier
    LinkBinding.Id := "FORLINK";
    LinkBinding.Name := "For link";
    // Specify that link is created by key
    LinkBinding.Reference := LinkDictionary.Attributes.Key;
    // Specify source table field that contains values for this attribute
    LinkBinding.Field := "FORLINK";
    // Create an imported attribute from linked dictionary
    ImportBinding := Bindings.Add(RdsLoaderBindingType.Imported) As IRdsImportedBinding;
    // Set attribute name and identifier
    ImportBinding.Id := "NAME_LINKEDDICT";
    ImportBinding.Name := "Capital";
    // Specify the binding, in which attribute is described that is used to link with other 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 attribute name and identifier
    MultiValueBinding.Id := "MULTIATTR";
    MultiValueBinding.Name := "Official languages";
    // Specify field in source table that contains values for this attribute
    MultiValueBinding.Field := "MULTIATTR";
    // Set attribute data type
    MultiValueBinding.DataType := DbDataType.String;
    // Specify that attribute can have multiple values
    MultiValueBinding.HasMultipleValues := True;
    // Specify table that stores multiple values
    MultiValueBinding.DetailTableObject := MB.ItemById("T_ATTRVALUES");
    // Set used fields with data from table that 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 used to create table MDM dictionaries and to load data to it. 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.

Fore.NET Example

The requirements and result of the Fore.NET Example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Db;
Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
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 := Params.Metabase;
    // Get dictionary, with which a link is created
    LinkDictionary := MB.ItemByIdNamespace["DICT_LINKED", MB.GetObjectKeyById("MDM")].Bind() As IRdsDictionary;
    // Create an object to create a table MDM dictionary and load data to it
    RdsLoader := New MetaRdsLoader.Create();
    // Specify table, from which data is loaded
    RdsLoader.TableSource := MB.ItemById["T_DICTIONARY"].Bind() As ITable;
    // Get bindings between source table fields and created table MDM dictionary
    Bindings := RdsLoader.Bindings;

    // Set bindings of mandatory system attributes of table MDM dictionary
    Bindings.KeyBinding.Field := "KEY";
    Bindings.NameBinding.Field := "NAME";
    Bindings.OrderBinding.Field := "ORD";
    // Set binding for the Owner attribute in table MDM dictionary
    PredBinding := Bindings.Add(RdsLoaderBindingType.rlbtPredefined) As IRdsPredefinedBinding;
    PredBinding.PredefinedType := RdsPredefinedAttribute.rpaParentKey;
    PredBinding.Field := "PARENT";
    // Set binding for attribute that will be used to link with other dictionary
    LinkBinding := Bindings.Add(RdsLoaderBindingType.rlbtLinked) As IRdsLinkedBinding;

    // Set attribute name and identifier
    LinkBinding.Id := "FORLINK";
    LinkBinding.Name := "For link";
    // Specify that link is created by key
    LinkBinding.Reference := LinkDictionary.Attributes.Key;
    // Specify source table field that contains values for this attribute
    LinkBinding.Field := "FORLINK";
    // Create an imported attribute from linked dictionary
    ImportBinding := Bindings.Add(RdsLoaderBindingType.rlbtImported) As IRdsImportedBinding;
    // Set attribute name and identifier
    ImportBinding.Id := "NAME_LINKEDDICT";
    ImportBinding.Name := "Capital";
    // Specify binding, in which attribute is described that is used to link with other attribute
    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.rlbtUserAttribute);

    // Set attribute name and identifier
    MultiValueBinding.Id := "MULTIATTR";
    MultiValueBinding.Name := "Official languages";
    // Specify field in source table that contains values for this attribute
    MultiValueBinding.Field := "MULTIATTR";
    // Set attribute data type
    MultiValueBinding.DataType := DbDataType.ddtString;
    // Specify that attribute can have multiple values
    MultiValueBinding.HasMultipleValues := True;
    // Specify table that stores multiple values
    MultiValueBinding.DetailTableObject := MB.ItemById["T_ATTRVALUES"];

    // Set used fields with data from table that stores multiple values
    MultiValueBinding.KeyField := "KEY";
    MultiValueBinding.OrderField := "ORDER";
    MultiValueBinding.ValueField := "VALUE";
    // Specify that multiple attribute can have 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.ulmInsert);
End Sub;

See also:

IRdsLoaderBindings