Scenario 1: Generating data flow - 6.3

Talend Components Reference Guide

EnrichVersion
6.3
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

This scenario describes a two-components Job that generates a three-line data flow describing different personal titles (Miss, Mrs, and Mr) and displaying them on the console.

Setting up the Job

  1. Drop tJavaFlex and tLogRow from the Palette onto the design workspace.

  2. Connect the components together using a Row > Main link.

Configuring the tJavaFlex component

  1. Double-click tJavaFlex to display its Basic settings view and define its properties.

  2. Click the three-dot button next to Edit schema to open the corresponding dialog box where you can define the data structure to pass to the component that follows.

  3. Click the [+] button to add two columns: key and value and then set their types to Integer and String respectively.

  4. Click OK to validate your changes and close the dialog box.

  5. In the Basic settings view of tJavaFlex, select the Data Auto Propagate check box to automatically propagate data to the component that follows.

    In this example, we do not want to do any transformation on the retrieved data.

  6. In the Start code field, enter the code to be executed in the initialization phase.

    In this example, the code indicates the initialization of tJavaFlex by displaying the START message and sets up the loop and the variables to be used afterwards in the Java code:

    System.out.println("## START\n#");
    String [] valueArray = {"Miss", "Mrs", "Mr"};
    
    for (int i=0;i<valueArray.length;i++) {

  7. In the Main code field, enter the code you want to apply on each of the data rows.

    In this example, we want to display each key with its value:

    row1.key = i;
    row1.value = valueArray[i];

    Warning

    In the Main code field, "row1" corresponds to the name of the link that comes out of tJavaFlex. If you rename this link, you have to modify the code of this field accordingly.

  8. In the End code field, enter the code that will be executed in the closing phase.

    In this example, the brace (curly bracket) closes the loop and the code indicates the end of the execution of tJavaFlex by displaying the END message:

    }
    System.out.println("#\n## END");

  9. If needed, double-click tLogRow and in its Basic settings view, click the [...] button next to Edit schema to make sure that the schema has been correctly propagated.

Saving and executing the Job

  1. Save your Job by pressing Ctrl+S.

  2. Execute the Job by pressing F6 or clicking Run on the Run tab.

    The three personal titles are displayed on the console along with their corresponding keys.