Prerequisites
This guide assumes you have already created a Maven project withatoti-server-extension-parent as described in the Atoti Server Extension reference.1. Add atoti-server-extension-parent to your pom.xml
For a correct use of Atoti Server Extension, you need to add theatoti-server-extension-parent as a parent in the pom.xml file of your server extension project.
2. Create a basic custom measure and register it
In this section, we show you how to create a custom measure and register it in the Atoti application. The steps are the same for every custom measure not requiring an underlying post-processor.2.1 Create an argument class for your measure
Create a class that implements the empty interfacecom.activeviam.atoti.application.api.measures.IMeasureDefinition, this class should contain the arguments needed to compute the measure and optionally, the measure’s plugin key.Arguments can be of any Java primitive type, or any types of identifier defined in Atoti (e.g.
com.activeviam.activepivot.core.intf.api.cube.metadata.LevelIdentifier, com.activeviam.activepivot.core.intf.api.cube.metadata.HierarchyIdentifier, etc.).
IMeasureDefinition from Python are of the following types:
- Any Java primitive type (e.g.
int,double,boolean, etc.) LevelIdentifierHierarchyIdentifierStoreField- Measure name as a
String - Column name as a
String - Dimension name as a
String - Any array/tuple and map of the above types
2.2 Create your measure’s registration class
Once an argument class is defined, you are now able to create acom.activeviam.atoti.server.common.api.plugins.MeasureRegistration object specific to your measure, that will then be used to register the measure in the Atoti application.
You can also specify a formatter when creating your custom measure formula by overriding
IFormulaFactory.computeFormatter()Example
Example
2.3 Register your measure in the Atoti application
Once the measure registration class is ready, you can register your measure in the Atoti application using thecom.activeviam.atoti.server.common.api.plugins.IPluginSetup bean.You can do this in a Spring configuration class by defining a bean that returns a
com.activeviam.atoti.server.common.api.plugins.PluginMeasureRegistrations object.
If you need to register multiple measures, they can all be added to the
PluginMeasureRegistrations object returned by the contributeMeasures() method of the IPluginSetup bean.Example:3. Create a custom measure relying on a custom post-processor
In this section, we show you how to create a custom measure whose calculations rely on a custom post-processor.3.1 Create a custom post-processor
You can create a custom post-processor by extending any class which already extendsAAdvancedPostProcessor.For example:
Creation of a basic post-processor
Creation of a basic post-processor
3.2 Create a custom measure relying on the created post-processor
Once the post-processor is created, you can create a measure that relies on it by using very similar code to the one used in the Basic Custom Measure section:- You need to create an argument class that implementing
IMeasureDefinition.
- You need to create a
MeasureRegistrationobject specifying the new post-processor that will be used to register the measure in the Atoti application, for example:
3.3 Register the post-processor
One the post-processor and the measure are created, you need to manually register the created post-processor in the Atoti application registry:3.4 Register the measure
Finally, you can register the measure in the Atoti application using theIPluginSetup bean as shown in the Basic Custom Measure section. The post-processor must also be registered in the PluginMeasureRegistrations bean definition.
4. Import your measures configuration in your project’s AutoConfiguration
Once you have created your measures configuration class (e.g.,ServerExtensionMeasuresConfig), you must import it in your extension’s @AutoConfiguration class to make it available to the Atoti application see.