Add(BindingType: RdsLoaderBindingType): IRdsBaseBinding;
Add(BindingType: Prognoz.Platform.Interop.Rds.RdsLoaderBindingType): Prognoz.Platform.Interop.Rds.IRdsBaseBinding;
BindingType. Type of created binding.
The Add method creates a binding with a specified type.
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:
IRdsPredefinedBinding. Parameters of system attribute binding.
IRdsTranslationBinding. Binding parameters for the attribute that stores values in a specific language.
IRdsUserAttributeBinding. Parameters of custom attribute binding.
IRdsLinkedBinding. Parameters of linked attribute binding.
IRdsImportedBinding. Parameters of imported attribute binding.
Executing the example requires that the repository contains the objects:
The MDM repository with the MDM identifier where table MDM dictionary with the DICT_LINKED identifier is created. A link with this dictionary is created from the created MDM dictionary.
A table with the T_DICTIONARY identifier that is used as a source of dictionary data.
A table with the T_ATTRVALUES identifier where values for multiple-value attribute are stored in the created dictionary.
Add links to the Dal, Db, Metabase, Rds system assemblies.
Description of required structure and data for used objects:
The DICT_LINKED table MDM dictionary
<font color="#008080">Sub</font> UserProc;<br /> <font color="#008080">Var</font><br /> MB: IMetabase;<br /> CrInfo: IMetabaseObjectCreateInfo;<br /> LinkDictionary: IRdsDictionary;<br /> RdsLoader: IMetaRdsLoader;<br /> Bindings: IRdsLoaderBindings;<br /> PredBinding: IRdsPredefinedBinding;<br /> LinkBinding: IRdsLinkedBinding;<br /> ImportBinding: IRdsImportedBinding;<br /> MultiValueBinding: IRdsBaseBinding;<br /> <font color="#008080">Begin</font><br /> <font color="#008000">// Get current repository<br /> </font> MB := MetabaseClass.Active;<br /> <font color="#008000">// Get dictionary with which binding will be created<br /> </font> LinkDictionary := MB.ItemByIdNamespace(<font color="#800000">"DICT_LINKED"</font>, MB.GetObjectKeyById(<font color="#800000">"MDM"</font>)).Bind <font color="#008080">As</font> IRdsDictionary;<br /> <font color="#008000">// Create object to create table MDM dictionary and to load data to it<br /> </font> RdsLoader := <font color="#008080">New</font> MetaRdsLoader.Create;<br /> <font color="#008000">// Determine table from which data will be loaded<br /> </font> RdsLoader.TableSource := MB.ItemById(<font color="#800000">"T_DICTIONARY"</font>).Bind <font color="#008080">As</font> ITable;<br /> <font color="#008000">// Get bindings of table source fields and created table MDM dictionary<br /> </font> Bindings := RdsLoader.Bindings;<br /> <font color="#008000">// Determine bindings of mandatory system attributes of table MDM dictionary<br /> </font> Bindings.KeyBinding.Field := <font color="#800000">"KEY"</font>;<br /> Bindings.NameBinding.Field := <font color="#800000">"NAME"</font>;<br /> Bindings.OrderBinding.Field := <font color="#800000">"ORD"</font>;<br /> <font color="#008000">// Determine binding for the Owner attribute in the table MDM dictionary<br /> </font> PredBinding := Bindings.Add(RdsLoaderBindingType.Predefined) <font color="#008080">As</font> IRdsPredefinedBinding;<br /> PredBinding.PredefinedType := RdsPredefinedAttribute.ParentKey;<br /> PredBinding.Field := <font color="#800000">"PARENT"</font>;<br /> <font color="#008000">// Determine binding for the attribute which will be used for binding with another dictionary<br /> </font> LinkBinding := Bindings.Add(RdsLoaderBindingType.Linked) <font color="#008080">As</font> IRdsLinkedBinding;<br /> <font color="#008000">// Determine attribute name and identifier<br /> </font> LinkBinding.Id := <font color="#800000">"FORLINK"</font>;<br /> LinkBinding.Name := <font color="#800000">"Для связи"</font>;<br /> <font color="#008000">// Determine that binding will be created by key<br /> </font> LinkBinding.Reference := LinkDictionary.Attributes.Key;<br /> <font color="#008000">// Determine filed in the table source which contains values for the attribute<br /> </font> LinkBinding.Field := <font color="#800000">"FORLINK"</font>;<br /> <font color="#008000">// Create borrowed attribute from linked dictionary<br /> </font> ImportBinding := Bindings.Add(RdsLoaderBindingType.Imported) <font color="#008080">As</font> IRdsImportedBinding;<br /> <font color="#008000">// Determine attribute name and identifier<br /> </font> ImportBinding.Id := <font color="#800000">"NAME_LINKEDDICT"</font>;<br /> ImportBinding.Name := <font color="#800000">"Capital"</font>;<br /> <font color="#008000">// Determine binding where there is a description of the attribute used for binding with other dictionary<br /> </font> ImportBinding.LinkBinding := LinkBinding;<br /> <font color="#008000">// Determine that borrowed attribute will display<br /> </font> <font color="#008000">// names of elements from linked dictionary<br /> </font> ImportBinding.Lookup := LinkBinding.Dictionary.Attributes.Name;<br /> <font color="#008000">// Determine binding for the attribute with multiple values<br /> </font> MultiValueBinding := Bindings.Add(RdsLoaderBindingType.UserAttribute);<br /> <font color="#008000">// Determine attribute name and identifier<br /> </font> MultiValueBinding.Id := <font color="#800000">"MULTIATTR"</font>;<br /> MultiValueBinding.Name := <font color="#800000">"National languages"</font>;<br /> <font color="#008000">// Determine field in table source which contains values for this attribute<br /> </font> MultiValueBinding.Field := <font color="#800000">"MULTIATTR"</font>;<br /> <font color="#008000">// Determine attribute data type<br /> </font> MultiValueBinding.DataType := DbDataType.String;<br /> <font color="#008000">// Determine that attribute can have multiple values<br /> </font> MultiValueBinding.HasMultipleValues := <font color="#008080">True</font>;<br /> <font color="#008000">// Determine table where multiple values are stored<br /> </font> MultiValueBinding.DetailTableObject := MB.ItemById(<font color="#800000">"T_ATTRVALUES"</font>);<br /> <font color="#008000">// Determine used fields with data from table where multiple values are stored<br /> </font> MultiValueBinding.KeyField := <font color="#800000">"KEY"</font>;<br /> MultiValueBinding.OrderField := <font color="#800000">"ORDER"</font>;<br /> MultiValueBinding.ValueField := <font color="#800000">"VALUE"</font>;<br /> <font color="#008000">// Determine that multiple attribute can contain empty values<br /> </font> MultiValueBinding.Nullable := <font color="#008080">True</font>;<br /> <font color="#008000">// Determine information about created dictionary<br /> </font> CrInfo := MB.CreateCreateInfo;<br /> CrInfo.Parent := MB.ItemById(<font color="#800000">"MDM"</font>);<br /> CrInfo.Id := MB.GenerateId(<font color="#800000">"Dict"</font>, CrInfo.Parent.Key);<br /> <font color="#008000">// Create and save dictionary<br /> </font> (RdsLoader.CreateObject(CrInfo) <font color="#008080">As</font> IMetabaseObject).Save;<br /> <font color="#008000">// Load data<br /> </font> RdsLoader.Load(UpdateLoadMode.Insert);<br /> <font color="#008080">End</font> <font color="#008080">Sub</font> 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.
The requirements and result of the Fore.NET Example execution match with those in the Fore Example.
<font color="#008080">Imports</font> Prognoz.Platform.Interop.Dal;<br /> <font color="#008080">Imports</font> Prognoz.Platform.Interop.Db;<br /> <font color="#008080">Imports</font> Prognoz.Platform.Interop.Rds;<br /> …<br /> <font color="#008080">Public</font> <font color="#008080">Shared</font> <font color="#008080">Sub</font> Main(Params: StartParams);<br /> <font color="#008080">Var</font><br /> MB: IMetabase;<br /> CrInfo: IMetabaseObjectCreateInfo;<br /> LinkDictionary: IRdsDictionary;<br /> RdsLoader: IMetaRdsLoader;<br /> Bindings: IRdsLoaderBindings;<br /> PredBinding: IRdsPredefinedBinding;<br /> LinkBinding: IRdsLinkedBinding;<br /> ImportBinding: IRdsImportedBinding;<br /> MultiValueBinding: IRdsBaseBinding;<br /> <font color="#008080">Begin</font><br /> <font color="#008000">// Get current repository<br /> </font> MB := Params.Metabase;<br /> <font color="#008000">// Get dictionary with which binding will be created<br /> </font> LinkDictionary := MB.ItemByIdNamespace[<font color="#800000">"DICT_LINKED"</font>, MB.GetObjectKeyById(<font color="#800000">"MDM"</font>)].Bind() <font color="#008080">As</font> IRdsDictionary;<br /> <font color="#008000">// Create object to create table MDM dictionary and to load data to it<br /> </font> RdsLoader := <font color="#008080">New</font> MetaRdsLoader.Create();<br /> <font color="#008000">// Determine table from which data is loaded<br /> </font> RdsLoader.TableSource := MB.ItemById[<font color="#800000">"T_DICTIONARY"</font>].Bind() <font color="#008080">As</font> ITable;<br /> <font color="#008000">// Get bindings of table source fields and created table MDM dictionary<br /> </font> Bindings := RdsLoader.Bindings;<br /> <font color="#008000">// Determine bindings of mandatory sestem attributes of table MDM dictionary<br /> </font> Bindings.KeyBinding.Field := <font color="#800000">"KEY"</font>;<br /> Bindings.NameBinding.Field := <font color="#800000">"NAME"</font>;<br /> Bindings.OrderBinding.Field := <font color="#800000">"ORD"</font>;<br /> <font color="#008000">// Determine binding for the Owner attribute in table MDM dictionary<br /> </font> PredBinding := Bindings.Add(RdsLoaderBindingType.rlbtPredefined) <font color="#008080">As</font> IRdsPredefinedBinding;<br /> PredBinding.PredefinedType := RdsPredefinedAttribute.rpaParentKey;<br /> PredBinding.Field := <font color="#800000">"PARENT"</font>;<br /> <font color="#008000">// Determine binding for the attribute which will be used to link with another dictionary<br /> </font> LinkBinding := Bindings.Add(RdsLoaderBindingType.rlbtLinked) <font color="#008080">As</font> IRdsLinkedBinding;<br /> <font color="#008000">// Determine attribute name and identifier<br /> </font> LinkBinding.Id := <font color="#800000">"FORLINK"</font>;<br /> LinkBinding.Name := <font color="#800000">"Для связи"</font>;<br /> <font color="#008000">// Determine that link is created by key<br /> </font> LinkBinding.Reference := LinkDictionary.Attributes.Key;<br /> <font color="#008000">// Determine filed in the source table which contain values for this attribute<br /> </font> LinkBinding.Field := <font color="#800000">"FORLINK"</font>;<br /> <font color="#008000">// Create borrowed attribute from linked dictionary<br /> </font> ImportBinding := Bindings.Add(RdsLoaderBindingType.rlbtImported) <font color="#008080">As</font> IRdsImportedBinding;<br /> <font color="#008000">// Determine attribute name and identifier<br /> </font> ImportBinding.Id := <font color="#800000">"NAME_LINKEDDICT"</font>;<br /> ImportBinding.Name := <font color="#800000">"Capital"</font>;<br /> <font color="#008000">// Determine binding where there is a description of the attributeused for link with another dictionary<br /> </font> ImportBinding.LinkBinding := LinkBinding;<br /> <font color="#008000">// Determine that borrowed attribute will display<br /> </font> <font color="#008000">// name of elements from linked dictionary<br /> </font> ImportBinding.Lookup := LinkBinding.Dictionary.Attributes.Name;<br /> <font color="#008000">// Determine binding for the attribute with multiple values<br /> </font> MultiValueBinding := Bindings.Add(RdsLoaderBindingType.rlbtUserAttribute);<br /> <font color="#008000">// Determine name and identifier of the attribute<br /> </font> MultiValueBinding.Id := <font color="#800000">"MULTIATTR"</font>;<br /> MultiValueBinding.Name := <font color="#800000">"National languages</font>;<br /> <font color="#008000">// Determine field in the source table whcih contains values of this attribute<br /> </font> MultiValueBinding.Field := <font color="#800000">"MULTIATTR"</font>;<br /> <font color="#008000">// Determine attribute data type<br /> </font> MultiValueBinding.DataType := DbDataType.ddtString;<br /> <font color="#008000">// Determine that attribute can have multiple values<br /> </font> MultiValueBinding.HasMultipleValues := <font color="#008080">True</font>;<br /> <font color="#008000">// Determine table where multiple values are stored<br /> </font> MultiValueBinding.DetailTableObject := MB.ItemById[<font color="#800000">"T_ATTRVALUES"</font>];<br /> <font color="#008000">// Determine used fields with data from table where multiple values are stored<br /> </font> MultiValueBinding.KeyField := <font color="#800000">"KEY"</font>;<br /> MultiValueBinding.OrderField := <font color="#800000">"ORDER"</font>;<br /> MultiValueBinding.ValueField := <font color="#800000">"VALUE"</font>;<br /> <font color="#008000">// Determine that multiple attribute can contain empty values<br /> </font> MultiValueBinding.Nullable := <font color="#008080">True</font>;<br /> <font color="#008000">// Determine information about created dictionary<br /> </font> CrInfo := MB.CreateCreateInfo();<br /> CrInfo.Parent := MB.ItemById[<font color="#800000">"MDM"</font>];<br /> CrInfo.Id := MB.GenerateId(<font color="#800000">"Dict"</font>, CrInfo.Parent.Key);<br /> <font color="#008000">// Creare and save dictionary<br /> </font> (RdsLoader.CreateObject(CrInfo) <font color="#008080">As</font> IMetabaseObject).Save();<br /> <font color="#008000">// Load data<br /> </font> RdsLoader.Load(UpdateLoadMode.ulmInsert);<br /> <font color="#008080">End</font> <font color="#008080">Sub</font>;
See also: