DetailTableObject: IMetabaseObjectDescriptor;
DetailTableObject: Prognoz.Platform.Interop.Metabase.IMetabaseObjectDescriptor;
The DetailTableObject property determines repository table, to which data of multiple values of a dictionary attribute is exported.
The IRdsExportSchemaAttribute.DetailTable property determines physical name of the table, to which data of multiple values of a dictionary attribute is exported.
Executing the example requires that the repository contains tables with the OBJ_EXP and OBJ_EXP_VALUE identifiers. There must be also the MDM repository with the RDS_REPO identifier that contains the MDM dictionary with the EXPORT identifier. This dictionary has an attribute with the ATTRIBUTE identifier that may have multiple values and is connected with another dictionary. Identifiers and field types of the OBJ_EXP table and of the EXPORT dictionary match. The OBJ_EXP table must also have a field of integer type with the KEY_EXP identifier. The OBJ_EXP_VALUE table must contain fields of integer type with the following identifiers: KEYFIELD, VALUEFIELD, ORDERFIELD.
Add links to the Metabase, Rds, Db system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
Dict: IRdsDictionary;
Export: IRdsExportSchemas;
SchemaExport: IRdsExportSchema;
Attrs: IRdsAttributes;
TableObj: IMetabaseObjectDescriptor;
Table: ITable;
SchemaExportAttr: IRdsExportSchemaAttribute;
DictInst: IRdsDictionaryInstance;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemByIdNamespace("EXPORT", MB.ItemById("RDS_REPO").Key).Edit;
Dict := MObj As IRdsDictionary;
Attrs := Dict.Attributes;
Export := Dict.ExportSchemas;
SchemaExport := Export.Add;
SchemaExport.Id := MB.GenerateId("Export1");
SchemaExport.Name := Export scheme #1;
SchemaExport.Mappings(Attrs.Key).FieldName := "Key";
SchemaExport.Mappings(Attrs.Name).FieldName := "Name";
SchemaExport.Mappings(Attrs.Order).FieldName := "Ord";
SchemaExport.Mappings(Attrs.ParentKey).FieldName := "Parent_key";
TableObj := MB.ItemById("OBJ_EXP");
Table := TableObj.Bind As ITable;
SchemaExport.TableObject := TableObj;
SchemaExport.TableName := Table.NativeName;
SchemaExportAttr := SchemaExport.Mappings(Attrs.FindById("ATTRIBUTE"));
//Binding attribute that has multiple values
TableObj := MB.ItemById("OBJ_EXP_VALUE");
Table := TableObj.Bind As ITable;
SchemaExportAttr.DetailTableObject := TableObj;
SchemaExportAttr.DetailTable := Table.NativeName;
SchemaExportAttr.FieldName := "KEY_EXP";
SchemaExportAttr.KeyField := "KEYFIELD";
SchemaExportAttr.ValueField := "VALUEFIELD";
SchemaExportAttr.OrderField := "ORDERFIELD";
MObj.Save;
DictInst := Dict.Open(Null);
DictInst.ExportData(SchemaExport);
End Sub UserProc;
After executing the example a new export scheme is created in the MDM dictionary. Attribute values of the EXPORT dictionary are exported in same-name fields of the OBJ_EXP table. Multiple values of the ATTRIBUTE attribute are imported from the OBJ_EXP_VALUE table. Export will be executed.
Executing the example requires that the repository contains tables with the OBJ_EXP and OBJ_EXP_VALUE identifiers. There must be also the MDM repository with the RDS_REPO identifier that contains the MDM dictionary with the EXPORT identifier. This dictionary has an attribute with the ATTRIBUTE identifier that may have multiple values and is connected with another dictionary. Identifiers and field types of the OBJ_EXP table and of the EXPORT dictionary match. The OBJ_EXP table must also have a field of integer type with the KEY_EXP identifier. The OBJ_EXP_VALUE table must contain fields of integer type with the following identifiers: KEYFIELD, VALUEFIELD, ORDERFIELD.
Imports Prognoz.Platform.Interop.Db;
Imports Prognoz.Platform.Interop.Rds;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MObj: IMetabaseObject;
Dict: IRdsDictionary;
Export: IRdsExportSchemas;
SchemaExport: IRdsExportSchema;
Attrs: IRdsAttributes;
TableObj: IMetabaseObjectDescriptor;
Table: ITable;
SchemaExportAttr: IRdsExportSchemaAttribute;
DictInst: IRdsDictionaryInstance;
Begin
MB := Params.Metabase;
MObj := MB.ItemByIdNamespace["EXPORT", MB.ItemById["RDS_REPO"].Key].Edit();
Dict := MObj As IRdsDictionary;
Attrs := Dict.Attributes;
Export := Dict.ExportSchemas;
SchemaExport := Export.Add();
SchemaExport.Id := MB.GenerateId("Export1", 0);
SchemaExport.Name := Export scheme #1;
SchemaExport.Mappings[Attrs.Key].FieldName := "Key";
SchemaExport.Mappings[Attrs.Name].FieldName := "Name";
SchemaExport.Mappings[Attrs.Order].FieldName := "Ord";
SchemaExport.Mappings[Attrs.ParentKey].FieldName := "Parent_key";
TableObj := MB.ItemById["OBJ_EXP"];
Table := TableObj.Bind() As ITable;
SchemaExport.TableObject := TableObj;
SchemaExport.TableName := Table.NativeName;
SchemaExportAttr := SchemaExport.Mappings[Attrs.FindById("ATTRIBUTE")];
//Binding attribute that has multiple values
TableObj := MB.ItemById["OBJ_EXP_VALUE"];
Table := TableObj.Bind() As ITable;
SchemaExportAttr.DetailTableObject := TableObj;
SchemaExportAttr.DetailTable := Table.NativeName;
SchemaExportAttr.FieldName := "KEY_EXP";
SchemaExportAttr.KeyField := "KEYFIELD";
SchemaExportAttr.ValueField := "VALUEFIELD";
SchemaExportAttr.OrderField := "ORDERFIELD";
MObj.Save();
DictInst := Dict.Open(Null);
DictInst.ExportData(SchemaExport);
End Sub;
After executing the example a new export scheme is created in the MDM dictionary. Attribute values of the EXPORT dictionary are exported in same-name fields of the OBJ_EXP table. Multiple values of the ATTRIBUTE attribute are imported from the OBJ_EXP_VALUE table. Export will be executed.
See also: