Using the Dictionary in a Graph

The dictionary can be accessed in multiple ways by various components in the graph. It can be accessed from:

Readers and Writers. Both of them support dictionaries as their data source or data target via their File URL attribute.

The dictionary can also be accessed with CTL or Java source code in any component that defines a transformation (all Joiners, Reformat, Normalizer, etc).

Accessing the Dictionary from Readers and Writers

To reference the dictionary parameter in the File URL attribute of a graph component, this attribute must have the following form: dict:<Parameter name>[:processingType]. Depending on the type of the parameter in the dictionary and the processingType, the value can be used either as a name of the input or output file or it can be used directly as data source or data target (in other words, the data will be read from or written to the parameter directly).

Processing types are the following:

  1. For Readers

    • discrete

      This is the default processing type, needs not be specified.

    • source

    See also Reading from Dictionary for information about URL in Readers.

  2. For Writers

    • stream

      This is the default processing type, needs not be specified.

    • discrete

    See also Writing to Dictionary for information about URL in Writers.

For example, dict:mountains.csv can be used as either input or output in a Reader or a Writer, respectively (in this case, the property type is writable.channel).

Accessing the Dictionary with Java

To access the values from the Java code embedded in the components of a graph, methods of the org.jetel.graph.Dictionary class must be used.

For example, to get the value of the heightMin property, you can use a code similar to the following snippet:

getGraph().getDictionary().getValue("heightMin")

In the snippet above, you can see that we need an instance of TransformationGraph, which is usually available via the getGraph() method in any place where you can put your own code. The current dictionary is then retrieved via the getDictionary() method and finally the value of the property is read by calling the getValue(String) method.

[Note]Note

For further information check out the JavaDoc documentation.

Accessing the Dictionary with CTL2

If the dictionary entries should be used in CTL2, they must be defined in the graph. Working with the entries uses standard CTL2 syntax. No dictionary functions are available in CTL2.

For more information see Dictionary in CTL2.

Accessing the Dictionary with CTL1

Dictionary can be accessed from CTL1 using a set of functions for entries of string data type.

Even if the dictionary entries should be used in CTL1, they do not need to be defined in the graph.

For more information see Dictionary Functions.