About global variables
Global variables are used for parametrization. Read about global variables.
Set global variable using JavaScript
importPackage(com.toolsverse.config);
// props is a java.util.HashMap<String, String>
var props = SystemConfig.instance().getProperties();
// you can store strings in props
props.put("unique key", someObject);
Set global variable in parallel loop or transformation
This technique is used to set global variables in parallel loops and parallel transformations using a thread-safe container. These variables are only "visible" to the current ETL thread, so do not use this technique to set variables that can be accessed in other threads.
importPackage(com.toolsverse.config);
SystemConfig.instance().addPropertyInCurrentEtlThread(key, value);
Access a previously-stored global variable from JavaScript
importPackage(com.toolsverse.config);
// props is a java.util.HashMap<String, String>
var props = SystemConfig.instance().getProperties();
// use the same key you stored in props.put(...)
var obj = props.get("unique key");
Access global variable in parallel loop or transformation
This technique is used to access the value of the variable set in a parallel loop or parallel transformation. If the variable is not found in the current ETL thread this method will return the value set in the main thread.
importPackage(com.toolsverse.config);
// props is a java.util.HashMap<String, String>
var props = SystemConfig.instance().getContextProperties();
// use the same key you stored in props.put(...)
var obj = props.get("unique key");
Access a previously-stored global variable from transformation and Connection
To access the value of the previously stored global variable from the transformation
or from the Connection parameters,
use {global variable name}
. This will work equally well for variables set in the main thread and in the parallel loop or transformation.
Comments
0 comments
Please sign in to leave a comment.