Talend routines

Talend routines are very useful when you want to write code once and which can be called many times from the same job and more than one jobs.

  1. Reusable pieces of Java code
  2. Custom code in Java to optimize data processing
  3. Improve Job capacity
  4. Extend Talend Studio features

There are two types of routines

  1. System routines (read only) – System routines are classified according to the type of data they process, such as: numerical, string, date
    To access the system routines, click Code > Routines > system
    Screenshot 2016-01-09 02.06.36
  2. User routines – User routines is created by user routines to add custom functionality to Talend Studio.
    Below is the example of User routine which will convert any String into camel case String.

    package routines;
    
    public class ProductUtil {
     public static String toCamelCase(String inputString) {
            String result = "";
            if (inputString.length() == 0) {
                return result;
            }
            char firstChar = inputString.charAt(0);
            char firstCharToUpperCase = Character.toUpperCase(firstChar);
            result = result + firstCharToUpperCase;
            for (int i = 1; i < inputString.length(); i++) {
                char currentChar = inputString.charAt(i);
                char previousChar = inputString.charAt(i - 1);
                if (previousChar == ' ') {
                    char currentCharToUpperCase = Character.toUpperCase(currentChar);
                    result = result + currentCharToUpperCase;
                } else {
                    char currentCharToLowerCase = Character.toLowerCase(currentChar);
                    result = result + currentCharToLowerCase;
                }
            }
            return result;
        }
    }

    Screenshot 2015-12-07 03.29.49

You can call any of your user and system routines from your Job components in order to run them at the same time as your Job.

Like I am calling User routine in tmap expression using

<routine_name>.<method_name>

ProductUtil.toCamelCase(row1.CUST_FIRST_NAME)

Screenshot 2016-01-09 03.22.26

Advertisements

One Comment Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s