IEtlPlainDataConsumer.Consumer

Syntax

Consumer: IDtConsumer;

Description

The Consumer property returns export object.

Comments

According to the ETL task object type, cast the value of the Consumer property to one of the interfaces, for which IDtConsumer is basic, to set specific export options.

Example

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;
    Tab: IDatasetModel;
    Fields_ETL: IEtlPlainFields;
    Field: IEtlPlainField;
    FieldType: String;
    i, j: integer;
Begin
    // ETL task search. Repository object 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(2020);
    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, a repository data consumer will be created for the ETL task, input fields will be identical to fields of the specified consumer. After executing the example the console window displays information about data consumer input fields.

See also:

IEtlPlainDataConsumer