From 9377a87ed650a57734ce4803964cb5e1fda49f07 Mon Sep 17 00:00:00 2001 From: saiprakash-egov Date: Tue, 19 Nov 2024 11:53:09 +0530 Subject: [PATCH] comment older boundary utils --- .../org/egov/project/util/BoundaryUtil.java | 130 +++++++++--------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/health-services/project/src/main/java/org/egov/project/util/BoundaryUtil.java b/health-services/project/src/main/java/org/egov/project/util/BoundaryUtil.java index 3a0a08d31ea..1d41122e620 100644 --- a/health-services/project/src/main/java/org/egov/project/util/BoundaryUtil.java +++ b/health-services/project/src/main/java/org/egov/project/util/BoundaryUtil.java @@ -26,70 +26,70 @@ @Slf4j public class BoundaryUtil { - @Value("${egov.location.host}") - private String locationHost; - - @Value("${egov.location.context.path}") - private String locationContextPath; - - @Value("${egov.location.endpoint}") - private String locationEndpoint; - - @Value("${egov.location.code.query.param:codes}") - private String codeQueryParam; - - @Autowired - private ServiceRequestClient serviceRequestRepository; - - /* Takes map of locations with boundaryType as key and list of boundaries as its values, tenantId, requestInfo and hierarchyType. - * For each boundaryType, egov-location service is called with hierarchyType, tenantId and codes as parameters. The boundaries in request are validated against the egov-location response*/ - public void validateBoundaryDetails(Map> locations, String tenantId, RequestInfo requestInfo, String hierarchyTypeCode) { - for (Map.Entry> entry : locations.entrySet()) { - String boundaryType = entry.getKey(); - List boundaries = entry.getValue(); - - log.info("Validating boundary for boundary type " + boundaryType + " with hierarchyType " + hierarchyTypeCode); - StringBuilder uri = new StringBuilder(locationHost); - uri.append(locationContextPath).append(locationEndpoint); - uri.append("?").append("tenantId=").append(tenantId); - - if (hierarchyTypeCode != null) - uri.append("&").append("hierarchyTypeCode=").append(hierarchyTypeCode); - - uri.append("&").append("boundaryType=").append(boundaryType).append("&") - .append(String.format("%s=", codeQueryParam)) - .append(StringUtils.join(boundaries, ',')); - - Optional response = null; - try { - response = Optional.ofNullable(serviceRequestRepository.fetchResult(uri, - RequestInfoWrapper.builder().requestInfo(requestInfo).build(), LinkedHashMap.class)); - } catch (Exception e) { - log.error("error while calling boundary service", ExceptionUtils.getStackTrace(e)); - throw new CustomException("BOUNDARY_ERROR", "error while calling boundary service"); - } - - if (response.isPresent()) { - LinkedHashMap responseMap = (LinkedHashMap) response.get(); - if (CollectionUtils.isEmpty(responseMap)) - throw new CustomException("BOUNDARY ERROR", "The response from location service is empty or null"); - String jsonString = new JSONObject(responseMap).toString(); - - for (String boundary : boundaries) { - String jsonpath = "$..boundary[?(@.code==\"{}\")]"; - jsonpath = jsonpath.replace("{}", boundary); - DocumentContext context = JsonPath.parse(jsonString); - Object boundaryObject = context.read(jsonpath); - - if (!(boundaryObject instanceof ArrayList) || CollectionUtils.isEmpty((ArrayList) boundaryObject)) { - log.error("The boundary data for the code " + boundary + " is not available"); - throw new CustomException("INVALID_BOUNDARY_DATA", "The boundary data for the code " - + boundary + " is not available"); - } - } - } - log.info("The boundaries " + StringUtils.join(boundaries, ',') + " validated for boundary type " + boundaryType + " with tenantId " + tenantId); - } - } +// @Value("${egov.location.host}") +// private String locationHost; +// +// @Value("${egov.location.context.path}") +// private String locationContextPath; +// +// @Value("${egov.location.endpoint}") +// private String locationEndpoint; +// +// @Value("${egov.location.code.query.param:codes}") +// private String codeQueryParam; +// +// @Autowired +// private ServiceRequestClient serviceRequestRepository; +// +// /* Takes map of locations with boundaryType as key and list of boundaries as its values, tenantId, requestInfo and hierarchyType. +// * For each boundaryType, egov-location service is called with hierarchyType, tenantId and codes as parameters. The boundaries in request are validated against the egov-location response*/ +// public void validateBoundaryDetails(Map> locations, String tenantId, RequestInfo requestInfo, String hierarchyTypeCode) { +// for (Map.Entry> entry : locations.entrySet()) { +// String boundaryType = entry.getKey(); +// List boundaries = entry.getValue(); +// +// log.info("Validating boundary for boundary type " + boundaryType + " with hierarchyType " + hierarchyTypeCode); +// StringBuilder uri = new StringBuilder(locationHost); +// uri.append(locationContextPath).append(locationEndpoint); +// uri.append("?").append("tenantId=").append(tenantId); +// +// if (hierarchyTypeCode != null) +// uri.append("&").append("hierarchyTypeCode=").append(hierarchyTypeCode); +// +// uri.append("&").append("boundaryType=").append(boundaryType).append("&") +// .append(String.format("%s=", codeQueryParam)) +// .append(StringUtils.join(boundaries, ',')); +// +// Optional response = null; +// try { +// response = Optional.ofNullable(serviceRequestRepository.fetchResult(uri, +// RequestInfoWrapper.builder().requestInfo(requestInfo).build(), LinkedHashMap.class)); +// } catch (Exception e) { +// log.error("error while calling boundary service", ExceptionUtils.getStackTrace(e)); +// throw new CustomException("BOUNDARY_ERROR", "error while calling boundary service"); +// } +// +// if (response.isPresent()) { +// LinkedHashMap responseMap = (LinkedHashMap) response.get(); +// if (CollectionUtils.isEmpty(responseMap)) +// throw new CustomException("BOUNDARY ERROR", "The response from location service is empty or null"); +// String jsonString = new JSONObject(responseMap).toString(); +// +// for (String boundary : boundaries) { +// String jsonpath = "$..boundary[?(@.code==\"{}\")]"; +// jsonpath = jsonpath.replace("{}", boundary); +// DocumentContext context = JsonPath.parse(jsonString); +// Object boundaryObject = context.read(jsonpath); +// +// if (!(boundaryObject instanceof ArrayList) || CollectionUtils.isEmpty((ArrayList) boundaryObject)) { +// log.error("The boundary data for the code " + boundary + " is not available"); +// throw new CustomException("INVALID_BOUNDARY_DATA", "The boundary data for the code " +// + boundary + " is not available"); +// } +// } +// } +// log.info("The boundaries " + StringUtils.join(boundaries, ',') + " validated for boundary type " + boundaryType + " with tenantId " + tenantId); +// } +// } } \ No newline at end of file