Dataset: IDatasetModel;
The Dataset property determines a table MDM dictionary that is used as a data consumer.
Executing the example requires that the repository contains an ETL task with the ETL_Task identifier and a table MDM dictionary with the RDS_DICT identifier.
Add links to the Andy, Db, Drawing, Dt, Etl, Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
ETLTask: IEtlTask;
EtlConsumer: IEtlPlainDataConsumer;
DtRds: IDtRdsConsumer;
Begin
MB := MetabaseClass.Active;
ETLTask := MB.ItemById("ETL_Task").Edit As IEtlTask;
//Create a new data consumer - table MDM dictionary
EtlConsumer := ETLTask.Create(EtlObjectType.PlainDataRdsConsumer) As IEtlPlainDataConsumer;
EtlConsumer := EtlConsumer.Edit;
EtlConsumer.ClearConsumer := False;
EtlConsumer.Id := "RDS_Consumer";
EtlConsumer.Name := "Data consumer - Table MDM dictionary";
//Create a visual consumer object
CreateWX(ETLTask, EtlConsumer, 0, 0);
//Set up data consumer
DtRds := EtlConsumer.Consumer As IDtRdsConsumer;
DtRds.Dataset := Mb.ItemById("RDS_DICT").Bind As IDatasetModel;
DtRds.CatchAddRecordException := True;
DtRds.UpdateMode := UpdateLoadMode.InsertUpdate;
//Save data consumer
EtlConsumer.Save;
//Save task
(ETLTask As IMetabaseObject).Save;
End Sub UserProc;
//Create a visual object
Sub CreateWX(ETLTask: IEtlTask; ETLObject: IEtlObject; XPosition: Integer; YPosition: Integer);
Var
WxRect: IWxRectangle;
WxETLObj: IWxEtlObject;
Begin
WxRect := ETLTask.Workspace.CreateRectangle;
WxRect.Id := ETLObject.Id;
WxETLObj := New WxEtlObject.Create;
WxETLObj.EtlObject := ETLObject;
WxRect.Style.TextPosition := WxTextPosition.Bottom;
WxRect.Style.PictureMarginTop := -10;
WxRect.PinPosition := New GxPointF.Create(XPosition, YPosition);
WxRect.Extension := WxETLObj As IWxShapeExtension;
End Sub CreateWX;
Imports Prognoz.Platform.Interop.Andy;
Imports Prognoz.Platform.Interop.Db;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.Etl;
Imports Prognoz.Platform.Interop.Metabase;
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
ETLTask: IEtlTask;
EtlConsumer: IEtlPlainDataConsumer;
DtRds: IDtRdsConsumer;
Begin
MB := Params.Metabase;
ETLTask := MB.ItemById["ETL_Task"].Edit() As IEtlTask;
//Create a new data consumer - table MDM dictionary
EtlConsumer := ETLTask.Create(EtlObjectType.eotPlainDataRdsConsumer) As IEtlPlainDataConsumer;
EtlConsumer := EtlConsumer.Edit();
EtlConsumer.ClearConsumer := False;
EtlConsumer.Id := "RDS_Consumer";
EtlConsumer.Name := "Data provider - Table MDM dictionary";
//Create a visual source object
CreateWX(ETLTask, EtlConsumer, 0, 0);
//Set up data consumer
DtRds := EtlConsumer.Consumer As IDtRdsConsumer;
DtRds.Dataset := Mb.ItemById["RDS_DICT"].Bind() As IDatasetModel;
DtRds.CatchAddRecordException := True;
DtRds.UpdateMode := UpdateLoadMode.ulmInsertUpdate;
//Save data consumer
EtlConsumer.Save();
//Save task
(ETLTask As IMetabaseObject).Save();
End Sub;
//Create visual objects
Public Shared Sub CreateWX(ETLTask: IEtlTask; ETLObject: IEtlObject; XPosition: Integer; YPosition: Integer);
Var
GxPointFCls: GxPointF = New GxPointFClass();
WxRect: IWxRectangle;
WxETLObj: IWxEtlObject = New WxEtlObject();
Begin
WxRect := ETLTask.Workspace.CreateRectangle();
WxRect.Id := ETLObject.Id;
WxETLObj.EtlObject := ETLObject;
WxRect.Style.TextPosition := WxTextPosition.wtpBottom;
WxRect.Style.PictureMarginTop := -10;
GxPointFCls.Create(XPosition, YPosition);
WxRect.PinPosition := GxPointFCls;
WxRect.Extension := WxETLObj As IWxShapeExtension;
End Sub;
After executing the example, a new data consumer is created in the ETL task that is linked with the specified table MDM dictionary.
See also: