Variable Import Customization

Before implementing the plugin make sure that you have setup your environment.

This feature enables you to enrich or filter the variable import, e.g., if variables in Camunda contain only ids to variables in another database and you would like resolve those values to the actual values.

The Optimize plugin system contains the following interface:

public interface VariableImportAdapter {

  List<PluginVariableDto> adaptVariables(List<PluginVariableDto> variables);
}

Implement this to adjust the variables to be imported. Given is a list of variables that would be imported if no further action is performed. The returned list is the customized list with the enriched/filtered variables that will be imported. To create new variable instances, you can use the PluginVariableDto class as data transfer object (dto), which is also contained in the plugin system.

Please note that:

  • all dto class members need to be set in order, otherwise the variable is ignored, as this may lead to problems during data analysis.
  • the data from the engine is imported in batches. In particular you don’t get all the variables in one go, but the method is rather called once per batch. For instance, if you have 100 000 variables in total and the batch size is 10 000 then the plugin function will be called 10 times.

Next, package your plugin into a jar file and then add the jar file to the plugin folder of your Optimize directory. Finally, add the name of the base package of your custom VariableImportAdapter to the environment-config.yaml file:

plugin:
  variableImport:
    #Look in the given base package list for variable import adaption plugins.
    #If empty, the import is not influenced.
    basePackages: []

The following shows an example of a customization of the variable import in the package optimize.plugin, where every string variable is assigned the value ‘foo’:

package optimize.plugin;

import org.camunda.optimize.plugin.importing.variable.PluginVariableDto;
import org.camunda.optimize.plugin.importing.variable.VariableImportAdapter;

import java.util.List;

  public class MyCustomVariableImportAdapter implements VariableImportAdapter {

  @Override
  public List<PluginVariableDto> adaptVariables(List<PluginVariableDto> list) {
    for (PluginVariableDto pluginVariableDto : list) {
      if(pluginVariableDto.getType().toLowerCase().equals("string")) {
        pluginVariableDto.setValue("foo");
      }
    }
    return list;
  }

}

Now when ‘MyCustomVariableImportAdapter’, packaged as a jar file, is added to the plugin folder, we just have to add the following property to the environment-config.yaml file to make the plugin work:

plugin:
  variableImport:
    #Look in the given base package list for variable import adaption plugins.
    #If empty, the import is not influenced.
    basePackages: ["optimize.plugin"]

If you still don’t fully understand how the variable import customization works in detail, try to have a look at the Optimize Examples Repository.