Table of Contents

Search

  1. Preface
  2. Working with Transformations
  3. Aggregator Transformation
  4. Custom Transformation
  5. Custom Transformation Functions
  6. Data Masking Transformation
  7. Data Masking Examples
  8. Expression Transformation
  9. External Procedure Transformation
  10. Filter Transformation
  11. HTTP Transformation
  12. Identity Resolution Transformation
  13. Java Transformation
  14. Java Transformation API Reference
  15. Java Expressions
  16. Java Transformation Example
  17. Joiner Transformation
  18. Lookup Transformation
  19. Lookup Caches
  20. Dynamic Lookup Cache
  21. Normalizer Transformation
  22. Rank Transformation
  23. Router Transformation
  24. Sequence Generator Transformation
  25. Sorter Transformation
  26. Source Qualifier Transformation
  27. SQL Transformation
  28. Using the SQL Transformation in a Mapping
  29. Stored Procedure Transformation
  30. Transaction Control Transformation
  31. Union Transformation
  32. Unstructured Data Transformation
  33. Update Strategy Transformation
  34. XML Transformations

Transformation Guide

Transformation Guide

On Input Row Tab

On Input Row Tab

The Java transformation executes the Java code in the On Input Row tab when the transformation receives an input row. In this example, the transformation may or may not generate an output row, based on the values of the input row.
Enter the following code in the On Input Row tab:
// Initially set generateRow to true for each input row. generateRow = true; // Initially set isRoot to false for each input row. isRoot = false; // Check if input employee id and name is null. if (isNull ("EMP_ID_INP") || isNull ("EMP_NAME_INP")) {      incrementErrorCount(1);      // If input employee id and/or name is null, don't generate a output      // row for this input row.      generateRow = false; } else {      // Set the output port values.      EMP_ID_OUT = EMP_ID_INP;      EMP_NAME_OUT = EMP_NAME_INP; } if (isNull ("EMP_DESC_INP")) {      setNull("EMP_DESC_OUT"); } else {      EMP_DESC_OUT = EMP_DESC_INP; } boolean isParentEmpIdNull = isNull("EMP_PARENT_EMPID"); if(isParentEmpIdNull) {      // This employee is the root for the hierarchy.      isRoot = true;      logInfo("This is the root for this hierarchy.");      setNull("EMP_PARENT_EMPNAME"); } synchronized(lock) {      // If the employee is not the root for this hierarchy, get the      // corresponding parent id.      if(!isParentEmpIdNull)           EMP_PARENT_EMPNAME = (String) (empMap.get(new Integer (EMP_PARENT_EMPID)));      // Add employee to the map for future reference.      empMap.put (new Integer(EMP_ID_INP), EMP_NAME_INP); } // Generate row if generateRow is true. if(generateRow)      generateRow();

0 COMMENTS

We’d like to hear from you!