Add New Fields

Overview

This guide walks you through the end-to-end process of introducing a new field (e.g., landmark) in the CCRS service module, starting from backend model changes to data persistence and validations.

Adding a new field typically involves changes across multiple layers:

  • Java models (domain classes)

  • Validation and enrichment logic

  • Row mapping from DB

  • Persister and indexer configurations

This ensures the field is:

  • Captured in incoming requests

  • Validated or enriched if needed

  • Persisted to the database

  • Indexed for search

  • Returned in query results


Steps to Add a New Field

1

Add field in the Model

In Service.java (or the appropriate domain class):

private String landmark;
2

Add validation (optional)

In the validateCreate() method inside the Validator class:

if (request.getLandmark() == null) {
    throw new CustomException("PGR.LANDMARK_REQUIRED", "Landmark is required");
}
3

Enrich the Request (optional)

In enrichCreateRequest() method:

if (request.getLandmark() == null) {
    request.setLandmark("Default");
}
4

Map DB Result (RowMapper)

In PGRRowMapper.java:

service.setLandmark(rs.getString("landmark"));
5

Update Persister Configuration

In persister.yml, under save-pgr-request and update-pgr-request topics:

- jsonPath: $.Service.landmark
  dbColumn: landmark
  type: STRING

👉 After updating, restart the Persister service.

6

Update Persister Configuration

In indexer.yml, under save-pgr-request and update-pgr-request topics:

- jsonPath: $.Service.landmark
  dbColumn: landmark
  type: STRING

👉 After updating, restart the Indexer service.

7

Add to Search Query (Optional)

If you want to search/filter by landmark:

  • Update the query in PGRQueryBuilder.java

  • Add it to the parameter map


✅ Done!

Your new field is now fully integrated into the CCRS backend — from request to persistence.


Last updated

Was this helpful?