 | This developer guide will help you learn how to create your custom Apatar function. |
Extension
To create a new Apatar function,
- You need to extend a class from the com.altoros.octoslave.core.AbstractETLFunction class.
This can be achieved by carrying out the following steps.
a) Create your own plugin extended from the com.altoros.octoslave.core and com.altoros.octoslave.ui classes. (Please, read the guide explaining How to Create Your Own Connector or Operation.) Here, in this plugin, you need to create your own function.
b) Insert your function's code into com.altoros.octoslave.function plugin. This is where Apatar functions are located. For instance, the Concatenate function is being stored in the "plugins/com.altoros.octoslave.function/src/com/altoros/octoslave/function/String/ConcatenateTransformFunction.java" file. In the function plugin, Apatar's functions are divided into categories and put into related packages (folders). So, actually, you can copy one of the function's source code files and then rename it.
The com.altoros.octoslave.core.AbstractETLFunction class is the most general one. Using it, you can create any function for Apatar. However, there are a number of created classes that are already extended from this class. They have some functionality embedded which can be used in your new function.
- The ValueAbstractETLFunction class (plugins/com.altoros.octoslave.core/src/com/altoros/octoslave/core/ValueAbstractETLFunction.java) is used if your function needs a string parameter for setting options. The options window will be launched when someone double-clicks on the function's node.
- The IntValueAbstractETLFunction class (plugins/com.altoros.octoslave.core/src/com/altoros/octoslave/core/IntValueAbstractETLFunction.java) is used if your function needs an integer parameter for setting options. The options window will be launched when someone double-clicks on the function's node.
To display the options window, you can implement you own dialog window. To use existing Apatar classes, create the "Your_Class_NameBeanInfo.java" file in the same package where your function is located. In this file, you need to develop the Your_Class_NameBeanInfo class extended from BaseBeanInfo.
Methods to redefine:
getTitle() - returns the function title
initFromElement(Element e) - restores the function parameters after the project has been reopened
saveToElement() - saves the function parameters
isEditable() - is used when a function requires a value to be entered for this function to work with
getFunctionInfo() - returns information about the function (the number of inputs/outputs, etc.)
execute(List l) - executes the function and returns the execution results (All of the input parameters that are received at the function entry point (the ConnectionPoint class) are transferred via the "I" parameter.)
- Create a new instance of the FunctionInformation class. (This class is returned from the getFunctionInfo() method.)
The titles of the methods can give you an idea about their purpose and the values they return. For instance, the getInputComments() and getOutputComments() methods are used to set the tooltips that are displayed when a cursor moves over a connection point of an Apatar node.
- After that, you need to edit the "plugin.xml" file and specify the name of a plug-in where the extension point and the extension point name are described. Please, check the following example describing the extension of the Concatenate function (the String type):
<extension plugin-id="com.altoros.octoslave.core" point-id="functionFactory" id="functionFactoryConcatenate">
<parameter id="classFunction" value="com.altoros.octoslave.function.String.ConcatenateTransformFunction" />
</extension>
Please note that you need to set your own titles instead of the functionFactoryConcatenate id and the ConcatenateTransformFunction value here. (ConcatenateTransformFunction is the name of the function you are trying to create.)
SVN Repository
You can download Apatar's source code at http://apatar.svn.sourceforge.net/viewvc/apatar/
See Also
How to Create Your Own Connector or Operation