MDMS Migration
Steps to migrate MDMS data to enable use of workbench UI v1.0
Last updated
Was this helpful?
Was this helpful?
"x-unique": ["description"]"x-ref-schema": [{"fieldPath": "billingType","schemaCode": "WaterCharges.BillingType"}]curl -L 'localhost:8080/mdms-migration-toolkit/schema/v1/_migrate' \
-H 'Content-Type: application/json' \
-d '{
"schemaMigrationCriteria": {
"moduleName": "PropertyTax",
"tenantId": "pb"
},
"requestInfo": {
"apiId": "asset-services",
"ver": null,
"ts": null,
"action": null,
"did": null,
"key": null,
"msgId": "search with from and to values",
"authToken": "7a9fc02a-bd6e-4e42-bd43-519b9e357bae",
"correlationId": null,
"userInfo": {
"id": 878483,
"uuid": "3059806b-3059-4724-8ae1-d3f4e12686ff",
"userName": "8080800000",
"name": "HRMS-ADMIN-TESTING",
"mobileNumber": "8080800000",
"emailId": null,
"locale": null,
"type": "EMPLOYEE",
"roles": [
{
"name": "MDMS ADMIN",
"code": "MDMS_ADMIN",
"tenantId": "pb"
},
{
"name": "Localisation admin",
"code": "LOC_ADMIN",
"tenantId": "pb"
},
{
"name": "Employee",
"code": "EMPLOYEE",
"tenantId": "pb"
}
],
"active": true,
"tenantId": "pb",
"permanentCity": null
}
}
}'curl -L 'localhost:8080/mdms-migration-toolkit/data/v1/_migrate' \
-H 'accept: */*' \
-H 'Content-Type: application/json' \
-d '{
"masterDataMigrationCriteria": {
"moduleName": "PropertyTax",
"tenantId": "pb"
},
"requestInfo": {
"apiId": "asset-services",
"ver": null,
"ts": null,
"action": null,
"did": null,
"key": null,
"msgId": "search with from and to values",
"authToken": "7a9fc02a-bd6e-4e42-bd43-519b9e357bae",
"correlationId": null,
"userInfo": {
"id": 878483,
"uuid": "3059806b-3059-4724-8ae1-d3f4e12686ff",
"userName": "8080800000",
"name": "HRMS-ADMIN-TESTING",
"mobileNumber": "8080800000",
"emailId": null,
"locale": null,
"type": "EMPLOYEE",
"roles": [
{
"name": "MDMS ADMIN",
"code": "MDMS_ADMIN",
"tenantId": "pb"
},
{
"name": "Localisation admin",
"code": "LOC_ADMIN",
"tenantId": "pb"
},
{
"name": "Employee",
"code": "EMPLOYEE",
"tenantId": "pb"
}
],
"active": true,
"tenantId": "pb",
"permanentCity": null
}
}
}'{
"id": "060776ef-2eff-4f76-82ba-9b40cfad1c6c",
"tenantId": "pb",
"code": "ws-services-calculation.WCBillingSlab",
"description": "ws-services-calculation WCBillingSlab",
"definition": {
"type": "object",
"allOf": [
{
"if": {
"required": ["connectionType"],
"properties": {
"connectionType": {"const": "Metered"}
}
},
"then": {
"required": ["slabs"],
"properties": {
"calculationAttribute": {"enum": ["Water consumption"]}
}
}
},
{
"if": {
"required": ["connectionType"],
"properties": {
"connectionType": {"const": "Non_Metered"}
}
},
"then": {
"properties": {
"calculationAttribute": {
"enum": ["Flat", "No. of taps", "Pipe Size"]
}
}
}
}
],
"title": "Generated schema for Root",
"$schema": "http://json-schema.org/draft-07/schema#",
"required": ["buildingType", "calculationAttribute", "connectionType", "minimumCharge"],
"x-unique": ["buildingType", "connectionType"],
"properties": {
"slabs": {
"type": "array",
"items": {
"type": "object",
"required": ["from", "to", "charge"],
"properties": {
"to": {"type": "number"},
"from": {"type": "number"},
"charge": {"type": "number"},
"meterCharge": {"type": "number"}
}
}
},
"buildingType": {
"enum": [
"RESIDENTIAL", "NONRESIDENTIAL", "COMMERCIAL AND GOVERNMENT",
"PARTLY COMMERCIAL", "COMMERCIAL", "GOVERNMENT", "MIXED", "PUBLICSECTOR"
],
"type": "string"
},
"minimumCharge": {"type": "number"},
"connectionType": {
"enum": ["Metered", "Non_Metered"],
"type": "string"
},
"calculationAttribute": {
"enum": ["Flat", "Water consumption", "No. of taps", "Pipe Size"],
"type": "string"
}
}
},
"isActive": true,
"auditDetails": {
"createdBy": "3059806b-3059-4724-8ae1-d3f4e12686ff",
"lastModifiedBy": "3059806b-3059-4724-8ae1-d3f4e12686ff",
"createdTime": 1701151086754,
"lastModifiedTime": 1701151086754
}
}/**
* This method accepts master data migration requests and triggers
* creation of MDMS objects
* @param masterDataMigrationRequest
*/
public void migrateMasterData(@Valid MasterDataMigrationRequest masterDataMigrationRequest) {
// Get Master Data map
Map<String, Map<String, JSONArray>> tenantMap = MDMSApplicationRunnerImpl.getTenantMap();
// Get tenantId from request
String tenantId = masterDataMigrationRequest.getMasterDataMigrationCriteria().getTenantId();
// Build audit details for mdms objects creation
AuditDetails auditDetails = new AuditDetails();
RequestInfo requestInfo = masterDataMigrationRequest.getRequestInfo();
AuditDetailsEnrichmentUtil.enrichAuditDetails(auditDetails, requestInfo, Boolean.TRUE);
List<JSONArray> masterDataList = new ArrayList<>();
// Check if master data is present for the incoming tenantId.
if (tenantMap.containsKey(tenantId)) {
tenantMap.get(tenantId).keySet().forEach(module -> {
if (module.equals("common-masters")) {
tenantMap.get(tenantId).get(module).keySet().forEach(master -> {
if (master.equals("CancelCurrentBillReasons") || master.equals("CancelReceiptReason") ||
master.equals("CronJobAPIConfig") || master.equals("Department") || master.equals("Designation") ||
master.equals("IdProof") || master.equals("UsageCategory") || master.equals("OwnerType") ||
master.equals("VehicleType") || master.equals("UOM") || master.equals("StructureType") ||
master.equals("TablePaginationOptions")) {
// Get master data array for current module and master
JSONArray masterDataJSONArray = MDMSApplicationRunnerImpl
.getJSONArray(tenantMap.get(tenantId)
.get(module)
.get(master));
masterDataList.add(masterDataJSONArray);
}
});
}
});
}
}