IEtlFixedCodeBlock.Template

Syntax

Template: IEtlTemplate;

Description

The Template property determines a template, based on which a custom procedure is created.

Comments

The custom procedure templates are stored in the ISharedParams.EtlTemplates collection.

Example

Executing the example requires that the repository contains an ETL task with the ETL_TASK identifier. The repository should also contains a unit with the M_ETLPROCEDURE identifier. The unit contains the UserProcedure class that implements methods of the IEtlCustomCodeBlock interface.

Add links to the Andy, Drawing, Etl, Fore, Metabase, and XML system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Params: ISharedParams;
    Templates: IEtlTemplates;
    Template: IEtlTemplate;
    EtlTask: IEtlTask;
    Etl: IEtlFixedCodeBlock;
    XmlDoc: IXmlDomDocument3;
    XmlElement, SubElement: IXmlDomElement;
    Rect: IWxRectangle;
    WxETL: IWxEtlObject;
Begin
    MB := MetabaseClass.Active;
    // Create a custom procedure template
    Params := MB.SpecialObject(MetabaseSpecialObject.SharedParams).Edit As ISharedParams;
    Templates := Params.EtlTemplates(ETLTemplateType.CodeBlock);
    Template := Templates.Add;
    Template.Module := MB.ItemById("M_ETLPROCEDURE");
    Template.Class_ := "UserProcedure";
    Template.Id := "NewCodeBlock";
    Template.Name := "Custom procedure (template)";
    (Params As IMetabaseObject).Save;
    // ETL  task
    EtlTask := MB.ItemById("ETL_TASK").Edit As IEtlTask;
    // Create a custom procedure based on template
    Etl := EtlTask.Create(EtlObjectType.FixedCodeBlock) As IEtlFixedCodeBlock;
    Etl.Id := "PlainFixedCodeBlock";
    Etl.Name := "Template-based procedure";
    Etl.Template := Template;
    XmlDoc := New FreeThreadedDOMDocument60.Create;
    XmlElement := XmlDoc.createElement("UserData"As IXmlDomElement;
    SubElement := XmlDoc.createElement("Info");
    SubElement.setAttribute("Version""1");
    SubElement.setAttribute("Date", DateTime.Today.ToString);
    XmlElement.appendChild(SubElement);
    SubElement := XmlDoc.createElement("Data");
    SubElement.setAttribute("Prop1""Value1");
    SubElement.setAttribute("Prop2""Value2");
    XmlElement.appendChild(SubElement);
    XmlDoc.appendChild(XmlElement);
    Etl.UserData := XMLDoc.documentElement;
    // Procedure visualization
    Rect := EtlTask.Workspace.CreateRectangle;
    WxETL := New WxEtlObject.Create;
    WxETL.EtlObject := Etl;
    Rect.Style.TextPosition := WxTextPosition.Bottom;
    Rect.Style.PictureMarginTop := -10;
    Rect.PinPosition := New GxPointF.Create(5050);
    Rect.Extension := WxETL As IWxShapeExtension;
    // Save changes
    (EtlTask As IMetabaseObject).Save;
End Sub UserProc;

After executing the example, a new template for procedures will be created and set up in the ETL task. A new custom procedure will be created based on this template in the ETL task workspace. Main settings and a set of custom data in the XML format will be determined for the procedure.

See also:

IEtlFixedCodeBlock