UDFTransform247 Function

Number of input and output field

Number of input field : One or more
Number of output field : One or more

This Transformation Function is used to call a User-Defined Transformation (UDF Transformation).
The UDF must be implemented as a subclass of:
    com.solusi247.function.TransformationFunction247

Parameters Used by UDFTransform247

There are two parameters required when using a UDF Transformation:
  1. UDF Class Name
    The name of the class that extends:
        com.solusi247.function.TransformationFunction247
    
    Example:
        plugins.transform.UDFRotateTransform
    
  2. Parameter
    A parameter value that will be passed to the UDF class and can be accessed using the getParameter() method.

UDF Transformation Class Requirements

To create a custom transformation function, the class must:
  1. Extend the abstract class
        com.solusi247.function.TransformationFunction247
        
  2. Implement the following method
        public abstract List<Comparable> call(List<Comparable> record)
            
    This method:
    • Receives one input record
    • Processes the data
    • Returns a transformed record

Inherited Methods

A UDF transformation class also inherits several useful methods from:
    com.solusi247.function.TransformationFunction247

Supported Field Types

Input and output fields can use the following data types:
    FieldType.STRING
    FieldType.BYTE
    FieldType.SHORT
    FieldType.INT
    FieldType.LONG
    FieldType.FLOAT
    FieldType.DOUBLE
    FieldType.DATE
    FieldType.TIMESTAMP
    FieldType.OBJECT

Example: UDF Transformation Class

Below is an example of a transformation that reverses the characters of each field in a record.

Java Code Example
    package plugins.transform;

    import com.solusi247.function.TransformationFunction247;
    import java.util.ArrayList;
    import java.util.List;

    
    public class UDFRotateTransform extends TransformationFunction247{

        @Override
        public List<Comparable> call(List<Comparable> record) {
            List<Comparable> list=new ArrayList<Comparable>();
            for (int i=0; i<record.size(); i++){
                StringBuilder sb=new StringBuilder(record.get(i).toString());
                list.add(sb.reverse().toString());
            }

            return list;
        }
    }   

   

How This Transformation Works

Example input record:
    ["Jakarta", "HGrid247", "Data"]
Processing:
  1. "Jakarta" → "atrakaJ"
  2. "HGrid247" → "742dirGH"
  3. "Data" → "ataD"
Output record:
    ["atrakaJ", "742dirGH", "ataD"]

Deploying the UDF Transformation

To make the transformation appear in the HGrid247 GUI:
Step 1 — Compile the Java class
Compile the source file:
    UDFRotateTransform.java
Step 2 — Package into a JAR
Example:
    UDFRotateTransform.jar
Step 3 — Place in the plugins folder
    HGrid247-3.5/
    ├── plugins/
    │     └── UDFRotateTransform.jar
Step 4 — Restart HGrid247

After restarting, the UDF will appear in the Transformation Parameter dialog.



Required Dependency

Java-based plug-ins require the following library:
    HGrid247-3.5/
    ├── libCommon/
    │     └──  HGrid247CommonLib-3.5.jar