How To Create A Cleanse Library
How To Create A Cleanse Library
What is a cleanse Function A Cleanse function is a function which can accept input parameters based on which it can perform various operations (like reading required data from database and doing validation) and give the desired output. We can create our own cleanse functions in java and import them in MDM Hub Console, So that it can be used by other user defined cleanse functions in MDM Hub.
Dependencies log4j-1.2.8.jar siperian-api.jar siperian-common.jar siperian-server.jar How to create a cleanse Function 1) Create a class for cleanse function which should implement com.siperian.mrm.cleanse.api.CleanseFunction.
2) Create a method to get the Descriptor for the cleanse function com.siperian.mrm.cleanse.api.Cleanse Descriptor . The descriptor should be set with a name and Description plus the input and output parameters defined for the Cleanse function.
The input parameters will appear on MDM Hub console where they can be set with required values.
The output parameters will be set in the method cleanse which will appear as an output of the cleanse function in MDM Hub. Page 1 of 9
// set the cleanse function name descriptor.setName("< your cleanse function name>");
// set the Description for cleanse function name descriptor.setDescription("< your cleanse function description >");
// define input parameters descriptor.getInputs().add(intParameter(new Parameter(<parameter name>, "<parameter Type>", <parameter description>));
// define output parameters descriptor.getOutputs().add(intParameter(new Parameter(<parameter name>, "<parameter Type>", <parameter description>));
Page 2 of 9
The second argument of type Map contains the value that where passed for input parameters defined in the Cleanse function descriptor.
Retrieve the input values from this input Map , perform business operation and set the third argument of type Map for the output parameters defined in the Cleanse function descriptor.
Map context - This contains information some context information like Database connection. Map input - This contains data for input parameters. Map output - This map needs to be set with the output parameters.
public void cleanse(Map context, Map input, Map output) throws CleanseException {
// use the input parameters to perform business logic // set the output parameters output.put(<output parameter name>,<output Value>)
How to create a Cleanse library and associate Cleanse functions with it When all the required Cleanse functions have been created they need to be grouped under a library which can be imported to MDM as a jar file. Page 3 of 9
1) Create a class for cleanse library which should implement com.siperian.mrm.cleanse.api.CleanseFunction.CleanseLibrary 2) Create 2 attributes a. A library descriptor The name and description given here will appear in MDM hub console private com.siperian.mrm.cleanse.api.CleanseLibraryDescriptor descriptor = null;
b. Map for cleanse function - This is to attach the required cleanse functions so that they can be retrieved from this attribute private Map<String, BddCVFunction> functionMap = new HashMap<String, BddCVFunction>();
// set the description descriptor = new CleanseLibraryDescriptor(); descriptor.setName("<library name>"); descriptor.setDescription("library description"); descriptor.setDynamic(true); descriptor.setMajorVersion(1); descriptor.setMinorVersion(0);
public void initialize(Properties properties) throws CleanseException{ // Code needs to be added if required to do any initialize any resources }
public void shutdown(){ // code needs to be added here to release any required resources }
// This method is invoked to get the required Cleanse function by name. public CleanseFunction getCleanseFunction(String name) { return (CleanseFunction) functionMap.get(name); Page 5 of 9
5) Once the Cleanse library is created and cleanse functions have been attached build the jar file for the same.
a) Go to cleanse function >> right click >> select Add Java Library
Page 6 of 9
Page 7 of 9
c) You can see the library and the cleanse function associated with it.
Sample Cleanse function and Cleanse Library files from FPV prototype
Page 8 of 9
BddCVFunction.java
CVEntityFunction.jav a
BddValidationLibrary. java
Page 9 of 9