Consumer: IDtConsumer;
The Consumer property returns import or export object.
Executing the example requires that the repository contains an ETL task with the ETL identifier and a table with the Table identifier.
Sub UserProc;
Var
Metabase: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlConsumer: IEtlPlainDataConsumer;
MBConsumer: IDtMetabaseConsumer;
i, j: integer;
Tab: IDatasetModel;
Fields_ETL: IEtlPlainFields;
Field: IEtlPlainField;
FieldType: String;
Begin
//Search for ETL task . Object of repository with the ETL identifier
Metabase := MetabaseClass.Active;
MObj := Metabase.ItemById("ETL").Edit;
EtlTask := MObj As IEtlTask;
If EtlTask.Workspace.Shapes.Count > 0 Then
j := EtlTask.Workspace.Shapes.Count - 1;
// Remove ETL task objects
For i := j To 0 Step - 1 Do
EtlTask.Workspace.Shapes.Item(i).Delete;
End For;
EtlTask.FindById("MB_Consumer").Remove;
End If;
Tab := Metabase.ItemById("Table").Bind As IDatasetModel;
//Create the Repository Consumer object
EtlConsumer := EtlTask.Create(EtlObjectType.PlainDataMetabaseConsumer) As IEtlPlainDataConsumer;
EtlConsumer := EtlConsumer.Edit;
EtlConsumer.Id := "MB_Consumer";
EtlConsumer.Name := Repository data consumer;
//Set up data consumer
MBConsumer := EtlConsumer.Consumer As IDtMetabaseConsumer;
MBConsumer.Dataset := Tab;
EtlConsumer.FillDefault;
Fields_ETL := EtlConsumer.PlainInput.Fields;
For i := 0 To Fields_ETL.Count - 1 Do
Field := Fields_ETL.Item(i);
FieldDataType(Field.DataType, FieldType);
Debug.WriteLine("--------------------------------------------");
Debug.WriteLine("Field : " + Field.Name);
Debug.WriteLine(" Type : " + FieldType);
Debug.WriteLine(" Size : " + Field.Size.ToString);
Debug.WriteLine(" Precision : " + Field.Precision.ToString);
Debug.WriteLine("--------------------------------------------");
End For;
EtlConsumer.Save;
//Create a visual object
CreateWX(EtlConsumer, EtlTask);
MObj.Save
End Sub UserProc;
Sub CreateWX(CopyObj: IEtlPlainDataConsumer; Etltask: IEtltask);
Var
WxDataTrans: IWxRectangle;
WxETLDataTrans: IWxEtlObject;
Begin
WxDataTrans := EtlTask.Workspace.CreateRectangle;
WxDataTrans.Id := CopyObj.Id;
WxETLDataTrans := New WxEtlObject.Create;
WxETLDataTrans.EtlObject := CopyObj;
WxDataTrans.Style.TextPosition := WxTextPosition.Bottom;
WxDataTrans.Style.PictureMarginTop := -10;
WxDataTrans.PinPosition := New GxPointF.Create(20, 20);
WxDataTrans.Extension := WxETLDataTrans As IWxShapeExtension;
End Sub CreateWX;
Sub FieldDataType(FieldDataType: DbDataType; Var FieldType: string); { Get field type name }
Begin
Select Case FieldDataType
Case DbDataType.NoData: FieldType := "NoData";
Case DbDataType.String: FieldType := "String";
Case DbDataType.Integer: FieldType := "Integer";
Case DbDataType.Float: FieldType := "Float";
Case DbDataType.DateTime: FieldType := "DateTime";
Case DbDataType.Blob: FieldType := "Blob";
Case DbDataType.Boolean: FieldType := "Boolean";
Case DbDataType.Date: FieldType := "Date";
End Select;
End Sub FieldDataType;
After executing the UserProc procedure for ETL task, repository data consumer is created, input fields are identical with fields of the specified consumer (table with the Table identifier). While executing the example information about consumer input fields are displayed in the console window.
See also: