Customer Portal

Parsing transform code programmatically

Comments 2

  • Avatar
    admin
    0
    Comment actions Permalink
    Hi jasonq323,

    easier alternative is to store code of transformation (same code as you see in transformation editor, including initial //CTL2 comment) into file, then exec second graph, where transformation file is referred via "Transform URL" property.
  • Avatar
    jasonq323
    0
    Comment actions Permalink
    Hi,

    Thanks for the hint.

    Managed to breakpoint through a file load to see that a function can be loaded via the transform string of a Transform Node as well.

    // Create transformation ports for the joiner
    // These are transform function code in CTL2 that will be parsed
    // Need to understand how to store this in database
    String transformFunction = new StringBuilder()
    .append("//#CTL2 \n")
    .append("// Transforms input record into output record. \n")
    .append("function integer transform() { \n")
    .append("$out.0.RicFeed1 = $in.0.Ric; \n")
    .append("$out.0.TickerFeed1 = $in.0.Ticker; \n")
    .append("$out.0.BloombergFeed1 = $in.0.Bloomberg; \n")
    .append("$out.0.AssetclassFeed1 = $in.0.Assetclass; \n")
    .append("$out.0.RicFeed2 = $in.1.Ric; \n")
    .append("$out.0.TickerFeed2 = $in.1.Ticker; \n")
    .append("$out.0.BloombergFeed2 = $in.1.Bloomberg; \n")
    .append("$out.0.AssetclassFeed2 = $in.1.Assetclass; \n")
    .append("return OK; \n")
    .append("} \n")
    .append("// Called during component initialization. \n")
    .append("// function boolean init() {} \n")
    .append("// Called during each graph run before the transform is executed. May be used to allocate and initialize resources \n")
    .append("// required by the transform. All resources allocated within this method should be released \n")
    .append("// by the postExecute() method. \n")
    .append("// function void preExecute() {} \n")
    .append("// Called only if transform() throws an exception. \n")
    .append("// function integer transformOnError(string errorMessage, string stackTrace) {} \n")
    .append("// Called during each graph run after the entire transform was executed. Should be used to free any resources \n")
    .append("// allocated within the preExecute() method. \n")
    .append("// function void postExecute() {} \n")
    .append("// Called to return a user-defined error message when an error occurs. \n")
    .append("// function string getMessage() {} \n")
    .toString();

    Node nodeJoiner = new HashJoin("HashJoin", "$Ticker=$Ticker", transformFunction, null, null, Join.FULL_OUTER);

Please sign in to leave a comment.