AddByAttribute(Attribute: IRdsAttribute): IRdsBaseBinding;
AddByAttribute(Attribute: Prognoz.Platform.Interop.Rds.IRdsAttribute): Prognoz.Platform.Interop.Rds.IRdsBaseBinding;
Attribute. Dictionary attribute, for which a binding is created.
The AddByAttribute method creates a binding for a specified attribute.
Binding type is set according to the attribute type. Basic properties can be defined for the binding, it can be cast to the required type, and set specific properties. 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 a table with the T_Dictionary identifier in the repository, and the Rds_Repo MDM repository that contains the Dict_1 table MDM dictionary. It is assumed that table fields and dictionary attributes have matching identifiers.
Sub UserProc;
Var
MB: IMetabase;
TableSource: ITable;
RdsDictionary: IRdsDictionary;
RdsLoader: IMetaRdsLoader;
Attrs: IRdsAttributes;
Attr: IRdsAttribute;
Fields: ITableFields;
Field: ITableField;
Bindings: IRdsLoaderBindings;
Binding: IRdsBaseBinding;
Begin
MB := MetabaseClass.Active;
//Source
TableSource := MB.ItemById("T_Dictionary").Bind As ITable;
//Updated dictionary
RdsDictionary := MB.ItemByIdNamespace("Dict_1", MB.GetObjectKeyById("RDS_REPO")).Bind As IRdsDictionary;
RdsLoader := New MetaRdsLoader.Create;
RdsLoader.Dictionary := RdsDictionary;
RdsLoader.TableSource := TableSource;
//Create bindings
Attrs := RdsDictionary.Attributes;
Fields := TableSource.Fields;
Bindings := RdsLoader.Bindings;
For Each Attr In Attrs Do
//In the table find a filed with the identifier,
//that matches dictionary attribute identifier
Field := Fields.FindById(Attr.Id);
If Field <> Null Then
Select Case Attr.PredefinedType
Case RdsPredefinedAttribute.Key:
Binding := Bindings.KeyBinding;
Binding.Attribute := Attr;
Binding.Field := Field.Id;
Case RdsPredefinedAttribute.Name:
Binding := Bindings.NameBinding;
Binding.Attribute := Attr;
Binding.Field := Field.Id;
Case RdsPredefinedAttribute.Order:
Binding := Bindings.OrderBinding;
Binding.Attribute := Attr;
Binding.Field := Field.Id;
Else
Binding := Bindings.AddByAttribute(Attr);
Binding.Field := Field.Id;
End Select;
End If;
End For;
//Update records
RdsLoader.Load(UpdateLoadMode.InsertUpdate);
End Sub UserProc;
Executing the example initializes the object used to create table MDM dictionaries and load data to these dictionaries. The object settings contain table MDM dictionary to be updated, and bindings for all attributes are created. After this dictionary data is updated.
Executing the example requires a table with the T_Dictionary identifier in the repository, and the Rds_Repo MDM repository that contains the Dict_1 table MDM dictionary. It is assumed that table fields and dictionary attributes have matching identifiers. This procedure is an entry point for .NET assembly.
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
TableSource: ITable;
RdsDictionary: IRdsDictionary;
RdsLoader: IMetaRdsLoader;
Attrs: IRdsAttributes;
Attr: IRdsAttribute;
Fields: ITableFields;
Field: ITableField;
Bindings: IRdsLoaderBindings;
Binding: IRdsBaseBinding;
Begin
MB := Params.Metabase;
//Source
TableSource := MB.ItemById["T_Dictionary"].Bind() As ITable;
//Updated dictionary
RdsDictionary := MB.ItemByIdNamespace["Dict_1", MB.GetObjectKeyById("RDS_REPO")].Bind() As IRdsDictionary;
RdsLoader := New MetaRdsLoaderClass();
RdsLoader.Dictionary := RdsDictionary;
RdsLoader.TableSource := TableSource;
//Create bindings
Attrs := RdsDictionary.Attributes;
Fields := TableSource.Fields;
Bindings := RdsLoader.Bindings;
For Each Attr In Attrs Do
//In the table find a filed with the identifier,
//that matches dictionary attribute identifier
Field := Fields.FindById(Attr.Id);
If Field <> Null Then
Select Case Attr.PredefinedType
Case RdsPredefinedAttribute.rpaKey:
Binding := Bindings.KeyBinding;
Binding.Attribute := Attr;
Binding.Field := Field.Id;
Case RdsPredefinedAttribute.rpaName:
Binding := Bindings.NameBinding;
Binding.Attribute := Attr;
Binding.Field := Field.Id;
Case RdsPredefinedAttribute.rpaOrder:
Binding := Bindings.OrderBinding;
Binding.Attribute := Attr;
Binding.Field := Field.Id;
Else
Binding := Bindings.AddByAttribute(Attr);
Binding.Field := Field.Id;
End Select;
End If;
End For;
//Update records
RdsLoader.Load(UpdateLoadMode.ulmInsertUpdate);
End Sub;
Executing the example initializes the object used to create table MDM dictionaries and load data to these dictionaries. The object settings contain table MDM dictionary to be updated, and bindings for all attributes are created. After this dictionary data is updated.
See also: