Add New Fields
Overview
This guide walks you through the end-to-end steps to add a new field (e.g., landmark
) to the CCRS service module — from backend models to database, validation, and persisting.
Steps
✅ Done!
Your new field is now fully integrated into the PGR backend — from request to persistence.
🔍 Understanding the PGR-Service Code
🔄 update(ServiceRequest request)
— Main Update Method
update(ServiceRequest request)
— Main Update MethodThis is the central method for handling service updates.
public ServiceRequest update(ServiceRequest request){
String tenantId = request.getService().getTenantId();
Object mdmsData = mdmsUtils.mDMSCall(request);
validator.validateUpdate(request, mdmsData);
enrichmentService.enrichUpdateRequest(request);
workflowService.updateWorkflowStatus(request);
producer.push(tenantId, config.getUpdateTopic(), request);
return request;
}
What each line does:
tenantId
Extracts tenant info for validations, workflows, Kafka
mdmsUtils.mDMSCall()
Fetches config data (departments, services, etc.) from MDMS
validateUpdate()
Runs business validations
enrichUpdateRequest()
Adds audit info, modifies fields
updateWorkflowStatus()
Triggers workflow transitions
producer.push()
Sends updated data to Kafka for persistence
✨ Customize validations or enrichment here based on business needs.
🛡️ validateCreate(...)
— Request Validation Logic
validateCreate(...)
— Request Validation Logicpublic void validateCreate(ServiceRequest request, Object mdmsData){
Map<String, String> errorMap = new HashMap<>();
validateUserData(request, errorMap);
validateSource(request.getService().getSource());
validateMDMS(request, mdmsData);
validateDepartment(request, mdmsData);
if (!errorMap.isEmpty())
throw new CustomException(errorMap);
}
What’s Happening:
validateUserData()
Validates citizen info (userId, phone, etc.)
validateSource()
Checks source channel (mobile, web, etc.) via MDMS
validateMDMS()
Ensures serviceCode/category is valid
validateDepartment()
Checks department validity via MDMS
CustomException
Aggregates and throws all validation errors
🧠 Add custom rules for new fields or business logic here.
🏗️ getMDMSRequest(...)
— Building the MDMS Query
getMDMSRequest(...)
— Building the MDMS Querypublic MdmsCriteriaReq getMDMSRequest(RequestInfo requestInfo, String tenantId){
List<ModuleDetail> moduleDetails = getPGRModuleRequest();
MdmsCriteria mdmsCriteria = MdmsCriteria.builder()
.moduleDetails(moduleDetails)
.tenantId(tenantId)
.build();
return MdmsCriteriaReq.builder()
.mdmsCriteria(mdmsCriteria)
.requestInfo(requestInfo)
.build();
}
What it does:
getPGRModuleRequest()
List of master data modules to fetch
MdmsCriteria
Ties together tenant and modules
MdmsCriteriaReq
Final request to be sent to MDMS
🧩 Modify this if your feature needs new MDMS data (like a new department list, config options, etc.)
🧑💻 Developer Notes
✅ Add new validations in
validateCreate()
orvalidateUpdate()
✅ Enrich new fields in
enrichCreateRequest()
orenrichUpdateRequest()
✅ Add workflows via the Workflow service or update the config in
updateWorkflowStatus()
✅ Register Kafka topics in
persister.yml
andapplication.yml
✅ Always test against tenant-specific MDMS configs (e.g.,
pb
,pg
)
Last updated
Was this helpful?