Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/HCMPRE-1708-new' into HCMPRE-170…
Browse files Browse the repository at this point in the history
…8-new
  • Loading branch information
tanishi-egov committed Jan 16, 2025
2 parents 2ff8b2c + 5eb30a6 commit eb52289
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,13 @@ public class ServiceConstants {

public static final String FACILITY_TYPE_SEARCH_PARAMETER_KEY = "facilityType";

public static final String TERRAIN_CONDITION_SEARCH_PARAMETER_KEY = "accessibilityDetails.terrain.code";
public static final String TERRAIN_CONDITION_SEARCH_PARAMETER_KEY = "accessibilityDetails|terrain|code";

public static final String ROAD_CONDITION_SEARCH_PARAMETER_KEY = "accessibilityDetails.roadCondition.code";
public static final String ROAD_CONDITION_SEARCH_PARAMETER_KEY = "accessibilityDetails|roadCondition|code";

public static final String SECURITY_Q1_SEARCH_PARAMETER_KEY = "securityDetails.1.code";
public static final String SECURITY_Q1_SEARCH_PARAMETER_KEY = "securityDetails|1|code";

public static final String SECURITY_Q2_SEARCH_PARAMETER_KEY = "securityDetails.2.code";
public static final String SECURITY_Q2_SEARCH_PARAMETER_KEY = "securityDetails|2|code";

public static final String COMMA_DELIMITER = ",";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,9 @@ public String preparePartialJsonStringFromFilterMap(Map<String, String> filterMa
if (key.contains(DOT_SEPARATOR)) {
String[] keyArray = key.split(DOT_REGEX);
Map<String, Object> nestedQueryMap = new HashMap<>();

// Recursively build the nested structure based on the key hierarchy.
prepareNestedQueryMap(0, keyArray, nestedQueryMap, filterMap.get(key));

// Merge the newly created nested structure into the main query map.
queryMap.merge(keyArray[0], nestedQueryMap.get(keyArray[0]), (existing, newValue) -> {
// If both existing and new values are maps, merge them to prevent overwriting.
if (existing instanceof Map && newValue instanceof Map) {
mergeMaps((Map<String, Object>) existing, (Map<String, Object>) newValue);
return existing;
}
return newValue;
});
queryMap.put(keyArray[0], nestedQueryMap.get(keyArray[0]));
} else {
// If no nesting, directly put the key-value pair into the query map.
queryMap.put(key, filterMap.get(key));
}
});
Expand Down Expand Up @@ -182,31 +170,6 @@ public String getPaginatedQuery(String query, List<Object> preparedStmtList) {
return paginatedQuery.toString();
}

/**
* Recursively merges two maps, combining their nested structures while preserving existing values.
*
* @param existing The final map that will contain the merged result.
* @param newMap The source map whose contents will be merged into the existing map.
*
* Example:
* existing = {"a": {"b": "value1"}}
* newMap = {"a": {"c": "value2"}}
* Result: {"a": {"b": "value1", "c": "value2"}}
*/
private void mergeMaps(Map<String, Object> existing, Map<String, Object> newMap) {
newMap.forEach((key, value) -> {
existing.merge(key, value, (oldValue, newValue) -> {
// If both values are maps, recursively merge them
if (oldValue instanceof Map && newValue instanceof Map) {
mergeMaps((Map<String, Object>) oldValue, (Map<String, Object>) newValue);
return oldValue;
}
// If either value is not a map, use the new value
return newValue;
});
});
}

/**
* This method is used to extract and parse JSON data into a JsonNode object
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public class Census {
private String boundaryCode = null;

@JsonProperty("assignee")
@Size(max = 64)
private String assignee = null;
private List<String> assignee = null;

@JsonProperty("status")
@Size(max = 64)
Expand Down

0 comments on commit eb52289

Please sign in to comment.