MDMS V2 (Master Data Management Service)
MDMS v2 exposes APIs for defining schemas, searching schemas and then adding master data against these defined schemas. All of the data is now stored in PostgreSQL tables rather than in GitHub. MDMS v2 currently also exposes v1 search API which will fetch data from the database in the same format as MDMS v1 search API to maintain backward compatibility.
Requirements:
Prior Knowledge of Java/J2EE.
Prior Knowledge of Spring Boot.
Prior Knowledge of REST APIs and related concepts like path parameters, headers, JSON etc.
Prior knowledge of Git.
Advanced knowledge on how to operate JSON data would be an added advantage to understand the service.
Functionalities:
Create schema: MDMS v2 introduces functionality to define your schema with all validations and properties supported by JSON schema draft 07. Here is a sample schema definition for your reference -
"SchemaDefinition": {
"tenantId": "pb",
"code": "TradeLicense.TradeSubType",
"description": "Trade sub-type which is a child of Trade type",
"definition": {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"name": {
"type": "string",
"pattern": "^[A-Za-z]+$"
},
"code": {
"type": "string"
},
"tradeTypeCode": {
"type": "string"
}
},
"required": [
"name",
"code",
"tradeTypeCode"
],
"x-unique": [
"name"
],
"x-ref-schema": [
{
"fieldPath": "tradeTypeCode",
"schemaCode": "TradeLicense.TradeType"
}
]
},
"isActive": true
}
To create a basic schema definition, define the following keywords:
$schema: specifies which draft of the JSON Schema standard the schema adheres to.
title and description: state the intent of the schema. These keywords don’t add any constraints to the data being validated.
type: defines the first constraint on the JSON data.
Reference - https://json-schema.org/learn/getting-started-step-by-step#create
Now, properties can be added under the the schema definition. In JSON Schema terms, properties is a validation keyword. When you define properties, you create an object where each property represents a key in the JSON data that’s being validated. You can also specify which properties defined in the object are required.
Reference - https://json-schema.org/learn/getting-started-step-by-step#define
Additionally, we have two keys which are not part of standard JSON schema attributes -
x-unique: specifies the fields in the schema utilizing which a unique identifier for each master data will be created.
x-ref-schema: specifies referenced data. Useful in scenarios where parent-child relationship needs to be established in master data. For example, Trade Type can be a parent master data to Trade Sub Type. In the aforementioned example, the field path represents the JsonPath of the attribute in the master data which contains the unique identifier of the parent which is being referenced. Schema code represents the schema under which the referenced master data needs to be validated for existence.
Search schema: MDMS v2 has API to search schema based on the tenantid, schema code, unique identifier.
Create data: MDMS v2 allows creation of data against the defined schema. For the aforementioned schema, here is an example data for your reference -
"Mdms": {
"tenantId": "pb",
"schemaCode": "TradeLicense.TradeSubType",
"data": {
"name": "Electronics",
"code": "ELECTRONICS",
"tradeTypeCode": "GOODS.MANUFACTURE"
},
"isActive": true
}
Search data: MDMS v2 exposes two search APIs - v1 and v2 search where v1 search API is completely backward compatible.
Update data: MDMS v2 allows updation of master data fields.
Fallback functionality: Both the search APIs have fallback implemented where if data is not found for a particular tenant, the services falls back to the parent tenant(s) and returns the response back. If data is not found even for the parent tenant, empty response is sent to the user.
API Details:
/mdms-v2/schema/v1/_create - Takes RequestInfo and SchemaDefinition in request body. SchemaDefinition has all attributes which define the schema.
/mdms-v2/schema/v1/_search - Takes RequestInfo and SchemaDefSearchCriteria in request body and returns schemas based on the provided search criteria.
/mdms-v2/v2/_create/{schemaCode} - Takes RequestInfo and Mdms in request body where Mdms object has all the information for the master being created and it takes schemaCode as path param to identify the schema against which data is being created.
/mdms-v2/v2/_search - Takes RequestInfo and MdmsCriteria in request body to return master data based on the provided search criteria. It also has fallback functionality where if data is not found for the tenant which is sent, the services falls back to the parent tenant(s) to look for the data and return it back.
/mdms-v2/v2/_update/{schemaCode} - Takes RequestInfo and Mdms in request body where Mdms object has all the information for the master being updated and it takes schemaCode as path param to identify the schema against which data is being updated.
/mdms-v2/v1/_search - This is a backward compatible API which takes RequestInfo and MdmsCriteria in request body to return master data based on the provided search criteria and returns the response in MDMS v1 format. It also has fallback functionality where if data is not found for the tenant which is sent, the services falls back to the parent tenant(s) to look for the data and return it back.