From d800104ac0f0021d1aa3b048101dadfa4cc33a80 Mon Sep 17 00:00:00 2001 From: kanishq-egov Date: Fri, 9 Aug 2024 15:41:40 +0530 Subject: [PATCH 1/3] updated version for hcm v1.5 release --- health-services/household/pom.xml | 2 +- .../validators/household/HExistentEntityValidator.java | 2 -- health-services/individual/pom.xml | 2 +- .../libraries/health-services-common/CHANGELOG.md | 3 +++ health-services/libraries/health-services-common/pom.xml | 2 +- .../libraries/health-services-models/CHANGELOG.md | 6 ++++++ health-services/libraries/health-services-models/pom.xml | 2 +- health-services/project/CHANGELOG.md | 2 ++ health-services/project/pom.xml | 6 +++--- health-services/referralmanagement/CHANGELOG.md | 4 ++++ health-services/referralmanagement/pom.xml | 4 ++-- health-services/stock/pom.xml | 2 +- 12 files changed, 25 insertions(+), 12 deletions(-) diff --git a/health-services/household/pom.xml b/health-services/household/pom.xml index e97fd87ec1..955934b5e1 100644 --- a/health-services/household/pom.xml +++ b/health-services/household/pom.xml @@ -45,7 +45,7 @@ org.egov.common health-services-common - 1.0.17-dev-SNAPSHOT + 1.0.18-SNAPSHOT org.egov.common diff --git a/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java b/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java index 9c07be651a..c9b7cd9bf7 100644 --- a/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java +++ b/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java @@ -10,7 +10,6 @@ import org.egov.common.models.household.Household; import org.egov.common.models.household.HouseholdBulkRequest; import org.egov.common.models.household.HouseholdSearch; -import org.egov.common.models.individual.Individual; import org.egov.common.validator.Validator; import org.egov.household.repository.HouseholdRepository; import org.springframework.core.annotation.Order; @@ -18,7 +17,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; diff --git a/health-services/individual/pom.xml b/health-services/individual/pom.xml index 02c05ffd93..ab7767c720 100644 --- a/health-services/individual/pom.xml +++ b/health-services/individual/pom.xml @@ -53,7 +53,7 @@ org.egov.common health-services-common - 1.0.17-dev-SNAPSHOT + 1.0.18-SNAPSHOT org.egov.common diff --git a/health-services/libraries/health-services-common/CHANGELOG.md b/health-services/libraries/health-services-common/CHANGELOG.md index 14669d15d9..fbb085523f 100644 --- a/health-services/libraries/health-services-common/CHANGELOG.md +++ b/health-services/libraries/health-services-common/CHANGELOG.md @@ -1,5 +1,8 @@ All notable changes to this module will be documented in this file. +## 1.0.18 - 2024-08-09 +- Added validateClientReferenceIdsFromDB method to GenericRepository. + ## 1.0.16 - 2024-05-29 - Introduced multiple reusable functions to streamline and simplify the codebase. - Enhanced function modularity for better maintainability and readability. diff --git a/health-services/libraries/health-services-common/pom.xml b/health-services/libraries/health-services-common/pom.xml index 0047646dc8..8f5e0d4fae 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.17-dev-SNAPSHOT + 1.0.18-SNAPSHOT Shared classes among services diff --git a/health-services/libraries/health-services-models/CHANGELOG.md b/health-services/libraries/health-services-models/CHANGELOG.md index 531680fc20..c7476cbe79 100644 --- a/health-services/libraries/health-services-models/CHANGELOG.md +++ b/health-services/libraries/health-services-models/CHANGELOG.md @@ -1,5 +1,11 @@ All notable changes to this module will be documented in this file. +## 1.0.21 - 2024-08-07 +- Added UserActionEnum, UserAction Entities, TaskStatus enum +- Added isCascadingProjectDateUpdate in ProjectRequest model +- Removed status field from EgovModel + + ## 1.0.20 - 2024-05-29 - Added EgovModel, EgovSearchModel, EgovOfflineModel, EgovOfflineSearchModel - Updated Lombok to 1.18.22 for SuperBuilder annotation support. diff --git a/health-services/libraries/health-services-models/pom.xml b/health-services/libraries/health-services-models/pom.xml index d0d38bea5d..6ca95c3fe4 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.21-dev-SNAPSHOT + 1.0.21-SNAPSHOT 17 ${java.version} diff --git a/health-services/project/CHANGELOG.md b/health-services/project/CHANGELOG.md index 427aa3e591..7865206457 100644 --- a/health-services/project/CHANGELOG.md +++ b/health-services/project/CHANGELOG.md @@ -1,5 +1,7 @@ All notable changes to this module will be documented in this file. +## 1.1.5 - 2024-08-07 +- Added UserAction functionality with support for Location capture. ## 1.1.4 - 2024-05-29 - Integrated Core 2.9LTS diff --git a/health-services/project/pom.xml b/health-services/project/pom.xml index e957915b1d..fd0b688dcc 100644 --- a/health-services/project/pom.xml +++ b/health-services/project/pom.xml @@ -5,7 +5,7 @@ project jar project - 1.1.4 + 1.1.5 17 ${java.version} @@ -45,12 +45,12 @@ org.egov.common health-services-common - 1.0.17-dev-SNAPSHOT + 1.0.18-SNAPSHOT org.egov.common health-services-models - 1.0.21-dev-SNAPSHOT + 1.0.21-SNAPSHOT compile diff --git a/health-services/referralmanagement/CHANGELOG.md b/health-services/referralmanagement/CHANGELOG.md index c605b86863..21e7865768 100644 --- a/health-services/referralmanagement/CHANGELOG.md +++ b/health-services/referralmanagement/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this module will be documented in this file. +## 1.0.3 - 2024-08-09 +- Upgraded downsync logic. + + ## 1.0.2 - 2024-05-29 - Upgraded to Core 2.9LTS - Client reference ID validation added diff --git a/health-services/referralmanagement/pom.xml b/health-services/referralmanagement/pom.xml index 06abfeaa97..b9d85ad826 100644 --- a/health-services/referralmanagement/pom.xml +++ b/health-services/referralmanagement/pom.xml @@ -6,7 +6,7 @@ referralmanagement jar referralmanagement - 1.0.2 + 1.0.3 17 ${java.version} @@ -46,7 +46,7 @@ org.egov.common health-services-common - 1.0.17-dev-SNAPSHOT + 1.0.18-SNAPSHOT org.egov.common diff --git a/health-services/stock/pom.xml b/health-services/stock/pom.xml index 49c0615b5f..d204ba5890 100644 --- a/health-services/stock/pom.xml +++ b/health-services/stock/pom.xml @@ -45,7 +45,7 @@ org.egov.common health-services-common - 1.0.17-dev-SNAPSHOT + 1.0.18-SNAPSHOT org.egov.common From 04ce5e18da83d0c1c28d98db8bbdf44a97dcb7ff Mon Sep 17 00:00:00 2001 From: kanishq-egov Date: Mon, 12 Aug 2024 11:38:48 +0530 Subject: [PATCH 2/3] HLM updated the code as per code review from code rabbit --- .../member/validators/HmExistentEntityValidator.java | 2 +- .../validators/household/HExistentEntityValidator.java | 2 +- .../individual/validators/IExistentEntityValidator.java | 3 +-- .../validator/beneficiary/PbExistentEntityValidator.java | 4 +--- .../validator/task/PtExistentEntityValidator.java | 4 +--- .../validator/useraction/UaExistentEntityValidator.java | 9 ++++++--- .../validator/RmExistentEntityValidator.java | 4 +--- .../validator/hfreferral/HfrExistentEntityValidator.java | 4 +--- .../validator/sideeffect/SeExistentEntityValidator.java | 4 +--- .../stock/validator/stock/SExistentEntityValidator.java | 4 +--- .../stockreconciliation/SrExistentEntityValidator.java | 4 +--- 11 files changed, 16 insertions(+), 28 deletions(-) diff --git a/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java b/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java index debe490149..74392caa12 100644 --- a/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java +++ b/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java @@ -65,7 +65,7 @@ public Map> validate(HouseholdMemberBulkRequest req .clientReferenceId(clientReferenceIdList) .build(); Map map = entities.stream() - .filter(individual -> StringUtils.isEmpty(individual.getClientReferenceId())) + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Check if the client reference ID list is not empty if (!CollectionUtils.isEmpty(clientReferenceIdList)) { diff --git a/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java b/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java index 3de08ef819..f4ea2b4a5a 100644 --- a/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java +++ b/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java @@ -60,7 +60,7 @@ public Map> validate(HouseholdBulkRequest request) { .map(Household::getClientReferenceId) .collect(Collectors.toList()); Map map = entities.stream() - .filter(individual -> StringUtils.isEmpty(individual.getClientReferenceId())) + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Create a search object for querying entities by client reference IDs HouseholdSearch householdSearch = HouseholdSearch.builder() diff --git a/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java b/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java index 420e4ea4b6..a6bf51fd37 100644 --- a/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java +++ b/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java @@ -17,7 +17,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; @@ -61,7 +60,7 @@ public Map> validate(IndividualBulkRequest request) { .map(Individual::getClientReferenceId) .collect(Collectors.toList()); Map map = entities.stream() - .filter(individual -> StringUtils.isEmpty(individual.getClientReferenceId())) + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Create a search object for querying entities by client reference IDs IndividualSearch individualSearch = IndividualSearch.builder() diff --git a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java index ddb4094414..e1057ef2ad 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java @@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; -import org.egov.common.models.individual.Individual; import org.egov.common.models.project.BeneficiaryBulkRequest; import org.egov.common.models.project.ProjectBeneficiary; import org.egov.common.models.project.ProjectBeneficiarySearch; @@ -18,7 +17,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; @@ -67,7 +65,7 @@ public Map> validate(BeneficiaryBulkRequest requ .clientReferenceId(clientReferenceIdList) .build(); Map map = entities.stream() - .filter(individual -> StringUtils.isEmpty(individual.getClientReferenceId())) + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Check if the client reference ID list is not empty if (!CollectionUtils.isEmpty(clientReferenceIdList)) { diff --git a/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java b/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java index 1ace860e5c..2840afd2a6 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java @@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; -import org.egov.common.models.individual.Individual; import org.egov.common.models.project.Task; import org.egov.common.models.project.TaskBulkRequest; import org.egov.common.models.project.TaskSearch; @@ -18,7 +17,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; @@ -63,7 +61,7 @@ public Map> validate(TaskBulkRequest request) { .map(Task::getClientReferenceId) .collect(Collectors.toList()); Map map = entities.stream() - .filter(individual -> StringUtils.isEmpty(individual.getClientReferenceId())) + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Create a search object for querying entities by client reference IDs TaskSearch taskSearch = TaskSearch.builder() diff --git a/health-services/project/src/main/java/org/egov/project/validator/useraction/UaExistentEntityValidator.java b/health-services/project/src/main/java/org/egov/project/validator/useraction/UaExistentEntityValidator.java index dac31dba57..95f7bd74aa 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/useraction/UaExistentEntityValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/useraction/UaExistentEntityValidator.java @@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; -import org.egov.common.models.individual.Individual; import org.egov.common.models.project.useraction.UserAction; import org.egov.common.models.project.useraction.UserActionBulkRequest; import org.egov.common.models.project.useraction.UserActionSearch; @@ -19,7 +18,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; @@ -30,6 +28,11 @@ public class UaExistentEntityValidator implements Validator { private UserActionRepository userActionRepository; + /** + * Constructs a UaExistentEntityValidator with the specified UserActionRepository. + * + * @param userActionRepository the repository used to validate user action entities + */ @Autowired public UaExistentEntityValidator(UserActionRepository userActionRepository) { this.userActionRepository = userActionRepository; @@ -57,7 +60,7 @@ public Map> validate(UserActionBulkRequest request) { .map(UserAction::getClientReferenceId) .collect(Collectors.toList()); Map map = entities.stream() - .filter(individual -> StringUtils.isEmpty(individual.getClientReferenceId())) + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Create a search object for querying entities by client reference IDs UserActionSearch userActionSearch = UserActionSearch.builder() diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java index f6fbcba5c3..f60faaa27a 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java @@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; -import org.egov.common.models.individual.Individual; import org.egov.common.models.referralmanagement.Referral; import org.egov.common.models.referralmanagement.ReferralBulkRequest; import org.egov.common.models.referralmanagement.ReferralSearch; @@ -18,7 +17,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; @@ -62,7 +60,7 @@ public Map> validate(ReferralBulkRequest request) { .map(Referral::getClientReferenceId) .collect(Collectors.toList()); Map map = entities.stream() - .filter(individual -> StringUtils.isEmpty(individual.getClientReferenceId())) + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Create a search object for querying entities by client reference IDs ReferralSearch referralSearch = ReferralSearch.builder() diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java index b891ab6f1b..a4e072be3d 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java @@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; -import org.egov.common.models.individual.Individual; import org.egov.common.models.referralmanagement.hfreferral.HFReferral; import org.egov.common.models.referralmanagement.hfreferral.HFReferralBulkRequest; import org.egov.common.models.referralmanagement.hfreferral.HFReferralSearch; @@ -18,7 +17,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; @@ -63,7 +61,7 @@ public Map> validate(HFReferralBulkRequest request) { .map(HFReferral::getClientReferenceId) .collect(Collectors.toList()); Map map = entities.stream() - .filter(individual -> StringUtils.isEmpty(individual.getClientReferenceId())) + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Create a search object for querying entities by client reference IDs HFReferralSearch hfReferralSearch = HFReferralSearch.builder() diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java index 0f5f435f39..35d3b6b725 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java @@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; -import org.egov.common.models.individual.Individual; import org.egov.common.models.referralmanagement.sideeffect.SideEffect; import org.egov.common.models.referralmanagement.sideeffect.SideEffectBulkRequest; import org.egov.common.models.referralmanagement.sideeffect.SideEffectSearch; @@ -18,7 +17,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; @@ -67,7 +65,7 @@ public Map> validate(SideEffectBulkRequest request) { .clientReferenceId(clientReferenceIdList) .build(); Map map = entities.stream() - .filter(individual -> StringUtils.isEmpty(individual.getClientReferenceId())) + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Check if the client reference ID list is not empty if (!CollectionUtils.isEmpty(clientReferenceIdList)) { diff --git a/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java b/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java index ce43f76fe4..bfdaf56cfa 100644 --- a/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java +++ b/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java @@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; -import org.egov.common.models.individual.Individual; import org.egov.common.models.stock.Stock; import org.egov.common.models.stock.StockBulkRequest; import org.egov.common.models.stock.StockSearch; @@ -18,7 +17,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; @@ -63,7 +61,7 @@ public Map> validate(StockBulkRequest request) { .map(Stock::getClientReferenceId) .collect(Collectors.toList()); Map map = entities.stream() - .filter(individual -> StringUtils.isEmpty(individual.getClientReferenceId())) + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Create a search object for querying entities by client reference IDs StockSearch stockSearch = StockSearch.builder() diff --git a/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java b/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java index fad9892035..52c60f4ba1 100644 --- a/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java +++ b/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java @@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; -import org.egov.common.models.individual.Individual; import org.egov.common.models.stock.StockReconciliation; import org.egov.common.models.stock.StockReconciliationBulkRequest; import org.egov.common.models.stock.StockReconciliationSearch; @@ -18,7 +17,6 @@ import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; @@ -63,7 +61,7 @@ public Map> validate(StockReconciliationBulkReq .map(StockReconciliation::getClientReferenceId) .collect(Collectors.toList()); Map map = entities.stream() - .filter(individual -> StringUtils.isEmpty(individual.getClientReferenceId())) + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Create a search object for querying entities by client reference IDs StockReconciliationSearch stockReconciliationSearch = StockReconciliationSearch.builder() From 02bc42daa9053e82d4dad28fd25e3e163ce08ff4 Mon Sep 17 00:00:00 2001 From: kanishq-egov Date: Mon, 12 Aug 2024 12:36:24 +0530 Subject: [PATCH 3/3] HCMPRE-209: updated code review comments and code documentation --- .../validators/HmExistentEntityValidator.java | 36 ++++++---- .../household/HExistentEntityValidator.java | 36 ++++++---- .../validators/IExistentEntityValidator.java | 37 +++++++---- .../common/models/project/TaskStatus.java | 66 ++++++++++++++++++- .../models/project/useraction/UserAction.java | 2 +- .../project/consumer/UserActionConsumer.java | 9 +-- .../PbExistentEntityValidator.java | 55 +++++++++++----- .../task/PtExistentEntityValidator.java | 57 ++++++++++------ .../useraction/UaExistentEntityValidator.java | 60 +++++++++++------ .../LocationCaptureController.java | 4 +- .../validator/RmExistentEntityValidator.java | 52 +++++++++------ .../HfrExistentEntityValidator.java | 45 ++++++++----- .../sideeffect/SeExistentEntityValidator.java | 43 +++++++----- .../stock/SExistentEntityValidator.java | 33 ++++++---- .../SrExistentEntityValidator.java | 33 ++++++---- 15 files changed, 390 insertions(+), 178 deletions(-) diff --git a/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java b/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java index 74392caa12..cc9eb6c12d 100644 --- a/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java +++ b/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java @@ -45,40 +45,52 @@ public HmExistentEntityValidator(HouseholdMemberRepository householdMemberReposi /** * Validates the existence of entities with the given client reference IDs. + * This method checks if any of the HouseholdMember entities in the request already exist in the database, + * based on their client reference IDs. If an entity is found to exist, an error is added to the error details map. * * @param request The bulk request containing HouseholdMember entities. - * @return A map containing HouseholdMember entities and their associated error details. + * @return A map containing HouseholdMember entities and their associated error details, if any. */ @Override public Map> validate(HouseholdMemberBulkRequest request) { - // Map to hold HouseholdMember entities and their error details + // Map to hold HouseholdMember entities and their associated error details Map> errorDetailsMap = new HashMap<>(); + // Get the list of HouseholdMember entities from the request List entities = request.getHouseholdMembers(); - // Extract client reference IDs from HouseholdMember entities without errors + + // Extract client reference IDs from HouseholdMember entities that do not have errors List clientReferenceIdList = entities.stream() - .filter(notHavingErrors()) - .map(HouseholdMember::getClientReferenceId) - .collect(Collectors.toList()); + .filter(notHavingErrors()) // Filter out entities that already have errors + .map(HouseholdMember::getClientReferenceId) // Map to client reference IDs + .collect(Collectors.toList()); // Collect the IDs into a list + // Create a search object for querying entities by client reference IDs HouseholdMemberSearch householdSearch = HouseholdMemberSearch.builder() - .clientReferenceId(clientReferenceIdList) + .clientReferenceId(clientReferenceIdList) // Set the client reference IDs for the search .build(); + + // Create a map of client reference ID to HouseholdMember entity for easy lookup Map map = entities.stream() - .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) - .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); - // Check if the client reference ID list is not empty + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) // Ensure client reference ID is not empty + .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Collect to a map + + // Check if the client reference ID list is not empty before querying the database if (!CollectionUtils.isEmpty(clientReferenceIdList)) { // Query the repository to find existing entities by client reference IDs List existingClientReferenceIds = householdMemberRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE); - // For each existing entity, populate error details for uniqueness + + // For each existing client reference ID, populate error details for uniqueness existingClientReferenceIds.forEach(clientReferenceId -> { + // Get a predefined error object for unique entity validation Error error = getErrorForUniqueEntity(); + // Populate error details for the HouseholdMember entity associated with the client reference ID populateErrorDetails(map.get(clientReferenceId), error, errorDetailsMap); }); } + + // Return the map containing HouseholdMember entities and their associated error details return errorDetailsMap; } - } diff --git a/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java b/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java index f4ea2b4a5a..3325308991 100644 --- a/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java +++ b/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java @@ -24,6 +24,7 @@ /** * Validator class for checking the existence of entities with the given client reference IDs. * This validator checks if the provided household entities already exist in the database based on their client reference IDs. + * * @author kanishq-egov */ @Component @@ -44,39 +45,52 @@ public HExistentEntityValidator(HouseholdRepository householdRepository) { /** * Validates the existence of entities with the given client reference IDs. + * This method checks if any of the household entities in the request already exist in the database, + * based on their client reference IDs. If an entity is found to exist, an error is added to the error details map. * * @param request The bulk request containing household entities. - * @return A map containing household entities and their associated error details. + * @return A map containing household entities and their associated error details, if any. */ @Override public Map> validate(HouseholdBulkRequest request) { - // Map to hold household entities and their error details + // Map to hold household entities and their associated error details Map> errorDetailsMap = new HashMap<>(); + // Get the list of household entities from the request List entities = request.getHouseholds(); - // Extract client reference IDs from household entities without errors + + // Extract client reference IDs from household entities that do not have errors List clientReferenceIdList = entities.stream() - .filter(notHavingErrors()) - .map(Household::getClientReferenceId) - .collect(Collectors.toList()); + .filter(notHavingErrors()) // Filter out entities that already have errors + .map(Household::getClientReferenceId) // Map to client reference IDs + .collect(Collectors.toList()); // Collect the IDs into a list + + // Create a map of client reference ID to Household entity for easy lookup Map map = entities.stream() - .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) - .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) // Ensure client reference ID is not empty + .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Collect to a map + // Create a search object for querying entities by client reference IDs HouseholdSearch householdSearch = HouseholdSearch.builder() - .clientReferenceId(clientReferenceIdList) + .clientReferenceId(clientReferenceIdList) // Set the client reference IDs for the search .build(); - // Check if the client reference ID list is not empty + + // Check if the client reference ID list is not empty before querying the database if (!CollectionUtils.isEmpty(clientReferenceIdList)) { // Query the repository to find existing entities by client reference IDs List existingClientReferenceIds = householdRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE); - // For each existing entity, populate error details for uniqueness + + // For each existing client reference ID, populate error details for uniqueness existingClientReferenceIds.forEach(clientReferenceId -> { + // Get a predefined error object for unique entity validation Error error = getErrorForUniqueEntity(); + // Populate error details for the household entity associated with the client reference ID populateErrorDetails(map.get(clientReferenceId), error, errorDetailsMap); }); } + + // Return the map containing household entities and their associated error details return errorDetailsMap; } diff --git a/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java b/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java index a6bf51fd37..39bb06f6ed 100644 --- a/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java +++ b/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java @@ -24,6 +24,7 @@ /** * Validator class for checking the existence of entities with the given client reference IDs. * This validator checks if the provided individual entities already exist in the database based on their client reference IDs. + * * @author kanishq-egov */ @Component @@ -44,41 +45,53 @@ public IExistentEntityValidator(IndividualRepository individualRepository) { /** * Validates the existence of entities with the given client reference IDs. + * This method checks if any of the individual entities in the request already exist in the database, + * based on their client reference IDs. If an entity is found to exist, an error is added to the error details map. * * @param request The bulk request containing individual entities. - * @return A map containing individual entities and their associated error details. + * @return A map containing individual entities and their associated error details, if any. */ @Override public Map> validate(IndividualBulkRequest request) { - // Map to hold individual entities and their error details + // Map to hold individual entities and their associated error details Map> errorDetailsMap = new HashMap<>(); + // Get the list of individual entities from the request List entities = request.getIndividuals(); - // Extract client reference IDs from individual entities without errors + + // Extract client reference IDs from individual entities that do not have errors List clientReferenceIdList = entities.stream() - .filter(notHavingErrors()) - .map(Individual::getClientReferenceId) - .collect(Collectors.toList()); + .filter(notHavingErrors()) // Filter out entities that already have errors + .map(Individual::getClientReferenceId) // Map to client reference IDs + .collect(Collectors.toList()); // Collect the IDs into a list + + // Create a map of client reference ID to Individual entity for easy lookup Map map = entities.stream() - .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) - .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) // Ensure client reference ID is not empty + .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Collect to a map + // Create a search object for querying entities by client reference IDs IndividualSearch individualSearch = IndividualSearch.builder() - .clientReferenceId(clientReferenceIdList) + .clientReferenceId(clientReferenceIdList) // Set the client reference IDs for the search .build(); - // Check if the client reference ID list is not empty + + // Check if the client reference ID list is not empty before querying the database if (!CollectionUtils.isEmpty(clientReferenceIdList)) { // Query the repository to find existing entities by client reference IDs List existingClientReferenceIds = individualRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE); - // For each existing entity, populate error details for uniqueness + + // For each existing client reference ID, populate error details for uniqueness existingClientReferenceIds.forEach(clientReferenceId -> { + // Get a predefined error object for unique entity validation Error error = getErrorForUniqueEntity(); + // Populate error details for the individual entity associated with the client reference ID populateErrorDetails(map.get(clientReferenceId), error, errorDetailsMap); }); } + + // Return the map containing individual entities and their associated error details return errorDetailsMap; } } - diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/TaskStatus.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/TaskStatus.java index c551a68acb..a17652a89c 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/TaskStatus.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/TaskStatus.java @@ -3,26 +3,90 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; +/** + * Enum representing the various possible statuses for a task. + *

