This interface allows custom steps to talk to Kettle. The StepMetaInterface is the main Java interface that a plugin
implements. The responsibilities of the implementing class are listed below:
- Keep track of the step settings
The implementing class typically keeps track of step settings using
private fields with corresponding getters and setters. The dialog class implementing StepDialogInterface is using the
getters and setters to copy the user supplied configuration in and out of the dialog.
The following interface methods also fall into the area of maintaining settings:
void setDefault()
This method is called every time a new step is created and should allocate or set the step configuration to sensible
defaults. The values set here will be used by Spoon when a new step is created. This is often a good place to ensure
that the step’s settings are initialized to non-null values. Null values can be cumbersome to deal with in
serialization and dialog population, so most PDI step implementations stick to non-null values for all step settings.
public Object clone()
This method is called when a step is duplicated in Spoon. It needs to return a deep copy of this step meta object. It
is essential that the implementing class creates proper deep copies if the step configuration is stored in modifiable
objects, such as lists or custom helper objects. See org.pentaho.di.trans.steps.rowgenerator.RowGeneratorMeta.clone()
for an example on creating a deep copy.
-
Serialize step settings
The plugin needs to be able to serialize its settings to both XML and a PDI repository. The interface methods are as
follows.
public String getXML()
This method is called by PDI whenever a step needs to serialize its settings to XML. It is called when saving a
transformation in Spoon. The method returns an XML string, containing the serialized step settings. The string
contains a series of XML tags, typically one tag per setting. The helper class org.pentaho.di.core.xml.XMLHandler is
typically used to construct the XML string.
public void loadXML(...)
This method is called by PDI whenever a step needs to read its settings from XML. The XML node containing the step's
settings is passed in as an argument. Again, the helper class org.pentaho.di.core.xml.XMLHandler is typically used to
conveniently read the step settings from the XML node.
public void saveRep(...)
This method is called by PDI whenever a step needs to save its settings to a PDI repository. The repository object
passed in as the first argument provides a convenient set of methods for serializing step settings. The
transformation id and step id passed in should be used by the step as identifiers when calling the repository
serialization methods.
public void readRep(...)
This method is called by PDI whenever a step needs to read its configuration from a PDI repository. The step id given
in the arguments should be used as the identifier when using the repositories serialization methods.
-
Provide instances of other plugin classes
The StepMetaInterface plugin class is the main class tying in with the rest of PDI architecture. It is responsible
for supplying instances of the other plugin classes implementing StepDialogInterface, StepInterface and
StepDataInterface. The following methods cover these responsibilities. Each of the method’s implementation is
typically constructing a new instance of the corresponding class forwarding the passed in arguments to the
constructor. The methods are as follows.
public StepDialogInterface getDialog(...)
public StepInterface getStep(...)
public StepDataInterface getStepData()
Each of the above methods returns a new instance of the plugin class implementing StepDialogInterface, StepInterface
and StepDataInterface.
-
Report the step’s changes to the row stream PDI needs to know how a step affects the row structure. A
step may be adding or removing fields, as well as modifying the metadata of a field. The method implementing this
aspect of a step plugin is getFields().
public void getFields(...)
Given a description of the input rows, the plugin needs to modify it to match the structure for its output fields.
The implementation modifies the passed in RowMetaInterface object to reflect any changes to the row stream. Typically
a step adds fields to the row structure, which is done by creating ValueMeta objects (PDI’s default
implementation of ValueMetaInterface), and appending them to the RowMetaInterface object. The section Working with
Fields goes into deeper detail on ValueMetaInterface.
-
Validate step settings
Spoon supports a “validate transformation” feature, which triggers a self-check of all steps. PDI invokes
the check() method of each step on the canvas allowing each step to validate its settings.
public void check()
Each step has the opportunity to validate its settings and verify that the configuration given by the user is
reasonable. In addition to that a step typically checks if it is connected to preceding or following steps, if the
nature of the step requires that kind of connection. An input step may expect to not have a preceding step for
example. The check method passes in a list of check remarks that the method should append its validation results to.
Spoon then displays the list of remarks collected from the steps, allowing the user to take corrective action in case
of validation warnings or errors.
Given a description of the input rows, the plugin needs to modify it to match the structure for its output fields.
The implementation modifies the passed in RowMetaInterface object to reflect any changes to the row stream. Typically
a step adds fields to the row structure, which is done by creating ValueMeta objects (PDI’s default
implementation of ValueMetaInterface), and appending them to the RowMetaInterface object. The section Working with
Fields goes into deeper detail on ValueMetaInterface.