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.
- Reusable pieces of Java code
- Custom code in Java to optimize data processing
- Improve Job capacity
- Extend Talend Studio features
There are two types of routines
- 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
- 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; } }
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)
One Comment Add yours