+ * Each status corresponds to a specific state of the task in the system. + * The status is stored as a string value and can be serialized/deserialized + * from JSON using Jackson annotations. + *

+ */ public enum TaskStatus { + + /** + * Indicates that the task administration has failed. + * This status represents an error or issue encountered during + * the administrative process of the task. + */ ADMINISTRATION_FAILED("ADMINISTRATION_FAILED"), + + /** + * Indicates that the task administration was successful. + * This status signifies that the task has been processed correctly + * without any issues. + */ ADMINISTRATION_SUCCESS("ADMINISTRATION_SUCCESS"), + + /** + * Indicates that the beneficiary has refused the task. + * This status means that the individual or entity for whom the task + * was intended has declined to participate or accept it. + */ BENEFICIARY_REFUSED("BENEFICIARY_REFUSED"), + + /** + * Indicates that the household associated with the task has been closed. + * This status implies that the household is no longer active or + * relevant to the task, possibly due to its closure or other reasons. + */ CLOSED_HOUSEHOLD("CLOSED_HOUSEHOLD"), + + /** + * Indicates that the task has been delivered. + * This status shows that the task has been successfully completed + * and the deliverables have been provided. + */ DELIVERED("DELIVERED"), + + /** + * Indicates that the task has not been administered. + * This status signifies that the task has not been processed or + * handled yet. + */ NOT_ADMINISTERED("NOT_ADMINISTERED"); + // The string value associated with the task status. private String value; + /** + * Constructor to initialize the TaskStatus with a specific string value. + * + * @param value The string value representing the task status. + */ TaskStatus(String value) { this.value = value; } + /** + * Returns the string representation of the TaskStatus. + * This method is used for serialization of the enum value to JSON. + * + * @return The string value of the task status. + */ @Override @JsonValue public String toString() { return String.valueOf(value); } + /** + * Creates a TaskStatus enum from a string value. + * This method is used for deserialization of the enum value from JSON. + * + * @param text The string value representing the task status. + * @return The TaskStatus enum corresponding to the provided value, + * or null if no match is found. + */ @JsonCreator public static TaskStatus fromValue(String text) { for (TaskStatus status : TaskStatus.values()) { @@ -30,6 +94,6 @@ public static TaskStatus fromValue(String text) { return status; } } - return null; + return null; // Return null if no matching status is found } } diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/useraction/UserAction.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/useraction/UserAction.java index ac20f32e15..d58d98996d 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/useraction/UserAction.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/useraction/UserAction.java @@ -33,7 +33,7 @@ public class UserAction extends EgovOfflineModel { * It must be between 2 and 64 characters long and cannot be null. */ @JsonProperty("projectId") - @Size(min = 2, max = 64) + @Size(min = 2, max = 64, message = "Project ID must be between 2 and 64 characters") @NotNull private String projectId; diff --git a/health-services/project/src/main/java/org/egov/project/consumer/UserActionConsumer.java b/health-services/project/src/main/java/org/egov/project/consumer/UserActionConsumer.java index e3714e98bb..f01d2e0091 100644 --- a/health-services/project/src/main/java/org/egov/project/consumer/UserActionConsumer.java +++ b/health-services/project/src/main/java/org/egov/project/consumer/UserActionConsumer.java @@ -1,13 +1,10 @@ package org.egov.project.consumer; -import java.util.Collections; -import java.util.List; import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.egov.common.models.project.useraction.UserAction; import org.egov.common.models.project.useraction.UserActionBulkRequest; import org.egov.project.service.LocationCaptureService; import org.egov.project.service.UserActionService; @@ -51,7 +48,7 @@ public void bulkCreateUserAction(Map consumerRecord, userActionService.create(request, true); } catch (Exception exception) { // Log any exception that occurs - log.error("error in user action consumer bulk create", ExceptionUtils.getStackTrace(exception)); + log.error("Error processing bulk create for user actions from topic {}: {}", topic, ExceptionUtils.getStackTrace(exception)); // throw custom exception throw new CustomException("PROJECT_USER_ACTION_BULK_CREATE", exception.getMessage()); } @@ -74,7 +71,7 @@ public void bulkUpdateUserAction(Map consumerRecord, userActionService.update(request, true); } catch (Exception exception) { // Log any exception that occurs - log.error("error in user action consumer bulk update", ExceptionUtils.getStackTrace(exception)); + log.error("Error processing bulk update for user actions from topic {}: {}", topic, ExceptionUtils.getStackTrace(exception)); // throw custom exception throw new CustomException("PROJECT_USER_ACTION_BULK_UPDATE", exception.getMessage()); } @@ -97,7 +94,7 @@ public void bulkCreateLocationCapture(Map consumerRecord, locationCaptureService.create(request, true); } catch (Exception exception) { // Log any exception that occurs - log.error("error in location capture consumer bulk create", ExceptionUtils.getStackTrace(exception)); + log.error("Error processing bulk create for location captures from topic {}: {}", topic, ExceptionUtils.getStackTrace(exception)); // throw custom exception throw new CustomException("PROJECT_USER_ACTION_LOCATION_CAPTURE_BULK_CREATE", exception.getMessage()); } diff --git a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java index e1057ef2ad..97acdc3d86 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java @@ -22,9 +22,12 @@ import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; /** - * Validator class for checking the existence of entities with the given client reference IDs. + * Validator class for checking the existence of ProjectBeneficiary entities with the given client reference IDs. * This validator checks if the provided ProjectBeneficiary entities already exist in the database based on their client reference IDs. * + * The validation ensures that each ProjectBeneficiary entity in the bulk request has a unique client reference ID, + * and if an entity with the same client reference ID already exists, an error is recorded. + * * @author kanishq-egov */ @Component @@ -38,46 +41,62 @@ public class PbExistentEntityValidator implements Validator> validate(BeneficiaryBulkRequest request) { - // Map to hold ProjectBeneficiary entities and their error details + // Initialize a map to hold ProjectBeneficiary entities and their associated error details. Map> errorDetailsMap = new HashMap<>(); - // Get the list of ProjectBeneficiary entities from the request + + // Extract the list of ProjectBeneficiary entities from the request. List entities = request.getProjectBeneficiaries(); - // Extract client reference IDs from ProjectBeneficiary entities without errors + + // Extract the client reference IDs from ProjectBeneficiary entities that do not have existing errors. List clientReferenceIdList = entities.stream() - .filter(notHavingErrors()) - .map(ProjectBeneficiary::getClientReferenceId) - .collect(Collectors.toList()); - // Create a search object for querying entities by client reference IDs + .filter(notHavingErrors()) // Filter out entities that already have errors. + .map(ProjectBeneficiary::getClientReferenceId) // Map to extract client reference IDs. + .collect(Collectors.toList()); // Collect the IDs into a list. + + // Create a map of client reference ID to ProjectBeneficiary entity for quick lookup. + Map map = entities.stream() + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) // Ensure client reference ID is not empty. + .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Collect to a map. + + // Create a search object to query entities by client reference IDs. ProjectBeneficiarySearch projectBeneficiarySearch = ProjectBeneficiarySearch.builder() - .clientReferenceId(clientReferenceIdList) + .clientReferenceId(clientReferenceIdList) // Set the client reference IDs for the search. .build(); - Map map = entities.stream() - .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) - .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); - // Check if the client reference ID list is not empty + + // Check if the client reference ID list is not empty before querying the database. if (!CollectionUtils.isEmpty(clientReferenceIdList)) { - // Query the repository to find existing entities by client reference IDs + // Query the repository to find existing entities with the given client reference IDs. List existingClientReferenceIds = projectBeneficiaryRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE); - // For each existing entity, populate error details for uniqueness + + // For each existing client reference ID, populate error details for the corresponding ProjectBeneficiary entity. existingClientReferenceIds.forEach(clientReferenceId -> { + // Get a predefined error object for unique entity validation. Error error = getErrorForUniqueEntity(); + // Populate error details for the individual entity associated with the client reference ID. populateErrorDetails(map.get(clientReferenceId), error, errorDetailsMap); }); } + + // Return the map containing ProjectBeneficiary entities and their associated error details. return errorDetailsMap; } diff --git a/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java b/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java index 2840afd2a6..ba4ebc2488 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java @@ -22,8 +22,11 @@ import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; /** - * Validator class for checking the existence of entities with the given client reference IDs. - * This validator checks if the provided Task entities already exist in the database based on their client reference IDs. + * Validator class for checking the existence of ProjectTask entities with the given client reference IDs. + * This validator ensures that the Task entities provided in the bulk request do not have duplicate client reference IDs in the database. + * + * The validation checks if each Task entity's client reference ID is unique across the database, + * and if a duplicate ID is found, it adds an error to the map with the entity. * * @author: kanishq-egov */ @@ -37,46 +40,62 @@ public class PtExistentEntityValidator implements Validator> validate(TaskBulkRequest request) { - // Map to hold Task entities and their error details + // Initialize a map to store Task entities and their associated error details. Map> errorDetailsMap = new HashMap<>(); - // Get the list of Task entities from the request + + // Extract the list of Task entities from the request. List entities = request.getTasks(); - // Extract client reference IDs from Task entities without errors + + // Extract client reference IDs from Task entities that do not have existing errors. List clientReferenceIdList = entities.stream() - .filter(notHavingErrors()) - .map(Task::getClientReferenceId) - .collect(Collectors.toList()); + .filter(notHavingErrors()) // Filter out entities that already have errors. + .map(Task::getClientReferenceId) // Map to extract client reference IDs. + .collect(Collectors.toList()); // Collect the IDs into a list. + + // Create a map for quick lookup of Task entities by client reference ID. Map map = entities.stream() - .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) - .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); - // Create a search object for querying entities by client reference IDs + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) // Ensure client reference ID is not empty. + .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Collect to a map. + + // Create a search object to query for existing entities based on client reference IDs. TaskSearch taskSearch = TaskSearch.builder() - .clientReferenceId(clientReferenceIdList) + .clientReferenceId(clientReferenceIdList) // Set the client reference IDs for the search. .build(); - // Check if the client reference ID list is not empty + + // Check if the client reference ID list is not empty before querying the database. if (!CollectionUtils.isEmpty(clientReferenceIdList)) { - // Query the repository to find existing entities by client reference IDs + // Query the repository to find existing entities with the given client reference IDs. List existingClientReferenceIds = projectTaskRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE); - // For each existing entity, populate error details for uniqueness + + // For each existing client reference ID, add an error to the map for the corresponding Task entity. existingClientReferenceIds.forEach(clientReferenceId -> { + // Get a predefined error object for unique entity validation. Error error = getErrorForUniqueEntity(); + // Populate error details for the individual Task entity associated with the client reference ID. populateErrorDetails(map.get(clientReferenceId), error, errorDetailsMap); }); } + + // Return the map containing Task entities and their associated error details. return errorDetailsMap; } } diff --git a/health-services/project/src/main/java/org/egov/project/validator/useraction/UaExistentEntityValidator.java b/health-services/project/src/main/java/org/egov/project/validator/useraction/UaExistentEntityValidator.java index 95f7bd74aa..e5f3ff7a02 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/useraction/UaExistentEntityValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/useraction/UaExistentEntityValidator.java @@ -22,6 +22,15 @@ import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; +/** + * Validator class for checking the existence of UserAction entities based on their client reference IDs. + * This validator ensures that the UserAction entities in the bulk request do not have duplicate client reference IDs in the database. + * + * The validation checks if each UserAction entity's client reference ID already exists in the database. + * If a duplicate ID is found, it adds an error to the map with the entity. + * + * @author: kanishq-egov + */ @Component @Order(value = 1) @Slf4j @@ -31,7 +40,7 @@ public class UaExistentEntityValidator implements Validator> validate(UserActionBulkRequest request) { - // Map to hold UserAction entities and their error details + // Map to hold UserAction entities and their error details. log.info("Validating existence of entities in UserActionBulkRequest with {} entities", request.getUserActions().size()); Map> errorDetailsMap = new HashMap<>(); - // Get the list of UserAction entities from the request + + // Get the list of UserAction entities from the request. List entities = request.getUserActions(); - // Extract client reference IDs from UserAction entities without errors + + // Extract client reference IDs from UserAction entities that do not have existing errors. List clientReferenceIdList = entities.stream() - .filter(notHavingErrors()) - .map(UserAction::getClientReferenceId) - .collect(Collectors.toList()); + .filter(notHavingErrors()) // Filter out entities that already have errors. + .map(UserAction::getClientReferenceId) // Map to extract client reference IDs. + .collect(Collectors.toList()); // Collect the IDs into a list. + + // Create a map for quick lookup of UserAction entities by client reference ID. Map map = entities.stream() - .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) - .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); - // Create a search object for querying entities by client reference IDs + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) // Ensure client reference ID is not empty. + .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Collect to a map. + + // Create a search object to query for existing UserAction entities based on client reference IDs. UserActionSearch userActionSearch = UserActionSearch.builder() - .clientReferenceId(clientReferenceIdList) + .clientReferenceId(clientReferenceIdList) // Set the client reference IDs for the search. .build(); - // Check if the client reference ID list is not empty + + // Check if the client reference ID list is not empty before querying the database. if (!CollectionUtils.isEmpty(clientReferenceIdList)) { - // Query the repository to find existing entities by client reference IDs + // Query the repository to find existing UserAction entities with the given client reference IDs. List existingClientReferenceIds = userActionRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.FALSE); - // For each existing entity, populate error details for uniqueness + + // For each existing client reference ID, add an error to the map for the corresponding UserAction entity. existingClientReferenceIds.forEach(clientReferenceId -> { + // Get a predefined error object for unique entity validation. Error error = getErrorForUniqueEntity(); + // Populate error details for the individual UserAction entity associated with the client reference ID. populateErrorDetails(map.get(clientReferenceId), error, errorDetailsMap); }); } + + // Return the map containing UserAction entities and their associated error details. return errorDetailsMap; } } diff --git a/health-services/project/src/main/java/org/egov/project/web/controllers/LocationCaptureController.java b/health-services/project/src/main/java/org/egov/project/web/controllers/LocationCaptureController.java index a2c3107730..2214594b31 100644 --- a/health-services/project/src/main/java/org/egov/project/web/controllers/LocationCaptureController.java +++ b/health-services/project/src/main/java/org/egov/project/web/controllers/LocationCaptureController.java @@ -78,7 +78,7 @@ public ResponseEntity locationCaptureTaskV1BulkCreatePost( // Send the request to the Kafka topic for bulk creation. producer.push(projectConfiguration.getBulkCreateLocationCaptureTopic(), request); } catch (Exception e) { - log.error("Error sending message to Kafka", e); + log.error("Error sending bulk create request for location captures to Kafka: {}", e.getMessage(), e); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body( ResponseInfoFactory.createResponseInfo(request.getRequestInfo(), false) ); @@ -119,7 +119,7 @@ public ResponseEntity locationCaptureTaskV2SearchPost( // Return the response with HTTP status OK. return ResponseEntity.status(HttpStatus.OK).body(response); } catch (Exception e) { - log.error("Error during search operation", e); + log.error("Error occurred during search operation for location captures: {}", e.getMessage(), e); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body( UserActionBulkResponse.builder() .responseInfo(ResponseInfoFactory.createResponseInfo(locationCaptureSearchRequest.getRequestInfo(), false)) diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java index f60faaa27a..c12c03054e 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java @@ -22,8 +22,9 @@ import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; /** - * Validator class for checking the existence of entities with the given client reference IDs. - * This validator checks if the provided referral entities already exist in the database based on their client reference IDs. + * Validator class for checking the existence of referral entities with the given client reference IDs. + * This validator checks if the provided Referral entities already exist in the database based on their client reference IDs. + * * @author kanishq-egov */ @Component @@ -36,47 +37,58 @@ public class RmExistentEntityValidator implements Validator> validate(ReferralBulkRequest request) { - // Map to hold referral entities and their error details + // Map to hold Referral entities and their error details Map> errorDetailsMap = new HashMap<>(); - // Get the list of referral entities from the request + + // Get the list of Referral entities from the request List entities = request.getReferrals(); - // Extract client reference IDs from referral entities without errors + + // Extract client reference IDs from Referral entities that do not have existing errors List clientReferenceIdList = entities.stream() - .filter(notHavingErrors()) - .map(Referral::getClientReferenceId) - .collect(Collectors.toList()); + .filter(notHavingErrors()) // Filter out entities that already have errors + .map(Referral::getClientReferenceId) // Extract client reference IDs from Referral entities + .collect(Collectors.toList()); // Collect the IDs into a list + + // Create a map for quick lookup of Referral entities by client reference ID Map map = entities.stream() - .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) - .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); - // Create a search object for querying entities by client reference IDs + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) // Ensure client reference ID is not empty + .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Collect to a map + + // Create a search object for querying existing Referral entities by client reference IDs ReferralSearch referralSearch = ReferralSearch.builder() - .clientReferenceId(clientReferenceIdList) + .clientReferenceId(clientReferenceIdList) // Set the client reference IDs for the search .build(); - // Check if the client reference ID list is not empty + + // Check if the client reference ID list is not empty before querying the database if (!CollectionUtils.isEmpty(clientReferenceIdList)) { - // Query the repository to find existing entities by client reference IDs + // Query the repository to find existing Referral entities with the given client reference IDs List existingClientReferenceIds = referralRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE); - // For each existing entity, populate error details for uniqueness + + // For each existing client reference ID, add an error to the map for the corresponding Referral entity existingClientReferenceIds.forEach(clientReferenceId -> { + // Get a predefined error object for unique entity validation Error error = getErrorForUniqueEntity(); + // Populate error details for the individual Referral entity associated with the client reference ID populateErrorDetails(map.get(clientReferenceId), error, errorDetailsMap); }); } + + // Return the map containing Referral entities and their associated error details return errorDetailsMap; } - } diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java index a4e072be3d..de041f238e 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java @@ -22,7 +22,7 @@ import static org.egov.common.utils.ValidatorUtils.getErrorForUniqueEntity; /** - * Validator class for checking the existence of entities with the given client reference IDs. + * Validator class for checking the existence of HFReferral entities with the given client reference IDs. * This validator checks if the provided HFReferral entities already exist in the database based on their client reference IDs. * * @author kanishq-egov @@ -44,40 +44,51 @@ public HfrExistentEntityValidator(HFReferralRepository hfReferralRepository) { } /** - * Validates the existence of entities with the given client reference IDs. + * Validates the existence of HFReferral entities in the HFReferralBulkRequest. + * Checks if the provided HFReferral entities already exist in the database based on their client reference IDs. * * @param request The bulk request containing HFReferral entities. - * @return A map containing HFReferral entities and their associated error details. + * @return A map containing HFReferral entities and their associated error details if any duplicates are found. */ @Override public Map> validate(HFReferralBulkRequest request) { - // Map to hold HFReferral entities and their error details + // Map to hold HFReferral entities and their error details. Map> errorDetailsMap = new HashMap<>(); - // Get the list of HFReferral entities from the request + + // Get the list of HFReferral entities from the request. List entities = request.getHfReferrals(); - // Extract client reference IDs from HFReferral entities without errors + + // Extract client reference IDs from HFReferral entities that do not have existing errors. List clientReferenceIdList = entities.stream() - .filter(notHavingErrors()) - .map(HFReferral::getClientReferenceId) - .collect(Collectors.toList()); + .filter(notHavingErrors()) // Filter out entities that already have errors. + .map(HFReferral::getClientReferenceId) // Extract client reference IDs from HFReferral entities. + .collect(Collectors.toList()); // Collect the IDs into a list. + + // Create a map for quick lookup of HFReferral entities by client reference ID. Map map = entities.stream() - .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) - .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); - // Create a search object for querying entities by client reference IDs + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) // Ensure client reference ID is not empty. + .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Collect to a map. + + // Create a search object for querying existing HFReferral entities by client reference IDs. HFReferralSearch hfReferralSearch = HFReferralSearch.builder() - .clientReferenceId(clientReferenceIdList) + .clientReferenceId(clientReferenceIdList) // Set the client reference IDs for the search. .build(); - // Check if the client reference ID list is not empty + + // Check if the client reference ID list is not empty before querying the database. if (!CollectionUtils.isEmpty(clientReferenceIdList)) { - // Query the repository to find existing entities by client reference IDs + // Query the repository to find existing HFReferral entities with the given client reference IDs. List existingClientReferenceIds = hfReferralRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE); - // For each existing entity, populate error details for uniqueness + + // For each existing client reference ID, add an error to the map for the corresponding HFReferral entity. existingClientReferenceIds.forEach(clientReferenceId -> { + // Get a predefined error object for unique entity validation. Error error = getErrorForUniqueEntity(); + // Populate error details for the individual HFReferral entity associated with the client reference ID. populateErrorDetails(map.get(clientReferenceId), error, errorDetailsMap); }); } + + // Return the map containing HFReferral entities and their associated error details. return errorDetailsMap; } - } diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java index 35d3b6b725..961272cb95 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java @@ -44,40 +44,51 @@ public SeExistentEntityValidator(SideEffectRepository sideEffectRepository) { } /** - * Validates the existence of SideEffect entities with the given client reference IDs. + * Validates the existence of SideEffect entities in the SideEffectBulkRequest. + * Checks if the provided SideEffect entities already exist in the database based on their client reference IDs. * * @param request The bulk request containing SideEffect entities. - * @return A map containing SideEffect entities and their associated error details. + * @return A map containing SideEffect entities and their associated error details if any duplicates are found. */ @Override public Map> validate(SideEffectBulkRequest request) { // Map to hold SideEffect entities and their error details Map> errorDetailsMap = new HashMap<>(); + // Get the list of SideEffect entities from the request List entities = request.getSideEffects(); - // Extract client reference IDs from SideEffect entities without errors + + // Extract client reference IDs from SideEffect entities that do not have existing errors List clientReferenceIdList = entities.stream() - .filter(notHavingErrors()) - .map(SideEffect::getClientReferenceId) - .collect(Collectors.toList()); - // Create a search object for querying entities by client reference IDs + .filter(notHavingErrors()) // Filter out entities that already have errors + .map(SideEffect::getClientReferenceId) // Extract client reference IDs from SideEffect entities + .collect(Collectors.toList()); // Collect the IDs into a list + + // Create a map for quick lookup of SideEffect entities by client reference ID + Map map = entities.stream() + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) // Ensure client reference ID is not empty + .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Collect to a map + + // Create a search object for querying existing SideEffect entities by client reference IDs SideEffectSearch sideEffectSearch = SideEffectSearch.builder() - .clientReferenceId(clientReferenceIdList) + .clientReferenceId(clientReferenceIdList) // Set the client reference IDs for the search .build(); - Map map = entities.stream() - .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) - .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); - // Check if the client reference ID list is not empty + + // Check if the client reference ID list is not empty before querying the database if (!CollectionUtils.isEmpty(clientReferenceIdList)) { - // Query the repository to find existing entities by client reference IDs - List existingClientReferenceIds = - sideEffectRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE); - // For each existing entity, populate error details for uniqueness + // Query the repository to find existing SideEffect entities with the given client reference IDs + List existingClientReferenceIds = sideEffectRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE); + + // For each existing client reference ID, add an error to the map for the corresponding SideEffect entity existingClientReferenceIds.forEach(clientReferenceId -> { + // Get a predefined error object for unique entity validation Error error = getErrorForUniqueEntity(); + // Populate error details for the individual SideEffect entity associated with the client reference ID populateErrorDetails(map.get(clientReferenceId), error, errorDetailsMap); }); } + + // Return the map containing SideEffect entities and their associated error details return errorDetailsMap; } } diff --git a/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java b/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java index bfdaf56cfa..85d5d2bf61 100644 --- a/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java +++ b/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java @@ -53,30 +53,41 @@ public SExistentEntityValidator(StockRepository stockRepository) { public Map> validate(StockBulkRequest request) { // Map to hold Stock entities and their error details Map> errorDetailsMap = new HashMap<>(); + // Get the list of Stock entities from the request List entities = request.getStock(); - // Extract client reference IDs from Stock entities without errors + + // Extract client reference IDs from Stock entities that do not already have errors List clientReferenceIdList = entities.stream() - .filter(notHavingErrors()) - .map(Stock::getClientReferenceId) - .collect(Collectors.toList()); + .filter(notHavingErrors()) // Exclude entities with existing errors + .map(Stock::getClientReferenceId) // Map entities to their client reference IDs + .collect(Collectors.toList()); // Collect IDs into a list + + // Create a map for quick lookup of Stock entities by their client reference ID Map map = entities.stream() - .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) - .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); - // Create a search object for querying entities by client reference IDs + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) // Ensure client reference ID is not empty + .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Collect to a map + + // Create a search object to query existing entities by client reference IDs StockSearch stockSearch = StockSearch.builder() - .clientReferenceId(clientReferenceIdList) + .clientReferenceId(clientReferenceIdList) // Set the client reference IDs for the search .build(); - // Check if the client reference ID list is not empty + + // Check if the list of client reference IDs is not empty if (!CollectionUtils.isEmpty(clientReferenceIdList)) { - // Query the repository to find existing entities by client reference IDs + // Query the repository to find existing Stock entities with the given client reference IDs List existingClientReferenceIds = stockRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE); - // For each existing entity, populate error details for uniqueness + + // For each existing client reference ID, add an error to the map for the corresponding Stock entity existingClientReferenceIds.forEach(clientReferenceId -> { + // Get a predefined error object for unique entity validation Error error = getErrorForUniqueEntity(); + // Populate error details for the individual Stock entity associated with the client reference ID populateErrorDetails(map.get(clientReferenceId), error, errorDetailsMap); }); } + + // Return the map containing Stock entities and their associated error details return errorDetailsMap; } } diff --git a/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java b/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java index 52c60f4ba1..6917135941 100644 --- a/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java +++ b/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java @@ -53,31 +53,42 @@ public SrExistentEntityValidator(StockReconciliationRepository stockReconciliati public Map> validate(StockReconciliationBulkRequest request) { // Map to hold StockReconciliation entities and their error details Map> errorDetailsMap = new HashMap<>(); + // Get the list of StockReconciliation entities from the request List entities = request.getStockReconciliation(); - // Extract client reference IDs from StockReconciliation entities without errors + + // Extract client reference IDs from StockReconciliation entities that do not already have errors List clientReferenceIdList = entities.stream() - .filter(notHavingErrors()) - .map(StockReconciliation::getClientReferenceId) - .collect(Collectors.toList()); + .filter(notHavingErrors()) // Filter out entities with existing errors + .map(StockReconciliation::getClientReferenceId) // Map entities to their client reference IDs + .collect(Collectors.toList()); // Collect IDs into a list + + // Create a map for quick lookup of StockReconciliation entities by their client reference ID Map map = entities.stream() - .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) - .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); - // Create a search object for querying entities by client reference IDs + .filter(entity -> StringUtils.hasText(entity.getClientReferenceId())) // Ensure client reference ID is not empty + .collect(Collectors.toMap(entity -> entity.getClientReferenceId(), entity -> entity)); // Collect to a map + + // Create a search object to query existing entities by client reference IDs StockReconciliationSearch stockReconciliationSearch = StockReconciliationSearch.builder() - .clientReferenceId(clientReferenceIdList) + .clientReferenceId(clientReferenceIdList) // Set the client reference IDs for the search .build(); - // Check if the client reference ID list is not empty + + // Check if the list of client reference IDs is not empty if (!CollectionUtils.isEmpty(clientReferenceIdList)) { - // Query the repository to find existing entities by client reference IDs + // Query the repository to find existing StockReconciliation entities with the given client reference IDs List existingClientReferenceIds = stockReconciliationRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE); - // For each existing entity, populate error details for uniqueness + + // For each existing client reference ID, add an error to the map for the corresponding StockReconciliation entity existingClientReferenceIds.forEach(clientReferenceId -> { + // Get a predefined error object for unique entity validation Error error = getErrorForUniqueEntity(); + // Populate error details for the individual StockReconciliation entity associated with the client reference ID populateErrorDetails(map.get(clientReferenceId), error, errorDetailsMap); }); } + + // Return the map containing StockReconciliation entities and their associated error details return errorDetailsMap; } }