From d39557774f6ec7e3bedf5b070719c8e3c202bc22 Mon Sep 17 00:00:00 2001 From: kanishq-egov Date: Wed, 18 Sep 2024 12:22:08 +0530 Subject: [PATCH 1/5] HCMPRE-469: added changes for facility count --- health-services/facility/pom.xml | 2 +- .../repository/FacilityRepository.java | 20 +++++++++++++------ .../facility/service/FacilityService.java | 20 ++++++++++++------- .../validator/FNonExistentValidator.java | 2 +- .../validator/FRowVersionValidator.java | 2 +- .../controllers/FacilityApiController.java | 7 +++++-- .../NonExistentEntityValidatorTest.java | 8 ++++++-- .../validator/RowVersionValidatorTest.java | 8 ++++++-- .../libraries/health-services-models/pom.xml | 2 +- .../models/facility/FacilityBulkResponse.java | 10 ++++++++-- 10 files changed, 56 insertions(+), 25 deletions(-) diff --git a/health-services/facility/pom.xml b/health-services/facility/pom.xml index 1eb0038656a..3d25b5d9780 100644 --- a/health-services/facility/pom.xml +++ b/health-services/facility/pom.xml @@ -50,7 +50,7 @@ org.egov.common health-services-models - 1.0.20-SNAPSHOT + 1.0.23-SNAPSHOT compile diff --git a/health-services/facility/src/main/java/org/egov/facility/repository/FacilityRepository.java b/health-services/facility/src/main/java/org/egov/facility/repository/FacilityRepository.java index 482ac988b98..ae962edf963 100644 --- a/health-services/facility/src/main/java/org/egov/facility/repository/FacilityRepository.java +++ b/health-services/facility/src/main/java/org/egov/facility/repository/FacilityRepository.java @@ -5,6 +5,7 @@ import org.egov.common.data.query.builder.SelectQueryBuilder; import org.egov.common.data.query.exception.QueryBuilderException; import org.egov.common.data.repository.GenericRepository; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.facility.Facility; import org.egov.common.models.facility.FacilitySearch; import org.egov.common.producer.Producer; @@ -23,6 +24,7 @@ import java.util.Optional; import java.util.stream.Collectors; +import static org.egov.common.utils.CommonUtils.constructTotalCountCTEAndReturnResult; import static org.egov.common.utils.CommonUtils.getIdMethod; @Repository @@ -35,7 +37,7 @@ public FacilityRepository(Producer producer, NamedParameterJdbcTemplate namedPar facilityRowMapper, Optional.of("facility")); } - public List findById(List ids, String columnName, Boolean includeDeleted) { + public SearchResponse findById(List ids, String columnName, Boolean includeDeleted) { List objFound = findInCache(ids); if (!includeDeleted) { objFound = objFound.stream() @@ -48,7 +50,7 @@ public List findById(List ids, String columnName, Boolean incl .map(obj -> (String) ReflectionUtils.invokeMethod(idMethod, obj)) .collect(Collectors.toList())); if (ids.isEmpty()) { - return objFound; + return SearchResponse.builder().response(objFound).build(); } } @@ -61,10 +63,10 @@ public List findById(List ids, String columnName, Boolean incl objFound.addAll(this.namedParameterJdbcTemplate.query(query, paramMap, this.rowMapper)); putInCache(objFound); - return objFound; + return SearchResponse.builder().response(objFound).build(); } - public List find(FacilitySearch searchObject, Integer limit, Integer offset, String tenantId, Long lastChangedSince, Boolean includeDeleted) throws QueryBuilderException { + public SearchResponse find(FacilitySearch searchObject, Integer limit, Integer offset, String tenantId, Long lastChangedSince, Boolean includeDeleted) throws QueryBuilderException { String query = "SELECT *, a.id as aid,a.tenantid as atenantid, a.clientreferenceid as aclientreferenceid FROM facility f LEFT JOIN address a ON f.addressid = a.id"; Map paramsMap = new HashMap<>(); List whereFields = GenericQueryBuilder.getFieldsWithCondition(searchObject, QueryFieldChecker.isNotNull, paramsMap); @@ -83,12 +85,18 @@ public List find(FacilitySearch searchObject, Integer limit, Integer o if (lastChangedSince != null) { query = query + "and lastModifiedTime>=:lastModifiedTime "; } - query = query + "ORDER BY f.id ASC LIMIT :limit OFFSET :offset"; + query = query + "ORDER BY f.id ASC"; paramsMap.put("tenantId", tenantId); paramsMap.put("isDeleted", includeDeleted); paramsMap.put("lastModifiedTime", lastChangedSince); + + Long totalCount = constructTotalCountCTEAndReturnResult(query, paramsMap, this.namedParameterJdbcTemplate); + + query = query + " LIMIT :limit OFFSET :offset"; paramsMap.put("limit", limit); paramsMap.put("offset", offset); - return this.namedParameterJdbcTemplate.query(query, paramsMap, this.rowMapper); + List facilities = this.namedParameterJdbcTemplate.query(query, paramsMap, this.rowMapper); + + return SearchResponse.builder().response(facilities).totalCount(totalCount).build(); } } diff --git a/health-services/facility/src/main/java/org/egov/facility/service/FacilityService.java b/health-services/facility/src/main/java/org/egov/facility/service/FacilityService.java index 769aae4b725..407c7fd4430 100644 --- a/health-services/facility/src/main/java/org/egov/facility/service/FacilityService.java +++ b/health-services/facility/src/main/java/org/egov/facility/service/FacilityService.java @@ -1,13 +1,16 @@ package org.egov.facility.service; +import io.micrometer.core.instrument.search.Search; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; import org.egov.common.ds.Tuple; import org.egov.common.models.ErrorDetails; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.facility.Facility; import org.egov.common.models.facility.FacilityBulkRequest; import org.egov.common.models.facility.FacilityRequest; import org.egov.common.models.facility.FacilitySearchRequest; +import org.egov.common.models.project.ProjectBeneficiary; import org.egov.common.validator.Validator; import org.egov.facility.config.FacilityConfiguration; import org.egov.facility.repository.FacilityRepository; @@ -173,23 +176,26 @@ public List delete(FacilityBulkRequest request, boolean isBulk) { return validEntities; } - public List search(FacilitySearchRequest facilitySearchRequest, - Integer limit, - Integer offset, - String tenantId, - Long lastChangedSince, - Boolean includeDeleted) throws Exception { + public SearchResponse search(FacilitySearchRequest facilitySearchRequest, + Integer limit, + Integer offset, + String tenantId, + Long lastChangedSince, + Boolean includeDeleted) throws Exception { log.info("starting search method for facility"); String idFieldName = getIdFieldName(facilitySearchRequest.getFacility()); if (isSearchByIdOnly(facilitySearchRequest.getFacility(), idFieldName)) { List ids = (List) ReflectionUtils.invokeMethod(getIdMethod(Collections .singletonList(facilitySearchRequest.getFacility())), facilitySearchRequest.getFacility()); - return facilityRepository.findById(ids, idFieldName, includeDeleted).stream() + SearchResponse searchResponse = facilityRepository.findById(ids, idFieldName, includeDeleted); + List facilities = searchResponse.getResponse().stream() .filter(lastChangedSince(lastChangedSince)) .filter(havingTenantId(tenantId)) .filter(includeDeleted(includeDeleted)) .collect(Collectors.toList()); + searchResponse.setResponse(facilities); + return searchResponse; } log.info("completed search method for facility"); diff --git a/health-services/facility/src/main/java/org/egov/facility/validator/FNonExistentValidator.java b/health-services/facility/src/main/java/org/egov/facility/validator/FNonExistentValidator.java index c666d6b3264..2857a038490 100644 --- a/health-services/facility/src/main/java/org/egov/facility/validator/FNonExistentValidator.java +++ b/health-services/facility/src/main/java/org/egov/facility/validator/FNonExistentValidator.java @@ -50,7 +50,7 @@ public Map> validate(FacilityBulkRequest request) { Map eMap = getIdToObjMap(validEntities, idMethod); if (!eMap.isEmpty()) { List entityIds = new ArrayList<>(eMap.keySet()); - List existingEntities = facilityRepository.findById(entityIds, getIdFieldName(idMethod), false); + List existingEntities = facilityRepository.findById(entityIds, getIdFieldName(idMethod), false).getResponse(); List nonExistentEntities = checkNonExistentEntities(eMap, existingEntities, idMethod); nonExistentEntities.forEach(facility -> { diff --git a/health-services/facility/src/main/java/org/egov/facility/validator/FRowVersionValidator.java b/health-services/facility/src/main/java/org/egov/facility/validator/FRowVersionValidator.java index df76ac89fe4..17adda2b3f2 100644 --- a/health-services/facility/src/main/java/org/egov/facility/validator/FRowVersionValidator.java +++ b/health-services/facility/src/main/java/org/egov/facility/validator/FRowVersionValidator.java @@ -47,7 +47,7 @@ public Map> validate(FacilityBulkRequest request) { Map eMap = getIdToObjMap(validEntities, idMethod); if (!eMap.isEmpty()) { List entityIds = new ArrayList<>(eMap.keySet()); - List existingEntities = facilityRepository.findById(entityIds, getIdFieldName(idMethod), false); + List existingEntities = facilityRepository.findById(entityIds, getIdFieldName(idMethod), false).getResponse(); List entitiesWithMismatchedRowVersion = getEntitiesWithMismatchedRowVersion(eMap, existingEntities, idMethod); entitiesWithMismatchedRowVersion.forEach(facility -> { diff --git a/health-services/facility/src/main/java/org/egov/facility/web/controllers/FacilityApiController.java b/health-services/facility/src/main/java/org/egov/facility/web/controllers/FacilityApiController.java index 3ca37071ca8..67de20615b1 100644 --- a/health-services/facility/src/main/java/org/egov/facility/web/controllers/FacilityApiController.java +++ b/health-services/facility/src/main/java/org/egov/facility/web/controllers/FacilityApiController.java @@ -8,6 +8,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; import org.egov.common.contract.response.ResponseInfo; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.core.URLParams; import org.egov.common.models.facility.Facility; import org.egov.common.models.facility.FacilityBulkRequest; @@ -111,7 +112,7 @@ public ResponseEntity facilityV1SearchPost( @Valid @ModelAttribute URLParams urlParams, @ApiParam(value = "Details for existing facility.", required = true) @Valid @RequestBody FacilitySearchRequest request ) throws Exception { - List facilities = facilityService.search( + SearchResponse searchResponse = facilityService.search( request, urlParams.getLimit(), urlParams.getOffset(), @@ -119,7 +120,9 @@ public ResponseEntity facilityV1SearchPost( urlParams.getLastChangedSince(), urlParams.getIncludeDeleted()); FacilityBulkResponse response = FacilityBulkResponse.builder().responseInfo(ResponseInfoFactory - .createResponseInfo(request.getRequestInfo(), true)).facilities(facilities).build(); + .createResponseInfo(request.getRequestInfo(), true)) + .facilities(searchResponse.getResponse()) + .totalCount(searchResponse.getTotalCount()).build(); return ResponseEntity.status(HttpStatus.OK).body(response); } diff --git a/health-services/facility/src/test/java/org/egov/facility/validator/NonExistentEntityValidatorTest.java b/health-services/facility/src/test/java/org/egov/facility/validator/NonExistentEntityValidatorTest.java index a6e8c05f7c1..06955011bc0 100644 --- a/health-services/facility/src/test/java/org/egov/facility/validator/NonExistentEntityValidatorTest.java +++ b/health-services/facility/src/test/java/org/egov/facility/validator/NonExistentEntityValidatorTest.java @@ -1,8 +1,10 @@ package org.egov.facility.validator; import org.egov.common.models.Error; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.facility.Facility; import org.egov.common.models.facility.FacilityBulkRequest; +import org.egov.common.models.household.Household; import org.egov.facility.helper.FacilityBulkRequestTestBuilder; import org.egov.facility.helper.FacilityTestBuilder; import org.egov.facility.repository.FacilityRepository; @@ -37,7 +39,7 @@ class NonExistentEntityValidatorTest { void shouldAddToErrorDetailsMapIfEntityNotFound() { FacilityBulkRequest request = FacilityBulkRequestTestBuilder.builder().withFacilityId("some-id").withRequestInfo().build(); when(facilityRepository.findById(anyList(), anyString(), anyBoolean())) - .thenReturn(Collections.emptyList()); + .thenReturn(SearchResponse.builder().build()); Map> errorDetailsMap = fNonExistentValidator.validate(request); @@ -49,7 +51,9 @@ void shouldAddToErrorDetailsMapIfEntityNotFound() { void shouldNotAddToErrorDetailsMapIfEntityFound() { FacilityBulkRequest request = FacilityBulkRequestTestBuilder.builder().withFacilityId("some-id").withRequestInfo().build(); when(facilityRepository.findById(anyList(), anyString(), anyBoolean())) - .thenReturn(Collections.singletonList(FacilityTestBuilder.builder().withFacility().withId("some-id").build())); + .thenReturn(SearchResponse.builder(). + response(Collections.singletonList(FacilityTestBuilder.builder().withFacility().withId("some-id").build())) + .build()); Map> errorDetailsMap = fNonExistentValidator.validate(request); diff --git a/health-services/facility/src/test/java/org/egov/facility/validator/RowVersionValidatorTest.java b/health-services/facility/src/test/java/org/egov/facility/validator/RowVersionValidatorTest.java index 1f44a89f94a..52f92421c49 100644 --- a/health-services/facility/src/test/java/org/egov/facility/validator/RowVersionValidatorTest.java +++ b/health-services/facility/src/test/java/org/egov/facility/validator/RowVersionValidatorTest.java @@ -1,6 +1,7 @@ package org.egov.facility.validator; import org.egov.common.models.Error; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.facility.Facility; import org.egov.common.models.facility.FacilityBulkRequest; import org.egov.facility.helper.FacilityBulkRequestTestBuilder; @@ -39,7 +40,9 @@ void shouldAddToErrorDetailsIfRowVersionMismatchFound() { FacilityBulkRequest request = FacilityBulkRequestTestBuilder.builder().withFacilityId("some-id").withRequestInfo().build(); request.getFacilities().get(0).setRowVersion(2); when(facilityRepository.findById(anyList(), anyString(), anyBoolean())) - .thenReturn(Collections.singletonList(FacilityTestBuilder.builder().withFacility().withId("some-id").build())); + .thenReturn(SearchResponse.builder() + .response(Collections.singletonList(FacilityTestBuilder.builder().withFacility().withId("some-id").build())) + .build()); Map> errorDetailsMap = fRowVersionValidator.validate(request); @@ -51,7 +54,8 @@ void shouldAddToErrorDetailsIfRowVersionMismatchFound() { void shouldNotAddToErrorDetailsIfRowVersionSimilar() { FacilityBulkRequest request = FacilityBulkRequestTestBuilder.builder().withFacilityId("some-id").withRequestInfo().build(); when(facilityRepository.findById(anyList(), anyString(), anyBoolean())) - .thenReturn(Collections.singletonList(FacilityTestBuilder.builder().withFacility().withId("some-id").build())); + .thenReturn(SearchResponse.builder() + .response(Collections.singletonList(FacilityTestBuilder.builder().withFacility().withId("some-id").build())).build()); Map> errorDetailsMap = fRowVersionValidator.validate(request); diff --git a/health-services/libraries/health-services-models/pom.xml b/health-services/libraries/health-services-models/pom.xml index cae31ed2480..dc4e4c878ca 100644 --- a/health-services/libraries/health-services-models/pom.xml +++ b/health-services/libraries/health-services-models/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.egov.common health-services-models - 1.0.22-SNAPSHOT + 1.0.23-SNAPSHOT 17 ${java.version} diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/facility/FacilityBulkResponse.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/facility/FacilityBulkResponse.java index 4209e6e2311..ea647af0b1d 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/facility/FacilityBulkResponse.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/facility/FacilityBulkResponse.java @@ -17,8 +17,6 @@ * FacilityResponse */ @Validated - - @Data @NoArgsConstructor @AllArgsConstructor @@ -34,6 +32,14 @@ public class FacilityBulkResponse { @Valid private List facilities = null; + /** + * The total count of user actions in the response. + * It is initialized to 0 by default. + */ + @JsonProperty("TotalCount") + @Valid + @Builder.Default + private Long totalCount = 0L; public FacilityBulkResponse addFacilityItem(Facility facilityItem) { if (this.facilities == null) { From d2b8b8c8b553cbe38c51dc05e56a02ca91ebef9b Mon Sep 17 00:00:00 2001 From: kanishq-egov Date: Wed, 18 Sep 2024 12:56:42 +0530 Subject: [PATCH 2/5] HCMPRE-469: added changes for models, added totalCount fields in required model classes --- .../models/facility/FacilityBulkResponse.java | 17 ++++++++---- .../project/ProjectFacilityBulkResponse.java | 23 +++++++++++++--- .../project/ProjectResourceBulkResponse.java | 5 ++++ .../project/ProjectStaffBulkResponse.java | 27 +++++++++++++++---- .../hfreferral/HFReferralBulkResponse.java | 18 +++++++++++++ .../models/stock/StockBulkResponse.java | 26 +++++++++++++++--- .../StockReconciliationBulkResponse.java | 25 ++++++++++++++--- 7 files changed, 120 insertions(+), 21 deletions(-) diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/facility/FacilityBulkResponse.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/facility/FacilityBulkResponse.java index ea647af0b1d..e1550174657 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/facility/FacilityBulkResponse.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/facility/FacilityBulkResponse.java @@ -14,7 +14,7 @@ import org.springframework.validation.annotation.Validated; /** - * FacilityResponse + * Represents a bulk response for facilities, including response metadata and a list of facilities. */ @Validated @Data @@ -23,24 +23,33 @@ @Builder @JsonIgnoreProperties(ignoreUnknown = true) public class FacilityBulkResponse { + + /** + * Metadata about the API response, including request details and status. + */ @JsonProperty("ResponseInfo") @NotNull @Valid private org.egov.common.contract.response.ResponseInfo responseInfo = null; + /** + * List of facilities returned in the response. + */ @JsonProperty("Facilities") @Valid private List facilities = null; /** - * The total count of user actions in the response. - * It is initialized to 0 by default. + * Total number of facilities in the response, defaults to 0. */ @JsonProperty("TotalCount") @Valid @Builder.Default private Long totalCount = 0L; + /** + * Adds a single facility to the list and returns the updated response. + */ public FacilityBulkResponse addFacilityItem(Facility facilityItem) { if (this.facilities == null) { this.facilities = new ArrayList<>(); @@ -48,6 +57,4 @@ public FacilityBulkResponse addFacilityItem(Facility facilityItem) { this.facilities.add(facilityItem); return this; } - } - diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectFacilityBulkResponse.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectFacilityBulkResponse.java index 3b7c899ebfe..38d1df9eafa 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectFacilityBulkResponse.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectFacilityBulkResponse.java @@ -15,29 +15,46 @@ import org.springframework.validation.annotation.Validated; /** - * ProjectFacilityResponse + * Represents a bulk response for project facilities, including response metadata and a list of facilities. */ @Validated - - @Data @NoArgsConstructor @AllArgsConstructor @Builder @JsonIgnoreProperties(ignoreUnknown = true) public class ProjectFacilityBulkResponse { + + /** + * Metadata about the API response, including request details and status. + */ @JsonProperty("ResponseInfo") @NotNull @Valid private ResponseInfo responseInfo = null; + /** + * Total number of project facilities in the response, defaults to 0. + */ + @JsonProperty("TotalCount") + @Valid + @Builder.Default + private Long totalCount = 0L; + + /** + * List of project facilities returned in the response. + */ @JsonProperty("ProjectFacilities") @NotNull @Valid private List projectFacilities = new ArrayList<>(); + /** + * Adds a single project facility to the list and returns the updated response. + */ public ProjectFacilityBulkResponse addProjectFacilityItem(ProjectFacility projectFacilityItem) { this.projectFacilities.add(projectFacilityItem); return this; } } + diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectResourceBulkResponse.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectResourceBulkResponse.java index 2fdba28281a..7aef41e322b 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectResourceBulkResponse.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectResourceBulkResponse.java @@ -37,6 +37,11 @@ public class ProjectResourceBulkResponse { @Valid private List projectResource = new ArrayList<>(); + @JsonProperty("TotalCount") + @Valid + @Builder.Default + private Long totalCount = 0L; + public ProjectResourceBulkResponse addProjectResourceItem(ProjectResource projectResourceItem) { this.projectResource.add(projectResourceItem); return this; diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectStaffBulkResponse.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectStaffBulkResponse.java index 73d80462fb0..49070e25a94 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectStaffBulkResponse.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/ProjectStaffBulkResponse.java @@ -15,11 +15,9 @@ import org.springframework.validation.annotation.Validated; /** -* ProjectStaffResponse -*/ + * Represents a bulk response for project staff, containing response metadata and a list of staff members. + */ @Validated - - @Data @NoArgsConstructor @AllArgsConstructor @@ -27,19 +25,38 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class ProjectStaffBulkResponse { + /** + * Metadata about the API response, including request status and other information. + */ @JsonProperty("ResponseInfo") @NotNull @Valid private ResponseInfo responseInfo = null; + /** + * List of project staff members returned in the response. + */ @JsonProperty("ProjectStaff") @NotNull @Valid private List projectStaff = new ArrayList<>(); + /** + * Total number of project staff members in the response, defaults to 0 if not specified. + */ + @JsonProperty("TotalCount") + @Valid + @Builder.Default + private Long totalCount = 0L; + + /** + * Adds a single project staff member to the list and returns the updated response. + * + * @param projectStaffItem The project staff member to add to the list. + * @return The updated ProjectStaffBulkResponse instance. + */ public ProjectStaffBulkResponse addProjectStaffItem(ProjectStaff projectStaffItem) { this.projectStaff.add(projectStaffItem); return this; } } - diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/hfreferral/HFReferralBulkResponse.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/hfreferral/HFReferralBulkResponse.java index a561ef4f8a4..d8791d66979 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/hfreferral/HFReferralBulkResponse.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/referralmanagement/hfreferral/HFReferralBulkResponse.java @@ -13,21 +13,39 @@ import lombok.NoArgsConstructor; import org.egov.common.contract.response.ResponseInfo; +/** + * Represents a bulk response for HF (Health Facility) referrals, containing response metadata and a list of referrals. + */ @Data @NoArgsConstructor @AllArgsConstructor @Builder public class HFReferralBulkResponse { + + /** + * Metadata about the API response, including details such as request status and information. + */ @JsonProperty("ResponseInfo") @NotNull @Valid private ResponseInfo responseInfo; + /** + * List of health facility referrals returned in the response. + */ @JsonProperty("HFReferrals") @NotNull @Valid private List hfReferrals; + /** + * Total number of HF referrals in the response, defaults to 0 if not specified. + */ + @JsonProperty("TotalCount") + @Valid + @Builder.Default + private Long totalCount = 0L; + /** * Add a HfReferral item to the list of HfReferrals in the bulk response. * diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/stock/StockBulkResponse.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/stock/StockBulkResponse.java index 3f52835a270..3ad45bc8ed7 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/stock/StockBulkResponse.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/stock/StockBulkResponse.java @@ -14,11 +14,9 @@ import org.springframework.validation.annotation.Validated; /** - * StockResponse + * Represents a bulk response for stock items, containing response metadata and a list of stock entries. */ @Validated - - @Data @NoArgsConstructor @AllArgsConstructor @@ -26,20 +24,40 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class StockBulkResponse { + /** + * Metadata about the API response, including details such as request status and information. + */ @JsonProperty("ResponseInfo") @NotNull @Valid private org.egov.common.contract.response.ResponseInfo responseInfo = null; + /** + * List of stock items returned in the response. + */ @JsonProperty("Stock") @NotNull @Valid private List stock = new ArrayList<>(); - + /** + * Total number of stock items in the response, defaults to 0 if not specified. + */ + @JsonProperty("TotalCount") + @Valid + @Builder.Default + private Long totalCount = 0L; + + /** + * Adds a single stock item to the list of stock and returns the updated response. + * + * @param stockItem The stock item to add to the list. + * @return The updated StockBulkResponse instance. + */ public StockBulkResponse addStockItem(Stock stockItem) { this.stock.add(stockItem); return this; } } + diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/stock/StockReconciliationBulkResponse.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/stock/StockReconciliationBulkResponse.java index 17ea81e8ed7..bae326d2dd8 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/stock/StockReconciliationBulkResponse.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/stock/StockReconciliationBulkResponse.java @@ -14,11 +14,9 @@ import org.springframework.validation.annotation.Validated; /** - * StockReconciliationResponse + * Represents a bulk response for stock reconciliation, containing response metadata and a list of stock reconciliation entries. */ @Validated - - @Data @NoArgsConstructor @AllArgsConstructor @@ -26,19 +24,38 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class StockReconciliationBulkResponse { + /** + * Metadata about the API response, including details such as request status and information. + */ @JsonProperty("ResponseInfo") @NotNull @Valid private org.egov.common.contract.response.ResponseInfo responseInfo = null; + /** + * List of stock reconciliation items returned in the response. + */ @JsonProperty("StockReconciliation") @NotNull @Valid private List stockReconciliation = new ArrayList<>(); + /** + * Total number of stock reconciliation items in the response, defaults to 0 if not specified. + */ + @JsonProperty("TotalCount") + @Valid + @Builder.Default + private Long totalCount = 0L; + + /** + * Adds a single stock reconciliation item to the list and returns the updated response. + * + * @param stockReconciliationItem The stock reconciliation item to add to the list. + * @return The updated StockReconciliationBulkResponse instance. + */ public StockReconciliationBulkResponse addStockReconciliationItem(StockReconciliation stockReconciliationItem) { this.stockReconciliation.add(stockReconciliationItem); return this; } } - From 17b24ce02d4092858cac15077fb90932f791fc26 Mon Sep 17 00:00:00 2001 From: kanishq-egov Date: Wed, 18 Sep 2024 15:50:09 +0530 Subject: [PATCH 3/5] HCMPRE-469: added changes for project facility, project staff, project resource, hf-referral, stock and stock reconciliation, also added helper function in common utils for findWithCount --- health-services/facility/pom.xml | 2 +- .../libraries/health-services-common/pom.xml | 4 +- .../data/repository/GenericRepository.java | 48 +++++++++++++++++++ .../libraries/health-services-models/pom.xml | 2 +- .../individual/IndividualBulkResponse.java | 24 +++++++--- health-services/project/pom.xml | 4 +- .../repository/ProjectFacilityRepository.java | 11 +++-- .../service/ProjectFacilityService.java | 31 ++++++------ .../service/ProjectResourceService.java | 18 +++---- .../project/service/ProjectStaffService.java | 20 ++++---- .../web/controllers/ProjectApiController.java | 10 ++-- .../ProjectResourceApiController.java | 8 +++- .../ProjectFacilityServiceSearchTest.java | 4 +- .../ProjectStaffServiceSearchTest.java | 4 +- .../ProjectFacilityApiControllerTest.java | 6 ++- .../ProjectStaffApiControllerTest.java | 3 +- health-services/referralmanagement/pom.xml | 2 +- .../repository/HFReferralRepository.java | 19 +++++--- .../service/HFReferralService.java | 16 ++++--- .../HfrNonExistentEntityValidator.java | 3 +- .../hfreferral/HfrRowVersionValidator.java | 2 +- .../controllers/HFReferralApiController.java | 8 +++- health-services/stock/pom.xml | 4 +- .../service/StockReconciliationService.java | 18 +++---- .../org/egov/stock/service/StockService.java | 18 +++---- .../web/controllers/StockApiController.java | 5 +- .../StockReconciliationApiController.java | 8 +++- 27 files changed, 201 insertions(+), 101 deletions(-) diff --git a/health-services/facility/pom.xml b/health-services/facility/pom.xml index 3d25b5d9780..5598fb8b333 100644 --- a/health-services/facility/pom.xml +++ b/health-services/facility/pom.xml @@ -50,7 +50,7 @@ org.egov.common health-services-models - 1.0.23-SNAPSHOT + 1.0.23-dev-SNAPSHOT compile diff --git a/health-services/libraries/health-services-common/pom.xml b/health-services/libraries/health-services-common/pom.xml index 17c27125802..701a70a2cc2 100644 --- a/health-services/libraries/health-services-common/pom.xml +++ b/health-services/libraries/health-services-common/pom.xml @@ -8,7 +8,7 @@ health-services-common jar health-services-common - 1.0.19-SNAPSHOT + 1.0.20-dev-SNAPSHOT Shared classes among services @@ -115,7 +115,7 @@ org.egov.common health-services-models - 1.0.22-SNAPSHOT + 1.0.23-dev-SNAPSHOT compile diff --git a/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/repository/GenericRepository.java b/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/repository/GenericRepository.java index 537a82400cc..269a15e449d 100644 --- a/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/repository/GenericRepository.java +++ b/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/repository/GenericRepository.java @@ -4,6 +4,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import org.egov.common.data.query.builder.SelectQueryBuilder; import org.egov.common.data.query.exception.QueryBuilderException; +import org.egov.common.models.core.SearchResponse; import org.egov.common.producer.Producer; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; @@ -23,6 +24,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import static org.egov.common.utils.CommonUtils.constructTotalCountCTEAndReturnResult; import static org.egov.common.utils.CommonUtils.getIdMethod; import static org.egov.common.utils.CommonUtils.getMethod; import static org.egov.common.utils.CommonUtils.getObjClass; @@ -236,6 +238,52 @@ public void putInCache(List objects, String key) { cacheByKey(objects, key); } + /** + * Finds entities based on search criteria, also returns the count of entities found. + * + * @param searchObject The object containing search criteria. + * @param limit The maximum number of entities to return. + * @param offset The offset for pagination. + * @param tenantId The tenant ID to filter entities. + * @param lastChangedSince The timestamp for last modified entities. + * @param includeDeleted Flag to include deleted entities in the search result. + * @return A list of entities found based on the search criteria with total count. + * @throws QueryBuilderException If an error occurs while building the query. + */ + public SearchResponse findWithCount(Object searchObject, + Integer limit, + Integer offset, + String tenantId, + Long lastChangedSince, + Boolean includeDeleted) throws QueryBuilderException { + String query = selectQueryBuilder.build(searchObject, tableName); + query += " AND tenantId=:tenantId "; + if (query.contains(tableName + " AND")) { + query = query.replace(tableName + " AND", tableName + " WHERE"); + } + if (Boolean.FALSE.equals(includeDeleted)) { + query += "AND isDeleted=:isDeleted "; + } + if (lastChangedSince != null) { + query += "AND lastModifiedTime>=:lastModifiedTime "; + } + query += "ORDER BY id ASC"; + Map paramsMap = selectQueryBuilder.getParamsMap(); + paramsMap.put("tenantId", tenantId); + paramsMap.put("isDeleted", includeDeleted); + paramsMap.put("lastModifiedTime", lastChangedSince); + + Long totalCount = constructTotalCountCTEAndReturnResult(query, paramsMap, namedParameterJdbcTemplate); + + query += " LIMIT :limit OFFSET :offset"; + paramsMap.put("limit", limit); + paramsMap.put("offset", offset); + + List resultantList = namedParameterJdbcTemplate.query(query, paramsMap, rowMapper); + + return SearchResponse.builder().response(resultantList).totalCount(totalCount).build(); + } + /** * Finds entities based on search criteria. * diff --git a/health-services/libraries/health-services-models/pom.xml b/health-services/libraries/health-services-models/pom.xml index dc4e4c878ca..79222b5b9a7 100644 --- a/health-services/libraries/health-services-models/pom.xml +++ b/health-services/libraries/health-services-models/pom.xml @@ -5,7 +5,7 @@ 4.0.0 org.egov.common health-services-models - 1.0.23-SNAPSHOT + 1.0.23-dev-SNAPSHOT 17 ${java.version} diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/individual/IndividualBulkResponse.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/individual/IndividualBulkResponse.java index 6ed081c182e..60647504677 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/individual/IndividualBulkResponse.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/individual/IndividualBulkResponse.java @@ -15,11 +15,10 @@ import org.springframework.validation.annotation.Validated; /** - * IndividualResponse + * IndividualBulkResponse represents the response structure for bulk operations related to individuals. + * It encapsulates the response information, total count of individuals, and a list of individual objects. */ @Validated - - @Data @NoArgsConstructor @AllArgsConstructor @@ -27,20 +26,35 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class IndividualBulkResponse { + /** + * Metadata about the API response, including details like request status and other information. + */ @JsonProperty("ResponseInfo") @NotNull @Valid private ResponseInfo responseInfo = null; + /** + * Total count of individual records in the response, defaults to 0 if not specified. + */ @JsonProperty("TotalCount") @Valid @Builder.Default private Long totalCount = 0L; - + + /** + * List of individual records returned in the response. + */ @JsonProperty("Individual") @Valid private List individual = null; + /** + * Adds a single individual record to the list and returns the updated response. + * + * @param individualItem The individual record to add to the list. + * @return The updated IndividualBulkResponse instance. + */ public IndividualBulkResponse addIndividualItem(Individual individualItem) { if (this.individual == null) { this.individual = new ArrayList<>(); @@ -48,6 +62,4 @@ public IndividualBulkResponse addIndividualItem(Individual individualItem) { this.individual.add(individualItem); return this; } - } - diff --git a/health-services/project/pom.xml b/health-services/project/pom.xml index fd0b688dcc3..9cb321d57d0 100644 --- a/health-services/project/pom.xml +++ b/health-services/project/pom.xml @@ -45,12 +45,12 @@ org.egov.common health-services-common - 1.0.18-SNAPSHOT + 1.0.20-dev-SNAPSHOT org.egov.common health-services-models - 1.0.21-SNAPSHOT + 1.0.23-dev-SNAPSHOT compile diff --git a/health-services/project/src/main/java/org/egov/project/repository/ProjectFacilityRepository.java b/health-services/project/src/main/java/org/egov/project/repository/ProjectFacilityRepository.java index d602f809b15..219a38458ec 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/ProjectFacilityRepository.java +++ b/health-services/project/src/main/java/org/egov/project/repository/ProjectFacilityRepository.java @@ -1,9 +1,13 @@ package org.egov.project.repository; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; import lombok.extern.slf4j.Slf4j; import org.egov.common.data.query.builder.SelectQueryBuilder; +import org.egov.common.data.query.exception.QueryBuilderException; import org.egov.common.data.repository.GenericRepository; import org.egov.common.models.project.ProjectFacility; +import org.egov.common.models.project.ProjectFacilitySearch; import org.egov.common.producer.Producer; import org.egov.project.repository.rowmapper.ProjectFacilityRowMapper; import org.springframework.beans.factory.annotation.Autowired; @@ -11,15 +15,16 @@ import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.stereotype.Repository; +import java.util.List; import java.util.Optional; @Repository @Slf4j public class ProjectFacilityRepository extends GenericRepository { @Autowired public ProjectFacilityRepository(Producer producer, NamedParameterJdbcTemplate namedParameterJdbcTemplate, - RedisTemplate redisTemplate, - SelectQueryBuilder selectQueryBuilder, ProjectFacilityRowMapper projectFacilityRowMapper) { + RedisTemplate redisTemplate, + SelectQueryBuilder selectQueryBuilder, ProjectFacilityRowMapper projectFacilityRowMapper) { super(producer, namedParameterJdbcTemplate, redisTemplate, selectQueryBuilder, projectFacilityRowMapper, Optional.of("project_facility")); } -} +} \ No newline at end of file diff --git a/health-services/project/src/main/java/org/egov/project/service/ProjectFacilityService.java b/health-services/project/src/main/java/org/egov/project/service/ProjectFacilityService.java index f7628318789..9e5e47675bb 100644 --- a/health-services/project/src/main/java/org/egov/project/service/ProjectFacilityService.java +++ b/health-services/project/src/main/java/org/egov/project/service/ProjectFacilityService.java @@ -1,9 +1,16 @@ package org.egov.project.service; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.function.Predicate; +import java.util.stream.Collectors; + import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; import org.egov.common.ds.Tuple; import org.egov.common.models.ErrorDetails; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.project.ProjectFacility; import org.egov.common.models.project.ProjectFacilityBulkRequest; import org.egov.common.models.project.ProjectFacilityRequest; @@ -27,12 +34,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; -import java.util.stream.Collectors; - import static org.egov.common.utils.CommonUtils.handleErrors; import static org.egov.common.utils.CommonUtils.havingTenantId; import static org.egov.common.utils.CommonUtils.includeDeleted; @@ -214,27 +215,27 @@ private Tuple, Map> validat return new Tuple<>(validEntities, errorDetailsMap); } - public List search(ProjectFacilitySearchRequest projectFacilitySearchRequest, - Integer limit, - Integer offset, - String tenantId, - Long lastChangedSince, - Boolean includeDeleted) throws Exception { + public SearchResponse search(ProjectFacilitySearchRequest projectFacilitySearchRequest, + Integer limit, + Integer offset, + String tenantId, + Long lastChangedSince, + Boolean includeDeleted) throws Exception { log.info("received request to search project facility"); if (isSearchByIdOnly(projectFacilitySearchRequest.getProjectFacility())) { log.info("searching project facility by id"); List ids = projectFacilitySearchRequest.getProjectFacility().getId(); log.info("fetching project facility with ids: {}", ids); - return projectFacilityRepository.findById(ids, includeDeleted).stream() + List projectfacilities = projectFacilityRepository.findById(ids, includeDeleted).stream() .filter(lastChangedSince(lastChangedSince)) .filter(havingTenantId(tenantId)) .filter(includeDeleted(includeDeleted)) .collect(Collectors.toList()); + return SearchResponse.builder().response(projectfacilities).build(); } log.info("searching project facility using criteria"); - return projectFacilityRepository.find(projectFacilitySearchRequest.getProjectFacility(), + return projectFacilityRepository.findWithCount(projectFacilitySearchRequest.getProjectFacility(), limit, offset, tenantId, lastChangedSince, includeDeleted); } - } diff --git a/health-services/project/src/main/java/org/egov/project/service/ProjectResourceService.java b/health-services/project/src/main/java/org/egov/project/service/ProjectResourceService.java index 660efbd4814..8f8c2555947 100644 --- a/health-services/project/src/main/java/org/egov/project/service/ProjectResourceService.java +++ b/health-services/project/src/main/java/org/egov/project/service/ProjectResourceService.java @@ -5,6 +5,7 @@ import org.egov.common.data.query.exception.QueryBuilderException; import org.egov.common.ds.Tuple; import org.egov.common.models.ErrorDetails; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.project.ProjectResource; import org.egov.common.models.project.ProjectResourceBulkRequest; import org.egov.common.models.project.ProjectResourceRequest; @@ -182,27 +183,28 @@ public List delete(ProjectResourceBulkRequest request, boolean } - public List search(ProjectResourceSearchRequest request, - Integer limit, - Integer offset, - String tenantId, - Long lastChangedSince, - Boolean includeDeleted) throws QueryBuilderException { + public SearchResponse search(ProjectResourceSearchRequest request, + Integer limit, + Integer offset, + String tenantId, + Long lastChangedSince, + Boolean includeDeleted) throws QueryBuilderException { String idFieldName = getIdFieldName(request.getProjectResource()); if (isSearchByIdOnly(request.getProjectResource(), idFieldName)) { List ids = (List) ReflectionUtils.invokeMethod(getIdMethod((Collections .singletonList(request.getProjectResource()))), request.getProjectResource()); - return projectResourceRepository.findById(ids, includeDeleted, idFieldName).stream() + List projectResources = projectResourceRepository.findById(ids, includeDeleted, idFieldName).stream() .filter(lastChangedSince(lastChangedSince)) .filter(havingTenantId(tenantId)) .filter(includeDeleted(includeDeleted)) .collect(Collectors.toList()); + return SearchResponse.builder().response(projectResources).build(); } log.info("completed search method for project resource"); - return projectResourceRepository.find(request.getProjectResource(), + return projectResourceRepository.findWithCount(request.getProjectResource(), limit, offset, tenantId, lastChangedSince, includeDeleted); } } diff --git a/health-services/project/src/main/java/org/egov/project/service/ProjectStaffService.java b/health-services/project/src/main/java/org/egov/project/service/ProjectStaffService.java index c600537a74e..d172b96263f 100644 --- a/health-services/project/src/main/java/org/egov/project/service/ProjectStaffService.java +++ b/health-services/project/src/main/java/org/egov/project/service/ProjectStaffService.java @@ -4,6 +4,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import org.egov.common.ds.Tuple; import org.egov.common.models.ErrorDetails; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.project.ProjectStaff; import org.egov.common.models.project.ProjectStaffBulkRequest; import org.egov.common.models.project.ProjectStaffRequest; @@ -28,9 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.lang.reflect.Type; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.Predicate; @@ -224,26 +223,27 @@ private Tuple, Map> validate(List return new Tuple<>(validEntities, errorDetailsMap); } - public List search(ProjectStaffSearchRequest projectStaffSearchRequest, - Integer limit, - Integer offset, - String tenantId, - Long lastChangedSince, - Boolean includeDeleted) throws Exception { + public SearchResponse search(ProjectStaffSearchRequest projectStaffSearchRequest, + Integer limit, + Integer offset, + String tenantId, + Long lastChangedSince, + Boolean includeDeleted) throws Exception { log.info("received request to search project staff"); if (isSearchByIdOnly(projectStaffSearchRequest.getProjectStaff())) { log.info("searching project staff by id"); List ids = projectStaffSearchRequest.getProjectStaff().getId(); log.info("fetching project staff with ids: {}", ids); - return projectStaffRepository.findById(ids, includeDeleted).stream() + List projectStaffs = projectStaffRepository.findById(ids, includeDeleted).stream() .filter(lastChangedSince(lastChangedSince)) .filter(havingTenantId(tenantId)) .filter(includeDeleted(includeDeleted)) .collect(Collectors.toList()); + return SearchResponse.builder().response(projectStaffs).build(); } log.info("searching project staff using criteria"); - return projectStaffRepository.find(projectStaffSearchRequest.getProjectStaff(), + return projectStaffRepository.findWithCount(projectStaffSearchRequest.getProjectStaff(), limit, offset, tenantId, lastChangedSince, includeDeleted); } diff --git a/health-services/project/src/main/java/org/egov/project/web/controllers/ProjectApiController.java b/health-services/project/src/main/java/org/egov/project/web/controllers/ProjectApiController.java index 1b74b7ab1d7..2ec0adc34d3 100644 --- a/health-services/project/src/main/java/org/egov/project/web/controllers/ProjectApiController.java +++ b/health-services/project/src/main/java/org/egov/project/web/controllers/ProjectApiController.java @@ -220,7 +220,7 @@ public ResponseEntity projectFacilityV2SearchPost( @Valid @ModelAttribute URLParams urlParams, @ApiParam(value = "Capture details of Project facility.", required = true) @Valid @RequestBody ProjectFacilitySearchRequest projectFacilitySearchRequest ) throws Exception { - List projectFacilities = projectFacilityService.search( + SearchResponse searchResponse = projectFacilityService.search( projectFacilitySearchRequest, urlParams.getLimit(), urlParams.getOffset(), @@ -229,7 +229,8 @@ public ResponseEntity projectFacilityV2SearchPost( urlParams.getIncludeDeleted() ); ProjectFacilityBulkResponse response = ProjectFacilityBulkResponse.builder() - .projectFacilities(projectFacilities) + .projectFacilities(searchResponse.getResponse()) + .totalCount(searchResponse.getTotalCount()) .responseInfo(ResponseInfoFactory .createResponseInfo(projectFacilitySearchRequest.getRequestInfo(), true)) .build(); @@ -310,7 +311,7 @@ public ResponseEntity projectStaffV1SearchPost( @Valid @ModelAttribute URLParams urlParams, @ApiParam(value = "Capture details of Project staff.", required = true) @Valid @RequestBody ProjectStaffSearchRequest projectStaffSearchRequest ) throws Exception { - List projectStaffList = projectStaffService.search( + SearchResponse searchResponse = projectStaffService.search( projectStaffSearchRequest, urlParams.getLimit(), urlParams.getOffset(), @@ -319,7 +320,8 @@ public ResponseEntity projectStaffV1SearchPost( urlParams.getIncludeDeleted() ); ProjectStaffBulkResponse response = ProjectStaffBulkResponse.builder() - .projectStaff(projectStaffList) + .projectStaff(searchResponse.getResponse()) + .totalCount(searchResponse.getTotalCount()) .responseInfo(ResponseInfoFactory .createResponseInfo(projectStaffSearchRequest.getRequestInfo(), true)) .build(); diff --git a/health-services/project/src/main/java/org/egov/project/web/controllers/ProjectResourceApiController.java b/health-services/project/src/main/java/org/egov/project/web/controllers/ProjectResourceApiController.java index 6f71ea7ef93..ef0522cfbf0 100644 --- a/health-services/project/src/main/java/org/egov/project/web/controllers/ProjectResourceApiController.java +++ b/health-services/project/src/main/java/org/egov/project/web/controllers/ProjectResourceApiController.java @@ -7,6 +7,7 @@ import jakarta.validation.Valid; import org.egov.common.contract.response.ResponseInfo; import org.egov.common.data.query.exception.QueryBuilderException; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.core.URLParams; import org.egov.common.models.project.ProjectResource; import org.egov.common.models.project.ProjectResourceBulkRequest; @@ -75,7 +76,7 @@ public ResponseEntity resourceV1SearchPost( @ApiParam(value = "Search linkage of Project and resource.", required = true) @Valid @RequestBody ProjectResourceSearchRequest projectResourceSearchRequest ) throws QueryBuilderException { - List projectResource = projectResourceService.search( + SearchResponse searchResponse = projectResourceService.search( projectResourceSearchRequest, urlParams.getLimit(), urlParams.getOffset(), @@ -84,7 +85,10 @@ public ResponseEntity resourceV1SearchPost( urlParams.getIncludeDeleted() ); ProjectResourceBulkResponse response = ProjectResourceBulkResponse.builder().responseInfo(ResponseInfoFactory - .createResponseInfo(projectResourceSearchRequest.getRequestInfo(), true)).projectResource(projectResource).build(); + .createResponseInfo(projectResourceSearchRequest.getRequestInfo(), true)) + .projectResource(searchResponse.getResponse()) + .totalCount(searchResponse.getTotalCount()) + .build(); return ResponseEntity.status(HttpStatus.OK).body(response); } diff --git a/health-services/project/src/test/java/org/egov/project/service/ProjectFacilityServiceSearchTest.java b/health-services/project/src/test/java/org/egov/project/service/ProjectFacilityServiceSearchTest.java index 6eed8465ca5..ae43fc65769 100644 --- a/health-services/project/src/test/java/org/egov/project/service/ProjectFacilityServiceSearchTest.java +++ b/health-services/project/src/test/java/org/egov/project/service/ProjectFacilityServiceSearchTest.java @@ -87,7 +87,7 @@ void shouldReturnProjectFacilityIfSearchCriteriaIsMatched() throws Exception { .withCompleteRequestInfo().build()).build(); List projectFacilities = projectFacilityService.search(projectFacilitySearchRequest, - 10, 0, "default", null, false); + 10, 0, "default", null, false).getResponse(); assertEquals(1, projectFacilities.size()); } @@ -104,7 +104,7 @@ void shouldReturnFromCacheIfSearchCriteriaHasIdOnly() throws Exception { when(projectFacilityRepository.findById(anyList(), anyBoolean())).thenReturn(projectFacilities); List projectFacilities = projectFacilityService.search(projectFacilitySearchRequest, - 10, 0, null, null, true); + 10, 0, null, null, true).getResponse(); assertEquals(1, projectFacilities.size()); } diff --git a/health-services/project/src/test/java/org/egov/project/service/ProjectStaffServiceSearchTest.java b/health-services/project/src/test/java/org/egov/project/service/ProjectStaffServiceSearchTest.java index 36aa7100f8d..de62e784f26 100644 --- a/health-services/project/src/test/java/org/egov/project/service/ProjectStaffServiceSearchTest.java +++ b/health-services/project/src/test/java/org/egov/project/service/ProjectStaffServiceSearchTest.java @@ -83,7 +83,7 @@ void shouldReturnProjectStaffIfSearchCriteriaIsMatched() throws Exception { .projectStaff(projectStaffSearch).requestInfo(RequestInfoTestBuilder.builder() .withCompleteRequestInfo().build()).build(); - List projectStaffs = projectStaffService.search(projectStaffSearchRequest, 10, 0, "default", null, false); + List projectStaffs = projectStaffService.search(projectStaffSearchRequest, 10, 0, "default", null, false).getResponse(); assertEquals(1, projectStaffs.size()); } @@ -100,7 +100,7 @@ void shouldReturnFromCacheIfSearchCriteriaHasIdOnly() throws Exception { when(projectStaffRepository.findById(anyList(), anyBoolean())).thenReturn(projectStaffs); List projectStaffs = projectStaffService.search(projectStaffSearchRequest, - 10, 0, null, null, true); + 10, 0, null, null, true).getResponse(); assertEquals(1, projectStaffs.size()); } diff --git a/health-services/project/src/test/java/org/egov/project/web/controllers/ProjectFacilityApiControllerTest.java b/health-services/project/src/test/java/org/egov/project/web/controllers/ProjectFacilityApiControllerTest.java index e6a97cf70c8..fe6a8e402db 100644 --- a/health-services/project/src/test/java/org/egov/project/web/controllers/ProjectFacilityApiControllerTest.java +++ b/health-services/project/src/test/java/org/egov/project/web/controllers/ProjectFacilityApiControllerTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.egov.common.helper.RequestInfoTestBuilder; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.project.ProjectFacility; import org.egov.common.models.project.ProjectFacilityBulkRequest; import org.egov.common.models.project.ProjectFacilityBulkResponse; @@ -193,8 +194,9 @@ void shouldAcceptSearchRequestAndReturnProjectFacility() throws Exception { any(Integer.class), any(String.class), any(Long.class), - any(Boolean.class))).thenReturn(Arrays.asList(ProjectFacilityTestBuilder.builder() - .withId().withAuditDetails().build())); + any(Boolean.class))).thenReturn(SearchResponse.builder() + .response(Arrays.asList(ProjectFacilityTestBuilder.builder() + .withId().withAuditDetails().build())).build()); final MvcResult result = mockMvc.perform(post( "/facility/v1/_search?limit=10&offset=100&tenantId=default&lastChangedSince=1234322&includeDeleted=false") diff --git a/health-services/project/src/test/java/org/egov/project/web/controllers/ProjectStaffApiControllerTest.java b/health-services/project/src/test/java/org/egov/project/web/controllers/ProjectStaffApiControllerTest.java index 1e1b5409485..2147e98e460 100644 --- a/health-services/project/src/test/java/org/egov/project/web/controllers/ProjectStaffApiControllerTest.java +++ b/health-services/project/src/test/java/org/egov/project/web/controllers/ProjectStaffApiControllerTest.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.egov.common.helper.RequestInfoTestBuilder; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.project.ProjectStaff; import org.egov.common.models.project.ProjectStaffBulkResponse; import org.egov.common.models.project.ProjectStaffRequest; @@ -175,7 +176,7 @@ void shouldAcceptSearchRequestAndReturnProjectStaff() throws Exception { any(Integer.class), any(String.class), any(Long.class), - any(Boolean.class))).thenReturn(Arrays.asList(ProjectStaffTestBuilder.builder().withId().withAuditDetails().build())); + any(Boolean.class))).thenReturn(SearchResponse.builder().response(Arrays.asList(ProjectStaffTestBuilder.builder().withId().withAuditDetails().build())).build()); final MvcResult result = mockMvc.perform(post( "/staff/v1/_search?limit=10&offset=100&tenantId=default&lastChangedSince=1234322&includeDeleted=false") diff --git a/health-services/referralmanagement/pom.xml b/health-services/referralmanagement/pom.xml index b9d85ad8269..c7e1e5b127e 100644 --- a/health-services/referralmanagement/pom.xml +++ b/health-services/referralmanagement/pom.xml @@ -51,7 +51,7 @@ org.egov.common health-services-models - 1.0.20-SNAPSHOT + 1.0.23-dev-SNAPSHOT compile diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HFReferralRepository.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HFReferralRepository.java index d2d43634030..0fee8b9d853 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HFReferralRepository.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HFReferralRepository.java @@ -12,6 +12,7 @@ import org.egov.common.data.query.builder.QueryFieldChecker; import org.egov.common.data.query.builder.SelectQueryBuilder; import org.egov.common.data.repository.GenericRepository; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.referralmanagement.hfreferral.HFReferral; import org.egov.common.models.referralmanagement.hfreferral.HFReferralSearch; import org.egov.common.producer.Producer; @@ -23,6 +24,7 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.ReflectionUtils; +import static org.egov.common.utils.CommonUtils.constructTotalCountCTEAndReturnResult; import static org.egov.common.utils.CommonUtils.getIdMethod; /** @@ -66,7 +68,7 @@ protected HFReferralRepository(Producer producer, NamedParameterJdbcTemplate nam * @param includeDeleted Flag indicating whether to include deleted records. * @return A list of HFReferral entities matching the search criteria. */ - public List find(HFReferralSearch searchObject, Integer limit, Integer offset, String tenantId, + public SearchResponse find(HFReferralSearch searchObject, Integer limit, Integer offset, String tenantId, Long lastChangedSince, Boolean includeDeleted) { // Initial query to select HFReferral fields from the table. String query = "SELECT hf.id, hf.clientreferenceid, hf.tenantid, hf.projectid, hf.projectfacilityid, hf.symptom, hf.symptomsurveyid, hf.beneficiaryid, hf.referralcode, hf.nationallevelid, hf.createdby, hf.createdtime, hf.lastmodifiedby, hf.lastmodifiedtime, hf.clientcreatedby, hf.clientcreatedtime, hf.clientlastmodifiedby, hf.clientlastmodifiedtime, hf.rowversion, hf.isdeleted, hf.additionaldetails from hf_referral hf"; @@ -96,16 +98,21 @@ public List find(HFReferralSearch searchObject, Integer limit, Integ } // Add ORDER BY, LIMIT, and OFFSET clauses to the query. - query = query + "ORDER BY hf.createdtime DESC LIMIT :limit OFFSET :offset"; + query = query + "ORDER BY hf.createdtime DESC"; paramsMap.put("tenantId", tenantId); paramsMap.put("isDeleted", includeDeleted); paramsMap.put("lastModifiedTime", lastChangedSince); + + Long totalCount = constructTotalCountCTEAndReturnResult(query, paramsMap, this.namedParameterJdbcTemplate); + + query += " LIMIT :limit OFFSET :offset"; paramsMap.put("limit", limit); paramsMap.put("offset", offset); // Execute the query and retrieve the list of HFReferral entities. List hfReferralList = this.namedParameterJdbcTemplate.query(query, paramsMap, this.rowMapper); - return hfReferralList; + + return SearchResponse.builder().response(hfReferralList).totalCount(totalCount).build(); } /** @@ -116,7 +123,7 @@ public List find(HFReferralSearch searchObject, Integer limit, Integ * @param columnName The column name to search for IDs. * @return A list of HFReferral entities matching the provided IDs. */ - public List findById(List ids, Boolean includeDeleted, String columnName) { + public SearchResponse findById(List ids, String columnName, Boolean includeDeleted) { // Find objects in the cache based on the provided IDs. List objFound = findInCache(ids); if (!includeDeleted) { @@ -134,7 +141,7 @@ public List findById(List ids, Boolean includeDeleted, Strin // If no IDs are remaining, return the objects found in the cache. if (ids.isEmpty()) { - return objFound; + return SearchResponse.builder().response(objFound).build(); } } @@ -154,6 +161,6 @@ public List findById(List ids, Boolean includeDeleted, Strin // Add the retrieved entities to the cache. objFound.addAll(hfReferralList); putInCache(objFound); - return objFound; + return SearchResponse.builder().response(objFound).build(); } } diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/HFReferralService.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/HFReferralService.java index c3c287bcff3..bc6aa52dc33 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/HFReferralService.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/HFReferralService.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.egov.common.ds.Tuple; import org.egov.common.models.ErrorDetails; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.referralmanagement.hfreferral.HFReferral; import org.egov.common.models.referralmanagement.hfreferral.HFReferralBulkRequest; import org.egov.common.models.referralmanagement.hfreferral.HFReferralRequest; @@ -169,12 +170,12 @@ public List update(HFReferralBulkRequest hfReferralRequest, boolean } // Method to search for HFReferrals based on certain criteria - public List search(HFReferralSearchRequest referralSearchRequest, - Integer limit, - Integer offset, - String tenantId, - Long lastChangedSince, - Boolean includeDeleted) { + public SearchResponse search(HFReferralSearchRequest referralSearchRequest, + Integer limit, + Integer offset, + String tenantId, + Long lastChangedSince, + Boolean includeDeleted) { log.info("Received request to search referrals"); String idFieldName = getIdFieldName(referralSearchRequest.getHfReferral()); @@ -186,11 +187,12 @@ public List search(HFReferralSearchRequest referralSearchRequest, referralSearchRequest.getHfReferral()); log.info("Fetching referrals with IDs: {}", ids); - return hfReferralRepository.findById(ids, includeDeleted, idFieldName).stream() + List hfReferrals = hfReferralRepository.findById(ids, idFieldName, includeDeleted).getResponse().stream() .filter(lastChangedSince(lastChangedSince)) .filter(havingTenantId(tenantId)) .filter(includeDeleted(includeDeleted)) .collect(Collectors.toList()); + return SearchResponse.builder().response(hfReferrals).build(); } log.info("Searching referrals using criteria"); diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrNonExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrNonExistentEntityValidator.java index 3011cef48ce..d7e81c7e9a4 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrNonExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrNonExistentEntityValidator.java @@ -82,7 +82,8 @@ public Map> validate(HFReferralBulkRequest request) { try { // Query the repository to find existing entities existingReferrals = hfReferralRepository.find(hfReferralSearch, hfReferrals.size(), 0, - hfReferrals.get(0).getTenantId(), null, false); + hfReferrals.get(0).getTenantId(), null, false).getResponse() + ; } catch (Exception e) { // Handle query builder exception log.error("Search failed for HFReferral with error: {}", e.getMessage(), e); diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrRowVersionValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrRowVersionValidator.java index e5d62bfee0a..495c0963b63 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrRowVersionValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrRowVersionValidator.java @@ -61,7 +61,7 @@ public Map> validate(HFReferralBulkRequest request) { if (!iMap.isEmpty()) { List hfReferralIds = new ArrayList<>(iMap.keySet()); List existingHfReferrals = hfReferralRepository.findById(hfReferralIds, - false, getIdFieldName(idMethod)); + false, getIdFieldName(idMethod)).getResponse(); List entitiesWithMismatchedRowVersion = getEntitiesWithMismatchedRowVersion(iMap, existingHfReferrals, idMethod); entitiesWithMismatchedRowVersion.forEach(hfReferral -> { diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/HFReferralApiController.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/HFReferralApiController.java index f09a4c578e8..c09a02bebfa 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/HFReferralApiController.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/web/controllers/HFReferralApiController.java @@ -6,6 +6,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; import org.egov.common.contract.response.ResponseInfo; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.core.URLParams; import org.egov.common.models.referralmanagement.hfreferral.HFReferral; import org.egov.common.models.referralmanagement.hfreferral.HFReferralBulkRequest; @@ -107,7 +108,7 @@ public ResponseEntity referralV1SearchPost( @ApiParam(value = "HFReferral Search.", required = true) @Valid @RequestBody HFReferralSearchRequest request ) throws Exception { - List hfReferrals = hfReferralService.search( + SearchResponse searchResponse = hfReferralService.search( request, urlParams.getLimit(), urlParams.getOffset(), @@ -115,7 +116,10 @@ public ResponseEntity referralV1SearchPost( urlParams.getLastChangedSince(), urlParams.getIncludeDeleted()); HFReferralBulkResponse response = HFReferralBulkResponse.builder().responseInfo(ResponseInfoFactory - .createResponseInfo(request.getRequestInfo(), true)).hfReferrals(hfReferrals).build(); + .createResponseInfo(request.getRequestInfo(), true)) + .hfReferrals(searchResponse.getResponse()) + .totalCount(searchResponse.getTotalCount()) + .build(); return ResponseEntity.status(HttpStatus.OK).body(response); } diff --git a/health-services/stock/pom.xml b/health-services/stock/pom.xml index d204ba58903..5cb0c17da56 100644 --- a/health-services/stock/pom.xml +++ b/health-services/stock/pom.xml @@ -45,12 +45,12 @@ org.egov.common health-services-common - 1.0.18-SNAPSHOT + 1.0.20-dev-SNAPSHOT org.egov.common health-services-models - 1.0.20-SNAPSHOT + 1.0.23-dev-SNAPSHOT diff --git a/health-services/stock/src/main/java/org/egov/stock/service/StockReconciliationService.java b/health-services/stock/src/main/java/org/egov/stock/service/StockReconciliationService.java index 6c6801a5922..69340c5efca 100644 --- a/health-services/stock/src/main/java/org/egov/stock/service/StockReconciliationService.java +++ b/health-services/stock/src/main/java/org/egov/stock/service/StockReconciliationService.java @@ -10,6 +10,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import org.egov.common.ds.Tuple; import org.egov.common.models.ErrorDetails; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.stock.StockReconciliation; import org.egov.common.models.stock.StockReconciliationBulkRequest; import org.egov.common.models.stock.StockReconciliationRequest; @@ -182,26 +183,27 @@ public List delete(StockReconciliationBulkRequest request, return validEntities; } - public List search(StockReconciliationSearchRequest request, - Integer limit, - Integer offset, - String tenantId, - Long lastChangedSince, - Boolean includeDeleted) throws Exception { + public SearchResponse search(StockReconciliationSearchRequest request, + Integer limit, + Integer offset, + String tenantId, + Long lastChangedSince, + Boolean includeDeleted) throws Exception { log.info("starting search method for stock reconciliation"); String idFieldName = getIdFieldName(request.getStockReconciliation()); if (isSearchByIdOnly(request.getStockReconciliation(), idFieldName)) { List ids = (List) ReflectionUtils.invokeMethod(getIdMethod(Collections .singletonList(request.getStockReconciliation())), request.getStockReconciliation()); - return stockRepository.findById(ids, includeDeleted, idFieldName).stream() + List stockReconciliations = stockRepository.findById(ids, includeDeleted, idFieldName).stream() .filter(lastChangedSince(lastChangedSince)) .filter(havingTenantId(tenantId)) .filter(includeDeleted(includeDeleted)) .collect(Collectors.toList()); + return SearchResponse.builder().response(stockReconciliations).build(); } log.info("completed search method for stock reconciliation"); - return stockRepository.find(request.getStockReconciliation(), + return stockRepository.findWithCount(request.getStockReconciliation(), limit, offset, tenantId, lastChangedSince, includeDeleted); } } diff --git a/health-services/stock/src/main/java/org/egov/stock/service/StockService.java b/health-services/stock/src/main/java/org/egov/stock/service/StockService.java index 6a26da44ced..c6b60278be7 100644 --- a/health-services/stock/src/main/java/org/egov/stock/service/StockService.java +++ b/health-services/stock/src/main/java/org/egov/stock/service/StockService.java @@ -10,6 +10,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; import org.egov.common.ds.Tuple; import org.egov.common.models.ErrorDetails; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.stock.Stock; import org.egov.common.models.stock.StockBulkRequest; import org.egov.common.models.stock.StockRequest; @@ -177,27 +178,28 @@ public List delete(StockBulkRequest request, boolean isBulk) { return validEntities; } - public List search(StockSearchRequest stockSearchRequest, - Integer limit, - Integer offset, - String tenantId, - Long lastChangedSince, - Boolean includeDeleted) throws Exception { + public SearchResponse search(StockSearchRequest stockSearchRequest, + Integer limit, + Integer offset, + String tenantId, + Long lastChangedSince, + Boolean includeDeleted) throws Exception { log.info("starting search method for stock"); String idFieldName = getIdFieldName(stockSearchRequest.getStock()); if (isSearchByIdOnly(stockSearchRequest.getStock(), idFieldName)) { List ids = (List) ReflectionUtils.invokeMethod(getIdMethod(Collections .singletonList(stockSearchRequest.getStock())), stockSearchRequest.getStock()); - return stockRepository.findById(ids, includeDeleted, idFieldName).stream() + List stocks = stockRepository.findById(ids, includeDeleted, idFieldName).stream() .filter(lastChangedSince(lastChangedSince)) .filter(havingTenantId(tenantId)) .filter(includeDeleted(includeDeleted)) .collect(Collectors.toList()); + return SearchResponse.builder().response(stocks).build(); } log.info("completed search method for stock"); - return stockRepository.find(stockSearchRequest.getStock(), + return stockRepository.findWithCount(stockSearchRequest.getStock(), limit, offset, tenantId, lastChangedSince, includeDeleted); } } diff --git a/health-services/stock/src/main/java/org/egov/stock/web/controllers/StockApiController.java b/health-services/stock/src/main/java/org/egov/stock/web/controllers/StockApiController.java index 913213dd191..7033f50a14a 100644 --- a/health-services/stock/src/main/java/org/egov/stock/web/controllers/StockApiController.java +++ b/health-services/stock/src/main/java/org/egov/stock/web/controllers/StockApiController.java @@ -8,6 +8,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; import org.egov.common.contract.response.ResponseInfo; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.core.URLParams; import org.egov.common.models.stock.Stock; import org.egov.common.models.stock.StockBulkRequest; @@ -80,7 +81,7 @@ public ResponseEntity stockV1SearchPost( @ApiParam(value = "Capture details of Stock Transfer.", required = true) @Valid @RequestBody StockSearchRequest stockSearchRequest ) throws Exception { - List stock = stockService.search( + SearchResponse searchResponse = stockService.search( stockSearchRequest, urlParams.getLimit(), urlParams.getOffset(), @@ -89,7 +90,7 @@ public ResponseEntity stockV1SearchPost( urlParams.getIncludeDeleted() ); StockBulkResponse response = StockBulkResponse.builder().responseInfo(ResponseInfoFactory - .createResponseInfo(stockSearchRequest.getRequestInfo(), true)).stock(stock).build(); + .createResponseInfo(stockSearchRequest.getRequestInfo(), true)).stock(searchResponse.getResponse()).totalCount(searchResponse.getTotalCount()).build(); return ResponseEntity.status(HttpStatus.OK).body(response); } diff --git a/health-services/stock/src/main/java/org/egov/stock/web/controllers/StockReconciliationApiController.java b/health-services/stock/src/main/java/org/egov/stock/web/controllers/StockReconciliationApiController.java index e612c3b692f..41fc33437e9 100644 --- a/health-services/stock/src/main/java/org/egov/stock/web/controllers/StockReconciliationApiController.java +++ b/health-services/stock/src/main/java/org/egov/stock/web/controllers/StockReconciliationApiController.java @@ -7,6 +7,7 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.validation.Valid; import org.egov.common.contract.response.ResponseInfo; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.core.URLParams; import org.egov.common.models.stock.StockReconciliation; import org.egov.common.models.stock.StockReconciliationBulkRequest; @@ -77,7 +78,7 @@ public ResponseEntity stockReconciliationV1Sear @ApiParam(value = "Capture details of Stock Reconciliation.", required = true) @Valid @RequestBody StockReconciliationSearchRequest stockReconciliationSearchRequest ) throws Exception { - List stock = stockReconciliationService.search( + SearchResponse searchResponse = stockReconciliationService.search( stockReconciliationSearchRequest, urlParams.getLimit(), urlParams.getOffset(), @@ -86,7 +87,10 @@ public ResponseEntity stockReconciliationV1Sear urlParams.getIncludeDeleted() ); StockReconciliationBulkResponse response = StockReconciliationBulkResponse.builder().responseInfo(ResponseInfoFactory - .createResponseInfo(stockReconciliationSearchRequest.getRequestInfo(), true)).stockReconciliation(stock).build(); + .createResponseInfo(stockReconciliationSearchRequest.getRequestInfo(), true)) + .stockReconciliation(searchResponse.getResponse()) + .totalCount(searchResponse.getTotalCount()) + .build(); return ResponseEntity.status(HttpStatus.OK).body(response); } From df091e9442d57d94985d693b927a79d151aba1a6 Mon Sep 17 00:00:00 2001 From: kanishq-egov Date: Wed, 18 Sep 2024 17:33:48 +0530 Subject: [PATCH 4/5] HCMPRE-469: added changes for removing digit-models deprecated dependency, replaced with tracer library references and mdms client references --- health-services/facility/pom.xml | 2 +- .../repository/rowmapper/FacilityRowMapper.java | 2 +- .../libraries/health-services-common/pom.xml | 6 ++++++ health-services/referralmanagement/pom.xml | 2 +- .../repository/rowmapper/HFReferralRowMapper.java | 2 +- .../repository/rowmapper/ReferralRowMapper.java | 2 +- .../repository/rowmapper/SideEffectRowMapper.java | 2 +- .../referralmanagement/service/MasterDataService.java | 11 ++++------- .../egov/referralmanagement/util/ValidatorUtil.java | 2 +- .../rowmapper/StockReconciliationRowMapper.java | 2 +- .../stock/repository/rowmapper/StockRowMapper.java | 2 +- .../main/java/org/egov/stock/util/ValidatorUtil.java | 2 +- 12 files changed, 20 insertions(+), 17 deletions(-) diff --git a/health-services/facility/pom.xml b/health-services/facility/pom.xml index 5598fb8b333..3bb21608516 100644 --- a/health-services/facility/pom.xml +++ b/health-services/facility/pom.xml @@ -45,7 +45,7 @@ org.egov.common health-services-common - 1.0.17-SNAPSHOT + 1.0.20-dev-SNAPSHOT org.egov.common diff --git a/health-services/facility/src/main/java/org/egov/facility/repository/rowmapper/FacilityRowMapper.java b/health-services/facility/src/main/java/org/egov/facility/repository/rowmapper/FacilityRowMapper.java index 3517293adcf..73276c91d88 100644 --- a/health-services/facility/src/main/java/org/egov/facility/repository/rowmapper/FacilityRowMapper.java +++ b/health-services/facility/src/main/java/org/egov/facility/repository/rowmapper/FacilityRowMapper.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.facility.Address; import org.egov.common.models.facility.AddressType; diff --git a/health-services/libraries/health-services-common/pom.xml b/health-services/libraries/health-services-common/pom.xml index 701a70a2cc2..0c834b051c8 100644 --- a/health-services/libraries/health-services-common/pom.xml +++ b/health-services/libraries/health-services-common/pom.xml @@ -118,6 +118,12 @@ 1.0.23-dev-SNAPSHOT compile + + org.egov + mdms-client + 2.9.0-SNAPSHOT + compile + diff --git a/health-services/referralmanagement/pom.xml b/health-services/referralmanagement/pom.xml index c7e1e5b127e..4bf32a9765a 100644 --- a/health-services/referralmanagement/pom.xml +++ b/health-services/referralmanagement/pom.xml @@ -46,7 +46,7 @@ org.egov.common health-services-common - 1.0.18-SNAPSHOT + 1.0.20-dev-SNAPSHOT org.egov.common diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/HFReferralRowMapper.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/HFReferralRowMapper.java index 5456cd9179c..7994e3d192f 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/HFReferralRowMapper.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/HFReferralRowMapper.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.referralmanagement.hfreferral.HFReferral; import org.springframework.beans.factory.annotation.Autowired; diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/ReferralRowMapper.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/ReferralRowMapper.java index 181aa1b6a55..83971874a2f 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/ReferralRowMapper.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/ReferralRowMapper.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.referralmanagement.Referral; import org.egov.common.models.referralmanagement.sideeffect.SideEffect; diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/SideEffectRowMapper.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/SideEffectRowMapper.java index 3832d8bd7e3..4b4d961b1f2 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/SideEffectRowMapper.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/rowmapper/SideEffectRowMapper.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.referralmanagement.sideeffect.SideEffect; import org.springframework.beans.factory.annotation.Autowired; diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/MasterDataService.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/MasterDataService.java index 3c09df3edde..a2d0a3f5277 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/MasterDataService.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/service/MasterDataService.java @@ -1,19 +1,12 @@ package org.egov.referralmanagement.service; -import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; import com.jayway.jsonpath.JsonPath; -import digit.models.coremodels.mdms.MasterDetail; -import digit.models.coremodels.mdms.MdmsCriteria; -import digit.models.coremodels.mdms.MdmsCriteriaReq; -import digit.models.coremodels.mdms.ModuleDetail; import lombok.extern.slf4j.Slf4j; import org.egov.common.contract.request.RequestInfo; import org.egov.common.http.client.ServiceRequestClient; @@ -22,6 +15,10 @@ import org.egov.common.models.project.ProjectResponse; import org.egov.common.models.referralmanagement.beneficiarydownsync.DownsyncCriteria; import org.egov.common.models.referralmanagement.beneficiarydownsync.DownsyncRequest; +import org.egov.mdms.model.MasterDetail; +import org.egov.mdms.model.MdmsCriteria; +import org.egov.mdms.model.MdmsCriteriaReq; +import org.egov.mdms.model.ModuleDetail; import org.egov.referralmanagement.config.ReferralManagementConfiguration; import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/util/ValidatorUtil.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/util/ValidatorUtil.java index 043c7d6a1b5..3541cb2d4dc 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/util/ValidatorUtil.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/util/ValidatorUtil.java @@ -1,7 +1,7 @@ package org.egov.referralmanagement.util; -import digit.models.coremodels.UserSearchRequest; import org.egov.common.contract.request.RequestInfo; +import org.egov.common.contract.user.UserSearchRequest; import org.egov.common.service.UserService; import org.springframework.util.CollectionUtils; diff --git a/health-services/stock/src/main/java/org/egov/stock/repository/rowmapper/StockReconciliationRowMapper.java b/health-services/stock/src/main/java/org/egov/stock/repository/rowmapper/StockReconciliationRowMapper.java index 813246f8a2b..d05bca6fdd1 100644 --- a/health-services/stock/src/main/java/org/egov/stock/repository/rowmapper/StockReconciliationRowMapper.java +++ b/health-services/stock/src/main/java/org/egov/stock/repository/rowmapper/StockReconciliationRowMapper.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.stock.StockReconciliation; import org.springframework.jdbc.core.RowMapper; diff --git a/health-services/stock/src/main/java/org/egov/stock/repository/rowmapper/StockRowMapper.java b/health-services/stock/src/main/java/org/egov/stock/repository/rowmapper/StockRowMapper.java index e413a3052ac..ea57dbad66d 100644 --- a/health-services/stock/src/main/java/org/egov/stock/repository/rowmapper/StockRowMapper.java +++ b/health-services/stock/src/main/java/org/egov/stock/repository/rowmapper/StockRowMapper.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.stock.ReferenceIdType; import org.egov.common.models.stock.SenderReceiverType; diff --git a/health-services/stock/src/main/java/org/egov/stock/util/ValidatorUtil.java b/health-services/stock/src/main/java/org/egov/stock/util/ValidatorUtil.java index d71f92cda2d..da5239e935c 100644 --- a/health-services/stock/src/main/java/org/egov/stock/util/ValidatorUtil.java +++ b/health-services/stock/src/main/java/org/egov/stock/util/ValidatorUtil.java @@ -6,8 +6,8 @@ import java.util.Map; import java.util.stream.Collectors; -import digit.models.coremodels.UserSearchRequest; import org.egov.common.contract.request.RequestInfo; +import org.egov.common.contract.user.UserSearchRequest; import org.egov.common.ds.Tuple; import org.egov.common.models.Error; import org.egov.common.models.stock.SenderReceiverType; From d96d6200f5e4062da39d25bfca5f5029330339a3 Mon Sep 17 00:00:00 2001 From: kanishq-egov Date: Wed, 18 Sep 2024 18:02:53 +0530 Subject: [PATCH 5/5] HCMPRE-469: added changes for project service, removed reference for digits model --- .../repository/rowmapper/DocumentRowMapper.java | 2 +- .../rowmapper/LocationCaptureRowMapper.java | 2 +- .../rowmapper/ProjectAddressRowMapper.java | 2 +- .../rowmapper/ProjectBeneficiaryRowMapper.java | 2 +- .../rowmapper/ProjectFacilityRowMapper.java | 2 +- .../rowmapper/ProjectResourceRowMapper.java | 2 +- .../repository/rowmapper/ProjectRowMapper.java | 2 +- .../rowmapper/ProjectStaffRowMapper.java | 2 +- .../rowmapper/ProjectTaskRowMapper.java | 2 +- .../repository/rowmapper/TargetRowMapper.java | 2 +- .../rowmapper/TaskResourceRowMapper.java | 2 +- .../rowmapper/UserActionRowMapper.java | 2 +- .../org/egov/project/service/ProjectService.java | 2 +- .../service/enrichment/ProjectEnrichment.java | 2 +- .../enrichment/ProjectTaskEnrichmentService.java | 2 +- .../java/org/egov/project/util/BoundaryUtil.java | 16 ++++++++-------- .../java/org/egov/project/util/MDMSUtils.java | 8 ++++---- .../egov/project/util/ProjectServiceUtil.java | 2 +- .../beneficiary/BeneficiaryValidator.java | 8 ++++---- .../validator/staff/PsUserIdValidator.java | 14 +++++++------- .../task/PtResourceQuantityValidator.java | 8 ++++---- .../ProjectBeneficiaryServiceCreateTest.java | 2 +- .../ProjectBeneficiaryServiceUpdateTest.java | 2 +- .../ProjectFacilityServiceSearchTest.java | 10 ++++++---- .../service/ProjectStaffServiceSearchTest.java | 9 +++++---- .../hfreferral/HfrRowVersionValidator.java | 2 +- 26 files changed, 57 insertions(+), 54 deletions(-) diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/DocumentRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/DocumentRowMapper.java index b9d3f814d7c..b2fcfb5672a 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/DocumentRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/DocumentRowMapper.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.project.Document; import org.egov.tracer.model.CustomException; import org.postgresql.util.PGobject; diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/LocationCaptureRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/LocationCaptureRowMapper.java index b9ea8babec8..a5a8da51b09 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/LocationCaptureRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/LocationCaptureRowMapper.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import lombok.extern.slf4j.Slf4j; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.project.UserActionEnum; diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectAddressRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectAddressRowMapper.java index fa5d72c5dc7..b4cd46201b3 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectAddressRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectAddressRowMapper.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.project.Address; import org.egov.common.models.project.AddressType; import org.egov.common.models.project.Project; diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectBeneficiaryRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectBeneficiaryRowMapper.java index c79c91ed161..663ada6310f 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectBeneficiaryRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectBeneficiaryRowMapper.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.project.ProjectBeneficiary; import org.springframework.jdbc.core.RowMapper; diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectFacilityRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectFacilityRowMapper.java index d6433f36db6..3d622db4a42 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectFacilityRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectFacilityRowMapper.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.project.ProjectFacility; import org.springframework.jdbc.core.RowMapper; diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectResourceRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectResourceRowMapper.java index 34deb79333a..bd6aa793bb6 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectResourceRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectResourceRowMapper.java @@ -1,7 +1,7 @@ package org.egov.project.repository.rowmapper; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.project.ProjectProductVariant; import org.egov.common.models.project.ProjectResource; import org.springframework.beans.factory.annotation.Autowired; diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectRowMapper.java index b8625274dfc..a4e1193eed2 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectRowMapper.java @@ -1,6 +1,6 @@ package org.egov.project.repository.rowmapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.project.Project; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Component; diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectStaffRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectStaffRowMapper.java index a0ff3d24bcf..169bdc99d40 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectStaffRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectStaffRowMapper.java @@ -5,7 +5,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.project.ProjectStaff; import org.springframework.jdbc.core.RowMapper; diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectTaskRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectTaskRowMapper.java index ccff648bd41..406a7419c54 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectTaskRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/ProjectTaskRowMapper.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.project.Address; import org.egov.common.models.project.AddressType; diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TargetRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TargetRowMapper.java index f9b352a69b4..59477283fec 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TargetRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TargetRowMapper.java @@ -1,6 +1,6 @@ package org.egov.project.repository.rowmapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.project.Target; import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.ResultSetExtractor; diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TaskResourceRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TaskResourceRowMapper.java index 87cab062d9c..1187e1692e6 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TaskResourceRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TaskResourceRowMapper.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.project.TaskResource; import org.springframework.jdbc.core.RowMapper; diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/UserActionRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/UserActionRowMapper.java index 8a63f0f3c99..57c992ae154 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/UserActionRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/UserActionRowMapper.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import lombok.extern.slf4j.Slf4j; import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.project.UserActionEnum; diff --git a/health-services/project/src/main/java/org/egov/project/service/ProjectService.java b/health-services/project/src/main/java/org/egov/project/service/ProjectService.java index 56e2665792a..e27c827ce29 100644 --- a/health-services/project/src/main/java/org/egov/project/service/ProjectService.java +++ b/health-services/project/src/main/java/org/egov/project/service/ProjectService.java @@ -1,7 +1,7 @@ package org.egov.project.service; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import jakarta.validation.Valid; import java.util.Map; import lombok.extern.slf4j.Slf4j; diff --git a/health-services/project/src/main/java/org/egov/project/service/enrichment/ProjectEnrichment.java b/health-services/project/src/main/java/org/egov/project/service/enrichment/ProjectEnrichment.java index 2bd670f589f..6497beb4d53 100644 --- a/health-services/project/src/main/java/org/egov/project/service/enrichment/ProjectEnrichment.java +++ b/health-services/project/src/main/java/org/egov/project/service/enrichment/ProjectEnrichment.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import java.util.Map; import java.util.ArrayList; import lombok.extern.slf4j.Slf4j; diff --git a/health-services/project/src/main/java/org/egov/project/service/enrichment/ProjectTaskEnrichmentService.java b/health-services/project/src/main/java/org/egov/project/service/enrichment/ProjectTaskEnrichmentService.java index db974db9be9..97bdaecc500 100644 --- a/health-services/project/src/main/java/org/egov/project/service/enrichment/ProjectTaskEnrichmentService.java +++ b/health-services/project/src/main/java/org/egov/project/service/enrichment/ProjectTaskEnrichmentService.java @@ -4,7 +4,7 @@ import java.util.Map; import java.util.stream.Collectors; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import lombok.extern.slf4j.Slf4j; import org.egov.common.models.project.Address; import org.egov.common.models.project.Task; 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..2ac778f4891 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 @@ -1,26 +1,26 @@ package org.egov.project.util; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.JsonPath; -import digit.models.coremodels.RequestInfoWrapper; import lombok.extern.slf4j.Slf4j; -import net.minidev.json.JSONObject; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.egov.common.contract.models.RequestInfoWrapper; import org.egov.common.contract.request.RequestInfo; import org.egov.common.http.client.ServiceRequestClient; import org.egov.tracer.model.CustomException; +import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - @Component @Slf4j diff --git a/health-services/project/src/main/java/org/egov/project/util/MDMSUtils.java b/health-services/project/src/main/java/org/egov/project/util/MDMSUtils.java index 4de61e5ab79..be006ad385d 100644 --- a/health-services/project/src/main/java/org/egov/project/util/MDMSUtils.java +++ b/health-services/project/src/main/java/org/egov/project/util/MDMSUtils.java @@ -5,10 +5,10 @@ import java.util.LinkedList; import java.util.List; -import digit.models.coremodels.mdms.MasterDetail; -import digit.models.coremodels.mdms.MdmsCriteria; -import digit.models.coremodels.mdms.MdmsCriteriaReq; -import digit.models.coremodels.mdms.ModuleDetail; +import org.egov.mdms.model.MasterDetail; +import org.egov.mdms.model.MdmsCriteria; +import org.egov.mdms.model.MdmsCriteriaReq; +import org.egov.mdms.model.ModuleDetail; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; import org.egov.common.contract.request.RequestInfo; diff --git a/health-services/project/src/main/java/org/egov/project/util/ProjectServiceUtil.java b/health-services/project/src/main/java/org/egov/project/util/ProjectServiceUtil.java index 7d750e8d984..8c9b810eecc 100644 --- a/health-services/project/src/main/java/org/egov/project/util/ProjectServiceUtil.java +++ b/health-services/project/src/main/java/org/egov/project/util/ProjectServiceUtil.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import digit.models.coremodels.AuditDetails; +import org.egov.common.contract.models.AuditDetails; import java.util.Iterator; import java.util.List; import java.util.Map; diff --git a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/BeneficiaryValidator.java b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/BeneficiaryValidator.java index 19c8454d63a..c0be5cfcb64 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/BeneficiaryValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/BeneficiaryValidator.java @@ -3,10 +3,10 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.mdms.MasterDetail; -import digit.models.coremodels.mdms.MdmsCriteria; -import digit.models.coremodels.mdms.MdmsCriteriaReq; -import digit.models.coremodels.mdms.ModuleDetail; +import org.egov.mdms.model.MasterDetail; +import org.egov.mdms.model.MdmsCriteria; +import org.egov.mdms.model.MdmsCriteriaReq; +import org.egov.mdms.model.ModuleDetail; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; import org.egov.common.contract.request.RequestInfo; diff --git a/health-services/project/src/main/java/org/egov/project/validator/staff/PsUserIdValidator.java b/health-services/project/src/main/java/org/egov/project/validator/staff/PsUserIdValidator.java index 7491e024ec3..a33408b813c 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/staff/PsUserIdValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/staff/PsUserIdValidator.java @@ -1,9 +1,15 @@ package org.egov.project.validator.staff; -import digit.models.coremodels.UserSearchRequest; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; import org.egov.common.contract.request.User; +import org.egov.common.contract.user.UserSearchRequest; import org.egov.common.http.client.ServiceRequestClient; import org.egov.common.models.Error; import org.egov.common.models.individual.Individual; @@ -18,12 +24,6 @@ import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import static org.egov.common.utils.CommonUtils.getIdToObjMap; import static org.egov.common.utils.CommonUtils.getMethod; import static org.egov.common.utils.CommonUtils.getObjClass; diff --git a/health-services/project/src/main/java/org/egov/project/validator/task/PtResourceQuantityValidator.java b/health-services/project/src/main/java/org/egov/project/validator/task/PtResourceQuantityValidator.java index e3be161fabb..0a4a68bd917 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/task/PtResourceQuantityValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/task/PtResourceQuantityValidator.java @@ -8,10 +8,6 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.mdms.MasterDetail; -import digit.models.coremodels.mdms.MdmsCriteria; -import digit.models.coremodels.mdms.MdmsCriteriaReq; -import digit.models.coremodels.mdms.ModuleDetail; import lombok.extern.slf4j.Slf4j; import org.egov.common.contract.request.RequestInfo; import org.egov.common.models.Error; @@ -22,6 +18,10 @@ import org.egov.common.service.MdmsService; import org.egov.common.utils.CommonUtils; import org.egov.common.validator.Validator; +import org.egov.mdms.model.MasterDetail; +import org.egov.mdms.model.MdmsCriteria; +import org.egov.mdms.model.MdmsCriteriaReq; +import org.egov.mdms.model.ModuleDetail; import org.egov.project.config.ProjectConfiguration; import org.egov.tracer.model.CustomException; import org.springframework.core.annotation.Order; diff --git a/health-services/project/src/test/java/org/egov/project/service/ProjectBeneficiaryServiceCreateTest.java b/health-services/project/src/test/java/org/egov/project/service/ProjectBeneficiaryServiceCreateTest.java index 93740830a51..fccdb5d0d1d 100644 --- a/health-services/project/src/test/java/org/egov/project/service/ProjectBeneficiaryServiceCreateTest.java +++ b/health-services/project/src/test/java/org/egov/project/service/ProjectBeneficiaryServiceCreateTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.mdms.MdmsCriteriaReq; +import org.egov.mdms.model.MdmsCriteriaReq; import org.apache.commons.io.IOUtils; import org.egov.common.contract.request.RequestInfo; import org.egov.common.http.client.ServiceRequestClient; diff --git a/health-services/project/src/test/java/org/egov/project/service/ProjectBeneficiaryServiceUpdateTest.java b/health-services/project/src/test/java/org/egov/project/service/ProjectBeneficiaryServiceUpdateTest.java index 805fba5c474..e4675e45bc2 100644 --- a/health-services/project/src/test/java/org/egov/project/service/ProjectBeneficiaryServiceUpdateTest.java +++ b/health-services/project/src/test/java/org/egov/project/service/ProjectBeneficiaryServiceUpdateTest.java @@ -2,7 +2,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.mdms.MdmsCriteriaReq; +import org.egov.mdms.model.MdmsCriteriaReq; import org.apache.commons.io.IOUtils; import org.egov.common.http.client.ServiceRequestClient; import org.egov.common.models.core.SearchResponse; diff --git a/health-services/project/src/test/java/org/egov/project/service/ProjectFacilityServiceSearchTest.java b/health-services/project/src/test/java/org/egov/project/service/ProjectFacilityServiceSearchTest.java index ae43fc65769..85fd9f4e71b 100644 --- a/health-services/project/src/test/java/org/egov/project/service/ProjectFacilityServiceSearchTest.java +++ b/health-services/project/src/test/java/org/egov/project/service/ProjectFacilityServiceSearchTest.java @@ -1,6 +1,7 @@ package org.egov.project.service; import org.egov.common.helper.RequestInfoTestBuilder; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.project.ProjectFacility; import org.egov.project.helper.ProjectFacilityTestBuilder; import org.egov.project.repository.ProjectFacilityRepository; @@ -46,9 +47,9 @@ void setUp() { @Test @DisplayName("should not raise exception if no search results are found") void shouldNotRaiseExceptionIfNoProjectFacilityFound() throws Exception { - when(projectFacilityRepository.find(any(ProjectFacilitySearch.class), any(Integer.class), + when(projectFacilityRepository.findWithCount(any(ProjectFacilitySearch.class), any(Integer.class), any(Integer.class), any(String.class), eq(null), any(Boolean.class))) - .thenReturn(Collections.emptyList()); + .thenReturn(SearchResponse.builder().response(Collections.emptyList()).build()); ProjectFacilitySearch projectFacilitySearch = ProjectFacilitySearch.builder() .id(Collections.singletonList("ID101")).facilityId(Collections.singletonList("some-facility-id")).build(); ProjectFacilitySearchRequest projectFacilitySearchRequest = ProjectFacilitySearchRequest.builder() @@ -77,8 +78,9 @@ void shouldNotRaiseExceptionIfNoProjectFacilityFoundForSearchById() { @Test @DisplayName("should return project facility if search criteria is matched") void shouldReturnProjectFacilityIfSearchCriteriaIsMatched() throws Exception { - when(projectFacilityRepository.find(any(ProjectFacilitySearch.class), any(Integer.class), - any(Integer.class), any(String.class), eq(null), any(Boolean.class))).thenReturn(projectFacilities); + when(projectFacilityRepository.findWithCount(any(ProjectFacilitySearch.class), any(Integer.class), + any(Integer.class), any(String.class), eq(null), any(Boolean.class))).thenReturn(SearchResponse.builder() + .response(projectFacilities).build()); projectFacilities.add(ProjectFacilityTestBuilder.builder().withId().withId().withAuditDetails().build()); ProjectFacilitySearch projectFacilitySearch = ProjectFacilitySearch.builder() .id(Collections.singletonList("ID101")).projectId(Collections.singletonList("some-projectId")).build(); diff --git a/health-services/project/src/test/java/org/egov/project/service/ProjectStaffServiceSearchTest.java b/health-services/project/src/test/java/org/egov/project/service/ProjectStaffServiceSearchTest.java index de62e784f26..f14fa8f9a9e 100644 --- a/health-services/project/src/test/java/org/egov/project/service/ProjectStaffServiceSearchTest.java +++ b/health-services/project/src/test/java/org/egov/project/service/ProjectStaffServiceSearchTest.java @@ -1,6 +1,7 @@ package org.egov.project.service; import org.egov.common.helper.RequestInfoTestBuilder; +import org.egov.common.models.core.SearchResponse; import org.egov.common.models.project.ProjectStaff; import org.egov.project.helper.ProjectStaffTestBuilder; import org.egov.project.repository.ProjectStaffRepository; @@ -46,9 +47,9 @@ void setUp() { @Test @DisplayName("should not raise exception if no search results are found") void shouldNotRaiseExceptionIfNoProjectStaffFound() throws Exception { - when(projectStaffRepository.find(any(ProjectStaffSearch.class), any(Integer.class), + when(projectStaffRepository.findWithCount(any(ProjectStaffSearch.class), any(Integer.class), any(Integer.class), any(String.class), eq(null), any(Boolean.class))) - .thenReturn(Collections.emptyList()); + .thenReturn(SearchResponse.builder().response(Collections.emptyList()).build()); ProjectStaffSearch projectStaffSearch = ProjectStaffSearch.builder() .id(Collections.singletonList("ID101")).staffId(Collections.singletonList("some-user-id")).build(); ProjectStaffSearchRequest projectStaffSearchRequest = ProjectStaffSearchRequest.builder() @@ -75,8 +76,8 @@ void shouldNotRaiseExceptionIfNoProjectStaffFoundForSearchById() { @Test @DisplayName("should return project staff if search criteria is matched") void shouldReturnProjectStaffIfSearchCriteriaIsMatched() throws Exception { - when(projectStaffRepository.find(any(ProjectStaffSearch.class), any(Integer.class), - any(Integer.class), any(String.class), eq(null), any(Boolean.class))).thenReturn(projectStaffs); + when(projectStaffRepository.findWithCount(any(ProjectStaffSearch.class), any(Integer.class), + any(Integer.class), any(String.class), eq(null), any(Boolean.class))).thenReturn(SearchResponse.builder().response(projectStaffs).build()); projectStaffs.add(ProjectStaffTestBuilder.builder().withId().withId().withAuditDetails().build()); ProjectStaffSearch projectStaffSearch = ProjectStaffSearch.builder().id(Collections.singletonList("ID101")).projectId(Collections.singletonList("some-projectId")).build(); ProjectStaffSearchRequest projectStaffSearchRequest = ProjectStaffSearchRequest.builder() diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrRowVersionValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrRowVersionValidator.java index 495c0963b63..83011aceec9 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrRowVersionValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrRowVersionValidator.java @@ -61,7 +61,7 @@ public Map> validate(HFReferralBulkRequest request) { if (!iMap.isEmpty()) { List hfReferralIds = new ArrayList<>(iMap.keySet()); List existingHfReferrals = hfReferralRepository.findById(hfReferralIds, - false, getIdFieldName(idMethod)).getResponse(); + getIdFieldName(idMethod), false).getResponse(); List entitiesWithMismatchedRowVersion = getEntitiesWithMismatchedRowVersion(iMap, existingHfReferrals, idMethod); entitiesWithMismatchedRowVersion.forEach(hfReferral -> {