Template: IEtlTemplate;
Template: Prognoz.Platform.Interop.KeFore.IEtlTemplate;
The Template property determines a user provider template.
The template is used to set user algorithm appearance on the desktop.
Executing the example requires that the repository contains:
A unit with the USERSCLASSFORETL identifier that contains the User class for implementing required interfaces.
An ETL task with the ETL_TASK identifier.
Add links to the Andy, Drawing, Etl, Fore, Metabase system assemblies.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
FixedUserProvider: IEtlPlainDataFixedUserProvider;
FixedUserConsumer: IEtlPlainDataFixedUserConsumer;
Paramss: ISharedParams;
Templates: IEtlTemplates;
Template: IEtlTemplate;
Begin
// Get repository
MB := MetabaseClass.Active;
// Get ETL task
MObj := MB.ItemById("ETL_TASK").Edit;
EtlTask := MObj As IEtlTask;
//Create the Custom Provider object
FixedUserProvider := EtlTask.Create(EtlObjectType.PlainDataFixedUserProvider) As IEtlPlainDataFixedUserProvider;
// Use template
Paramss := MB.SpecialObject(MetabaseSpecialObject.SharedParams).Edit As ISharedParams;
Templates := Paramss.EtlTemplates(ETLTemplateType.Provider);
Template := Templates.Add;
Template.Module := mb.ItemById("USERSCLASSFORETL");
Template.Class_ := "User";
Template.Id := "TemplateProv";
Template.Name := "TemplNameP";
FixedUserProvider.Template := Template;
(Paramss As IMetabaseObject).Save;
// Set mode for provider
FixedUserProvider.ExMode := True;
// Set source name
FixedUserProvider.Name := "User provider";
// Visual representation of source in task
CreateWXP(FixedUserProvider, EtlTask);
//Create the Custom Consumer object
FixedUserConsumer := EtlTask.Create(EtlObjectType.PlainDataFixedUserConsumer) As IEtlPlainDataFixedUserConsumer;
// Use template
Paramss := MB.SpecialObject(MetabaseSpecialObject.SharedParams).Edit As ISharedParams;
Templates := Paramss.EtlTemplates(ETLTemplateType.Consumer);
Template := Templates.Add;
Template.Module := mb.ItemById("USERSCLASSFORETL");
Template.Class_ := "User";
Template.Id := "TemplateCons";
Template.Name := "TemplNameC";
FixedUserProvider.Template := Template;
(Paramss As IMetabaseObject).Save;
// Set single mode for consumer
FixedUserConsumer.ExMode := True;
// Set consumer name
FixedUserConsumer.Name := "User consumer";
// Visual representation of consumer in task
CreateWXC(FixedUserConsumer, EtlTask);
// Save changes
Mobj.Save;
End Sub UserProc;
// Create a visual object of data source
Sub CreateWXP(CopyObj: IEtlPlainDataProvider; 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 CreateWXP;
// Create a visual object of data consumer
Sub CreateWXC(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(40, 40);
WxDataTrans.Extension := WxETLDataTrans As IWxShapeExtension;
End Sub CreateWXC;
After executing the example data provider and data consumer are created based on template.
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.Drawing;
Imports Prognoz.Platform.Interop.Etl;
Imports Prognoz.Platform.Interop.KeFore;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
FixedUserProvider: IEtlPlainDataFixedUserProvider;
FixedUserConsumer: IEtlPlainDataFixedUserConsumer;
Paramss: ISharedParams;
Templates: IEtlTemplates;
Template: IEtlTemplate;
Begin
// Get repository
MB := Params.Metabase;
// Get ETL task
MObj := MB.ItemById["ETL_TASK"].Edit();
EtlTask := MObj As IEtlTask;
//Create the Custom Provider object
FixedUserProvider := EtlTask.Create(EtlObjectType.eotPlainDataFixedUserProvider) As IEtlPlainDataFixedUserProvider;
// Use template
Paramss := MB.SpecialObject[MetabaseSpecialObject.msoSharedParams].Edit() As ISharedParams;
Templates := Paramss.EtlTemplates[ETLTemplateType.etlttProvider];
Template := Templates.Add();
Template.Module := MB.ItemById["USERSCLASSFORETL"];
Template.@Class := "User";
Template.Id := "TemplateProv";
Template.Name := "TemplNameP";
FixedUserProvider.Template := Template;
(Paramss As IMetabaseObject).Save();
// Set mode for provider
FixedUserProvider.ExMode := True;
// Set source name
FixedUserProvider.Name := "User provider";
// Visual representation of source in task
CreateWXP(FixedUserProvider, EtlTask);
//Create the Custom Consumer object
FixedUserConsumer := EtlTask.Create(EtlObjectType.eotPlainDataFixedUserConsumer) As IEtlPlainDataFixedUserConsumer;
// Use template
Paramss := MB.SpecialObject[MetabaseSpecialObject.msoSharedParams].Edit() As ISharedParams;
Templates := Paramss.EtlTemplates[ETLTemplateType.etlttConsumer];
Template := Templates.Add();
Template.Module := MB.ItemById["USERSCLASSFORETL"];
Template.@Class := "User";
Template.Id := "TemplateCons";
Template.Name := "TemplNameC";
FixedUserProvider.Template := Template;
(Paramss As IMetabaseObject).Save();
// Set single mode for consumer
FixedUserConsumer.ExMode := True;
// Set consumer name
FixedUserConsumer.Name := "User consumer";
// Visual representation of consumer in task
CreateWXC(FixedUserConsumer, EtlTask);
// Save changes
Mobj.Save();
End Sub;
// Create a visual object of data source
Public Shared Sub CreateWXP(CopyObj: IEtlPlainDataProvider; Etltask: IEtltask);
Var
WxDataTrans: IWxRectangle;
WxETLDataTrans: IWxEtlObject = New WxEtlObjectClass();
PointF: GxPointF = New GxPointFClass();
Begin
WxDataTrans := EtlTask.Workspace.CreateRectangle();
WxDataTrans.Id := CopyObj.Id;
//WxETLDataTrans := New WxEtlObject.Create;
WxETLDataTrans.EtlObject := CopyObj;
WxDataTrans.Style.TextPosition := WxTextPosition.wtpBottom;
WxDataTrans.Style.PictureMarginTop := -10;
WxDataTrans.PinPosition := PointF;
PointF.Create(20, 20);
WxDataTrans.Extension := WxETLDataTrans As IWxShapeExtension;
End Sub CreateWXP;
// Create a visual object of data consumer
Public Shared Sub CreateWXC(CopyObj: IEtlPlainDataConsumer; Etltask: IEtltask);
Var
WxDataTrans: IWxRectangle;
WxETLDataTrans: IWxEtlObject = New WxEtlObjectClass();
PointF: GxPointF = New GxPointFClass();
Begin
WxDataTrans := EtlTask.Workspace.CreateRectangle();
WxDataTrans.Id := CopyObj.Id;
//WxETLDataTrans := New WxEtlObject.Create;
WxETLDataTrans.EtlObject := CopyObj;
WxDataTrans.Style.TextPosition := WxTextPosition.wtpBottom;
WxDataTrans.Style.PictureMarginTop := -10;
WxDataTrans.PinPosition := PointF;
PointF.Create(20, 20);
WxDataTrans.Extension := WxETLDataTrans As IWxShapeExtension;
End Sub CreateWXC;
See also: