Runtime Data Mapping in Java
In Java Code
Creating a runtime data map in Java code requires a few steps:
- Create a new Map object, which will store the data mappings.
- Create your data map sources and targets.
- Link the sources and targets in the map.
- Set the runtime configuration on a flow (or, in some cases, node).
For step 2, you can use any combination of the variable manager sources and targets described below.
- Action properties, which can only be the target (not source) of a runtime data map, use the ActionPropertyTarget class. This class is created from the FlowChart object you are working with, by calling the following method:
workflow.makeActionPropertyTarget(String target);
The parameter “target” will be the name of the property you want to map. The property must begin with a capital letter and, for properties containing more than one word, each additional word should be capitalized. This method will throw an exception at runtime if the specified action property does not exist.
The following code could be used to set the “Sources” property of a File Copy Action:
workflow.makeActionProperty("Sources");
Or, to set the “Time Expression” on a Timer Trigger:
workflow.makeActionProperty("Timer Trigger");
- Flow Chart variables use either a FlowChartSource or FlowChartTarget, depending on whether they are the source or target of a mapping operation. They are created using the following methods:
workflow.makeFlowChartSource(String name);
workflow.makeFlowChartTarget(String name);
In either case, the property “name” is the name of the variable that will be used. For example:
workflow.makeFlowChartSource("MyVariable");
- Like flow chart variables, flow context variables use different classes for sources and targets: FlowContextSource and FlowContextTarget. They are created similarly to flow chart variables as well:
workflow.makeFlowContextSource(String name);
workflow.makeFlowContextTarget(String name);
Variables can also access fields of the objects they are mapping. For example:
workflow.makeFlowContextSource("RESULT.filename_matches");
- The runtime configuration variable manager is only available as the source of a data map, and cannot be used as a target. These can be created by calling:
workflow.makeRuntimeConfigurationSource(String name);
Where “name” is the name of the runtime variable to use. For example:
workflow.makeRuntimeConfigurationSource("MyRuntimeVariable");
Now that these basic classes have been introduced, let’s see how the actual data map is created.
First, we’ll create an empty Map, to store the runtime data map. Next, we’ll create the source and target we want to use, and place them in our map (here, we’re only using one source/target pair per data map, but you can add as many as you need). Finally, we’ll link the map to a flow by calling setRuntimeDataMap.