Configuring the Reformat component for precedence rules

A Reformat component is used to transform incoming configuration data into a precedenceRule record.

The transformation is done by this CTL function in the Reformat component:
function integer transform() {
   string prRecord = "";
   string isLeaf = "";

   // Begin building the precedenceRule record
   prRecord = "<mdex:precedenceRule ";
   // Add the name of the rule.
   prRecord = prRecord + "key='" + $0.Key + "' ";
   // Add the name of the trigger attribute
   prRecord = prRecord + "triggerAttributeKey='" + $0.TriggerAttribute + "' ";

   // Add mval or pval trigger value only if present in the input file
   if ($0.TriggerValue != null && !$0.TriggerValue.isBlank()) {
      prRecord = prRecord + "triggerAttributeValue='" + $0.TriggerValue + "' ";
   }
	
   // Add the name of the target attribute
   prRecord = prRecord + "targetAttributeKey='" + $0.TargetAttribute + "' ";

   // Add the boolean that specifies if the trigger is a leaf
   // Lower case the boolean in the CSV file
   isLeaf = lowerCase($0.isLeafTrigger);
   prRecord = prRecord + "isLeafTrigger='" + isLeaf + "'/>";

   // Append the record to the xmlString variable, which stores all the rules 
   $0.xmlString = prRecord;

   return ALL;
}

When it runs, the component will build one or more precedenceRule elements and send them in the xmlString property to the WebServiceClient component in the graph.

To configure the Reformat component in the precedence rules graph:

  1. In the Graph window, double-click the Reformat component. The Reformat Edit Component dialog is displayed.

  2. Single-click in the Transform field and then click the ... button. The Transform editor is displayed.
  3. Click the Source tab in the editor. The CTL template for the transform function is shown.

  4. Modify the CTL script so that it looks like the example above. You may see the message "Cannot write to output port '0'" at the bottom of the editor. Assuming you have not made any coding errors, you may disregard the message for now.
  5. When you have finished your edits, click OK. If you see the error "Transformation contains syntax errors! Accept it anyway?" in a pop-up message, click Yes.
  6. Optionally, you can use the Component name field to provide a customized name (such as "Transform Precedence Rules") for this component.
  7. Click OK to apply your configuration changes.
  8. Save the graph.

The two messages listed above should disappear once you configure the Reformat component Edge metadata.