Loader: Object;
Loader: Object;
The Loader property returns cube data loader parameters.
The property returns parameters of the loader described by the ICubeLoaderFromSource interface. Determine the following in the obtained loader:
If cube dimensions are based on MDM dictionaries, specify the ICubeLoaderFromSource.RdsDatabase property.
In the ICubeLoaderFromSource.Database property specify the database, in which a table for storing cube data is created.
If loading is performed to the current cube, specify the ICubeLoaderFromSource.Cube property. On creating a new cube the ICubeLoaderFromSource.Cube property is not specified, use the CreateInfo property to determine information about a created cube. If the CreateInfo property is not determined, all information about the created cube is generated automatically.
Use the ICubeLoaderFromSource.Init method initialize the bindings of dimensions determining as a parameter the Source source. Created bindings can be edited, if required, in the ICubeLoaderFromSource.DimensionBindings nbsp;andnbsp; ICubeLoaderFromSource.FactBindings properties.
Executing the example requires that the repository contains an ETL task with the ETL_Task identifier. A provider with the PLAINDATAMETABASEPROVIDER1 identifier is created in the task. The repository also contains the F_Cubes folder and the DB database.
Sub UserProc;
Var
MB: IMetabase;
ETLTask: IEtlTask;
EtlConsumer: IEtlPlainDataConsumer;
EtlProvider: IEtlPlainDataProvider;
ConsumerIn: IEtlPlainInput;
ProviderOut: IEtlPlainOutput;
DtCube: IDtCubeConsumer;
Loader: ICubeLoaderFromSource;
Link: IEtlPlainLink;
Shapes: IWxShapes;
Begin
MB := MetabaseClass.Active;
ETLTask := MB.ItemById("ETL_Task").Edit As IEtlTask;
//Create new consumer - cube consumer
EtlConsumer := ETLTask.Create(EtlObjectType.PlainDataCubeConsumer) As IEtlPlainDataConsumer;
EtlConsumer := EtlConsumer.Edit;
EtlConsumer.ClearConsumer := True;
EtlConsumer.Id := "CUBE_Consumer";
EtlConsumer.Name := "Cube consumer";
//Create a consumer visual object
CreateWX(ETLTask, EtlConsumer, 0, 0);
//Set up consumer
DtCube := EtlConsumer.Consumer As IDtCubeConsumer;
//Information about a created cube
Loader := DtCube.Loader As ICubeLoaderFromSource;
Loader.Type := CubeLoaderType.Cube;
Loader.Database := MB.ItemById("DB").Open(Null) As IDatabaseInstance;
Loader.Parent := MB.ItemById("F_Cubes").Bind;
//Provider with which consumer will linked
EtlProvider := ETLTask.FindById("PLAINDATAMETABASEPROVIDER1") As IEtlPlainDataProvider;
Loader.Init(EtlProvider.Provider);
//Compare provider and consumer fields
ConsumerIn := EtlConsumer.PlainInput;
ProviderOut := EtlProvider.PlainOutput;
FillFields(ConsumerIn.Fields, ProviderOut.Fields);
//Save consumer
EtlConsumer.Save;
//Create a link
Link := CreateLink(ETLTask, ProviderOut, ConsumerIn);
//Create visual links
Shapes := ETLTask.Workspace.Shapes;
CreateWXLink(ETLTask, Shapes.FindById(EtlProvider.Id), Shapes.FindById(EtlConsumer.Id), Link);
//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;
//Compare the lists of input/output fields
Sub FillFields(Fields, FieldsSource: IEtlPlainFields);
Begin
Fields := Fields.Edit;
Fields.Fill(FieldsSource);
Fields.Save;
End Sub FillFields;
//Create a link between objects
Function CreateLink(ETLTask: IEtlTask; Output: IEtlPlainOutput; Input: IEtlPlainInput): IEtlPlainLink;
Var
Link: IEtlPlainLink;
Begin
Link := ETLTask.CreatePlainLink;
Link.SourceObjectOutput := Output;
Link.DestinationObjectInput := Input;
Link.FillDefault;
Return Link;
End Function CreateLink;
//Create visual links
Sub CreateWXLink(ETLTask: IEtlTask; Shape1: IWxShape; Shape2: IWxShape; Link: IEtlPlainLink);
Var
WLink: IWxLink;
WxETLLink: IWxEtlObject;
Begin
//Create visual link objects
WLink := ETLTask.Workspace.AutoLinkShapes(Shape1, Shape2);
WLink.Style.LinePenBeginWxCap := WxLineCap.Flat;
WLink.Style.LinePenEndWxCap := WxLineCap.Arrow30DegreeFilled;
WxETLLink := New WxEtlObject.Create;
WxETLLink.EtlObject := Link;
WLink.Extension := WxETLLink As IWxShapeExtension;
End Sub CreateWXLink;
A new consumer is created in the ETL task on executing the example. The consumer will export data to a new repository cube. Cube structure is created automatically based on the information about fields of the source, with which the consumer is linked. All required visual objects are created in the ETL task.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Andy;
Imports Prognoz.Platform.Interop.Cubes;
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;
EtlProvider: IEtlPlainDataProvider;
ConsumerIn: IEtlPlainInput;
ProviderOut: IEtlPlainOutput;
DtCube: IDtCubeConsumer;
Loader: ICubeLoaderFromSource;
Link: IEtlPlainLink;
Shapes: IWxShapes;
Begin
MB := Params.Metabase;
ETLTask := mb.ItemById["ETL_Task"].Edit() As IEtlTask;
//Create a new consumer - cube consumer
EtlConsumer := ETLTask.Create(EtlObjectType.eotPlainDataCubeConsumer) As IEtlPlainDataConsumer;
EtlConsumer := EtlConsumer.Edit();
EtlConsumer.ClearConsumer := True;
EtlConsumer.Id := "CUBE_Consumer";
EtlConsumer.Name := "Cube consumer";
//Create a consumer visual object
CreateWX(ETLTask, EtlConsumer, 0, 0);
//Set up consumer
DtCube := EtlConsumer.Consumer As IDtCubeConsumer;
//Information about a created cube
Loader := DtCube.Loader As ICubeLoaderFromSource;
Loader.Type := CubeLoaderType.cltCube;
Loader.Database := MB.ItemById["DB"].Open(Null) As IDatabaseInstance;
Loader.Parent := MB.ItemById["F_Cubes"].Bind();
//Provider with which consumer will linked
EtlProvider := ETLTask.FindById("PLAINDATAMETABASEPROVIDER1") As IEtlPlainDataProvider;
Loader.Init(EtlProvider.Provider);
//Compare provider and consumer fields
ConsumerIn := EtlConsumer.PlainInput;
ProviderOut := EtlProvider.PlainOutput;
FillFields(ConsumerIn.Fields, ProviderOut.Fields);
//Save consumer
EtlConsumer.Save();
//Create a link
Link := CreateLink(ETLTask, ProviderOut, ConsumerIn);
//Create visual links
Shapes := ETLTask.Workspace.Shapes;
CreateWXLink(ETLTask, Shapes.FindById(EtlProvider.Id), Shapes.FindById(EtlConsumer.Id), Link);
//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;
//Create visual links
Public Shared Sub CreateWXLink(ETLTask: IEtlTask; Shape1: IWxShape; Shape2: IWxShape; Link: IEtlPlainLink);
Var
WLink: IWxLink;
WxETLLink: IWxEtlObject = New WxEtlObject();
Begin
//Create visual link objects
WLink := ETLTask.Workspace.AutoLinkShapes(Shape1, Shape2);
WLink.Style.LinePenBeginWxCap := WxLineCap.wlcFlat;
WLink.Style.LinePenEndWxCap := WxLineCap.wlcArrow30DegreeFilled;
WxETLLink.EtlObject := Link;
WLink.Extension := WxETLLink As IWxShapeExtension;
End Sub;
//Compare the lists of input/output fields
Public Shared Sub FillFields(Fields, FieldsSource: IEtlPlainFields);
Begin
Fields := Fields.Edit();
Fields.Fill(FieldsSource);
Fields.Save();
End Sub;
//Create a link between objects
Public Shared Function CreateLink(ETLTask: IEtlTask; Output: IEtlPlainOutput; Input: IEtlPlainInput): IEtlPlainLink;
Var
Link: IEtlPlainLink;
Begin
Link := ETLTask.CreatePlainLink();
Link.SourceObjectOutput := Output;
Link.DestinationObjectInput := Input;
Link.FillDefault();
Return Link;
End Function;
See also: