Creating a Simple Graph in a Few Simple Steps

After creating a new CloverETL graph, it is an empty pane. In order to create a non-empty graph, you must fill the empty graph with components and other graph elements. You need to select graph components, set up their properties (attributes), connect these components by edges, select data files and/or database tables that should be read or unloaded from, written or loaded to, create metadata describing data, assign them to edges, create database connections or JMS connections, create lookup tables and/or create sequences and parameters. Once all of it is done, you can run the graph.

If you want to know what edges, metadata, connections, lookup tables, sequences or parameters are, see Part V, Graph Elements, Structures and Tools for information.

Now we will present you a simple example of how CloverETL transformation graphs can be created using CloverETL Designer. We will try to make the explanation as clear as possible.

First, you need to select components from the Palette of Components.

To select any component, click the triangle on the upper right corner of the Graph Editor pane. The Palette of Components will open. Select the components you want by clicking and then drag-and-dropping them to the Graph Editor pane.

For our demonstration purposes, select UniversalDataReader from the Readers category of the Palette. Select also the ExtSort component from the Transformers category and UniversalDataWriter from the Writers category.

Components Selected from the Palette

Figure 10.6. Components Selected from the Palette


Once you have inserted the components to the Graph Editor pane, you need to connect them by edges. Select the Edge tool on the Palette and click the output port of one component and connect it with the input port of another by clicking again. Do the same with all selected components. The newly connected edges are still dashed. Close the Palette by clicking the triangle at its upper right corner. (See Chapter 18, Edges for more information about Edges.)

Components are Connected by Edges

Figure 10.7. Components are Connected by Edges


Now you need to prepare some input file. Move to the Navigator pane, which is on the left side of Eclipse window. Right-click the data-in folder of your project and select NewFile.

Creating an Input File

Figure 10.8. Creating an Input File


Once the new window appears, select the name of your input file in this window. For example, its name can be input.txt. Click Finish. The file will open in the Eclipse window.

Type some data in this file, for example, you can type pairs of firstname and surname like this: John|Brown. Type more rows whose form should be similar. Do not forget to create also a new empty row at the end. The rows (records) will look like this:

Creating the Contents of the Input File

Figure 10.9. Creating the Contents of the Input File


You need to save the file by pressing Ctrl+S.

After that, double-click the first edge from the left and select Create metadata from the menu that appears beside the edge. In the Metadata editor, click the green Plus sign button. Another (second) field appears. You can click any of the two fields and rename them. By clicking any of them, it turns blue, you can rename it and press Enter. (See Chapter 19, Metadata for more information about creating Metadata.)

Metadata Editor with Default Names of the Fields

Figure 10.10. Metadata Editor with Default Names of the Fields


After doing that, the names of the two fields will be Firstname and Surname, respectively.

Metadata Editor with New Names of the Fields

Figure 10.11. Metadata Editor with New Names of the Fields


After clicking Finish, metadata is created and assigned to the edge. The edge is solid now.

Edge Has Been Assigned Metadata

Figure 10.12. Edge Has Been Assigned Metadata


Now right-click the first edge and select Propagate metadata from the context menu. The second edge also becomes solid.

Metadata Have Been Propagated through the Component

Figure 10.13. Metadata Have Been Propagated through the Component


Now, double-click UniversalDataReader, click the File URL attribute row and click the button that appears in this File URL attribute row.

(You can see UniversalDataReader for more information about UniversalDataReader.)

Opening the Attribute Row

Figure 10.14. Opening the Attribute Row


After that, URL File Dialog will open. Double-click the data-in folder and double-click the input.txt file inside this folder. The file name appears in the right pane.

Selecting the Input File

Figure 10.15. Selecting the Input File


Then click OK. The File URL attribute row will look like this:

Input File URL Attribute Has Been Set

Figure 10.16. Input File URL Attribute Has Been Set


Click OK to close the UniversalDataReader editor.

Then, double click UniversalDataWriter.

(You can see UniversalDataWriter for more information about UniversalDataWriter.)

Click the File URL attribute row and click the button that appears in this File URL attribute row. After that, URL File Dialog will open. Double-click data-out folder. Then click OK. The File URL attribute row will look like this:

Output File URL without a File

Figure 10.17. Output File URL without a File


Click twice the File URL attribute row and type /output.txt there. The result will be as follows:

Output File URL with a File

Figure 10.18. Output File URL with a File


Click OK to close the UniversalDataWriter editor.

Now you only need to set up the ExtSort component.

(You can see ExtSort for more information about ExtSort.)

Double-click the component and its Sort key attribute row. After that, move the two metadata fields from the left pane (Fields) to the right pane (Key parts). Move Surname first, then move Firstname.

Defining a Sort Key

Figure 10.19. Defining a Sort Key


When you click OK, you will see the Sort key attribute row as follows:

Sort Key Has Been Defined

Figure 10.20. Sort Key Has Been Defined


Click OK to close the ExtSort editor and save the graph by pressing Ctrl+S.

Now right-click in any place of the Graph Editor (outside any component or edge) and select Run AsCloverETL graph.

(Ways how graphs can be run are described in Chapter 11, Running CloverETL Graphs.)

Running the Graph

Figure 10.21. Running the Graph


Once graph runs successfully, blue circles are displayed on the components and numbers of parsed records can be seen below the edges:

Result of Successful Run of the Graph

Figure 10.22. Result of Successful Run of the Graph


When you expand the data-out folder in the Navigator pane and open the output file, you can see the following contents of the file:

Contents of the Output File

Figure 10.23. Contents of the Output File


You can see that all persons have been sorted alphabetically. Surnames first, firstnames last. This way, you have built and run your first graph.