Validating a price change using the Before Saving process
The idea of creating this example is to help you get familiar with the Talend MDM Before Saving process and show you how to use a Before Saving process to validate data changes in Talend MDM.
A process in Talend MDM defines one or multiple steps to perform business validation, data integration, data transformation, etc. A Before Saving process works with a specific entity and validates the entity data according to certain conditions before saving the data in the MDM Hub. It is automatically called back right before MDM saves the record. For more information about the process and the Before Saving process, see Processes.
The Before Saving process beforeSaving_Product in Talend MDM demo project has been designed to validate any price change of a product before saving it in the MDM hub. This process uses the callJob plugin that calls the Job ValidatePriceChange created in the Integration perspective to validate the price change.
The Job ValidatePriceChange validates that the price does not increase or drop by more than 15%. When the price increases or drops by more than 15%, it will return an error message increase of/drop of [change ratio] not allowed, max is 15% that is defined in the tMap component with the label CheckRatio and the new price value will not be saved, or else, it will return an info message Product validation OK defined in the tMap component with the label SetResult and the new price will be successfully saved.
Before you begin
- The Talend IAM (Talend Identity and Access Management), TAC (Talend Administration Center), MDM server and Talend Studio have been successfully installed and started.
- The value of the context variables host and port in the Context view have been updated in the Integration perspective of Talend Studio if the MDM server is not installed locally and if you did not choose the default port number 8180 during the installation.
- At least the following Talend MDM demo project items, the Data Container Product, the Data Model Product, the Process beforeSaving_Product, the Job ValidatePriceChange, the View Product, the Role Demo_Manager and Demo_User, and the eleven images under the folder Resource in Talend Studio repository have been deployed to the MDM server successfully.
- The Job CreateUsers in Talend Studio has been executed successfully, and three MDM users have been created in Talend Administration Center and specific custom roles have been assigned to them.
- The Job MDM_LoadAll in Talend Studio has been executed successfully and the sample data has been loaded into the entity ProductFamily and Product.
For more information about the prerequisites, see Making the MDM demo project work.