Skip to content

Commit

Permalink
hcm v1.5 : dev to master (#855)
Browse files Browse the repository at this point in the history
* Hlm 6385 irs changes (#841)

* HLM-6385: added changes for IRS activity track and closed household concepts

* HLM-6385: added changes for IRS activity track and closed household concepts, added db migration script, validations for closed household

* HLM-6385: added changes for location tracking

* HLM-6385: added changes for location points

* HLM-6385: added clientReferenceId and tenantId in LocationPoint, updated Location_capture model

* HLM-6385, HCMPRE-46: Updated changes as per design review

* HLM-6385, HCMPRE-46: Added Location capture changes

* HLM-6385, HCMPRE-46: Added UserAction changes

* HLM-6385, HCMPRE-46: updated common models, replaced digit models with service-common

* Revert "HLM-6385, HCMPRE-46: updated common models, replaced digit models with service-common"

This reverts commit 6abdea4.

* HLM-6385, HCMPRE-46: updated table informations and columns for migration scripts

* reverting BoundaryUtil change

* reverting BoundaryUtil changes

* HLM-6385, HCMPRE-46: updated validators and IRSConsumer

* HLM-6385, HCMPRE-46: updated validators

* HLM-6385, HCMPRE-46: updated project configuration

* HLM-6385, HCMPRE-49: updated models to have isDeleted as it is required in common utils enrichment code

* HLM-6385, HCMPRE-46: updated the projectid field, added notnull annotation

* HLM-6385, HCMPRE-46: updated all the changes related to enrichment

* HLM-6385, HCMPRE-46: made action field notnull

* HLM-6385, HCMPRE-46: updated locationCapture and userAction with mandatory latitude, longitude, locationAccuracy fields

* HLM-6385, HCMPRE-46: updated locationCapture and userAction with mandatory latitude, longitude, locationAccuracy fields, HCMPRE-116, HCMPRE-117

* HLM-6385, HCMPRE-46: updated locationCapture and userAction with mandatory latitude, longitude, locationAccuracy fields, HCMPRE-116, HCMPRE-117, added in services

* HLM-6385, HCMPRE-46: removed outdated changes from Task.java

* removed all user location models

* Refactored from LocationCapture model to UserAction and packges from irs to useraction

* HLM-6385 - lat/long irs name changes

* HLM Downsync Incremental product changes pull from impel (#831)

* HLM Downsync Incremental product changes pull from impel

* HLM removed impel specific changes

* renamed Project type filter code constant

* HLM updated beneficiary based search

* HLM updated downsync search, cycles is required only when it is smc based campaign

* HCM - removed project task resource quantity validator

* HLM updated downsync logic as per review comments

* HCMPRE-216 : Added Administration failed status for validation when task resource is empty or when status is ADMINISTRATION_FAILED

* HCMPRE-216: updated task status

* HCMPRE-216: changed to ADMINISTRATION_FAILED

* HLM-6385: updated with code review comments

* HLM-6385: added changes as per review comments, and added correct logs wherever required.

* HLM-6385: code review comments addressed.

* HLM-6385: review comment added for error handling on LocationCaptureRepository

* HLM-6385: another batch of coderabbitai code review comments addressed.

* HLM-6385: added more logs in repository for useraction and location capture

* HLM-6385: updated the code as per code review comments from @kavi-egov

---------

Co-authored-by: kavi_elrey <[email protected]>
Co-authored-by: Holash Chand <[email protected]>

* Hcmpre 240 (#846)

* HLM closed household status

* HCMPRE-240: validate no resource task status scenario with configurable statuses

* HCMPRE-240: fixed issues related to string trimming

* HLM fixed rowversion referral bug, mis placement of rowversion validator

* HCMPRE-240: code review changes

* HCMPRE-242: updated for null resources and address check

* HCMPRE-242: added for proper null check

* HCMPRE-242: added checks for task resource where ever applicable

* HCMPRE-242: updated taskstatus to enum from string

* HCMPRE-242, HCMPRE-240: renamed task's status field to taskStatus field, as there is contradiction with EgovModel status field

* HCMPRE-242: fixed dupcalite entity cache issue for existing entity validation during bulk create

* HCMPRE-242: updated project test case for taskStatus field contraints changes : not null

* HCMPRE-242: fix generic repository code

* HCMPRE-242: added taskstatus migration script

* HCMPRE-240: updated PtIsResourceEmptyValidator, for task status

* HLM-242: added changes as per code review

* Revert "HCMPRE-242: added taskstatus migration script", and removed status field from EgovModel, and rename TaskStatus to status

This reverts commit 7caf0c4.

* HCMPRE-240: FIXED all task status reference

---------

Co-authored-by: sivajiganesh-dev <[email protected]>

* HLM rowmapper issue in household, referral fixed (#848)

* HLM rowmapper issue in household, referral fixed

* HCMPRE-255: updated the changes for household

* reverted local changes commit by mistake

* added logic for cascading project date updates (#834)

* added logic for cascading project date updates

* updated application.properties

* refactored logic for using ProjectRequest pojo to send message to kafka instead of Ancestor and Descendant Projects pojo

* added comments and enhanced search project logic

* made public back to private

* made  more concise the method in project service separated create project map logic

* separated concerns of update based on action whether null or updateProjectDates

* updated action logic for just test purpose

* updated version of health-service-models library

* update logic

* updated final logic for cascading update project dates based on flag in project request

* reverted config

* reverted config 2

* added multiple line comments

* udpated error messages

* HLM fixed issues in useraction existent entity validator (#850)

* HLM fixed issues in useraction existent entity validator

* updated after code review comments

* updated version for hcm v1.5 release (#852)

* updated version for hcm v1.5 release

* HLM updated the code as per code review from code rabbit

* HCMPRE-209: updated code review comments and code documentation

---------

Co-authored-by: kavi_elrey <[email protected]>
Co-authored-by: Holash Chand <[email protected]>
Co-authored-by: sivajiganesh-dev <[email protected]>
Co-authored-by: nitish-egov <[email protected]>
  • Loading branch information
5 people authored Aug 12, 2024
1 parent 0a99f06 commit 8208b6f
Show file tree
Hide file tree
Showing 72 changed files with 3,671 additions and 531 deletions.
2 changes: 1 addition & 1 deletion health-services/household/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>org.egov.common</groupId>
<artifactId>health-services-common</artifactId>
<version>1.0.17-SNAPSHOT</version>
<version>1.0.18-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.egov.common</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface Constants {

String INDIVIDUAL_ALREADY_MEMBER_OF_HOUSEHOLD = "INDIVIDUAL_ALREADY_MEMBER_OF_HOUSEHOLD";

String INDIVIDUAL_ALREADY_MEMBER_OF_HOUSEHOLD_MESSAGE = "individual is already member od household";
String INDIVIDUAL_ALREADY_MEMBER_OF_HOUSEHOLD_MESSAGE = "individual is already member of household";

String INDIVIDUAL_NOT_FOUND = "INDIVIDUAL_NOT_FOUND";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
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;
Expand Down Expand Up @@ -45,39 +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<HouseholdMember, List<Error>> validate(HouseholdMemberBulkRequest request) {
// Map to hold HouseholdMember entities and their error details
// Map to hold HouseholdMember entities and their associated error details
Map<HouseholdMember, List<Error>> errorDetailsMap = new HashMap<>();

// Get the list of HouseholdMember entities from the request
List<HouseholdMember> 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<String> 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();
// Check if the client reference ID list is not empty

// Create a map of client reference ID to HouseholdMember entity for easy lookup
Map<String, HouseholdMember> 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

// 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<HouseholdMember> existentEntities = householdMemberRepository.findById(
clientReferenceIdList,
getIdFieldName(householdSearch),
Boolean.FALSE).getResponse();
// For each existing entity, populate error details for uniqueness
existentEntities.forEach(entity -> {
List<String> existingClientReferenceIds =
householdMemberRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE);

// 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();
populateErrorDetails(entity, error, errorDetailsMap);
// 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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
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;

/**
* 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
Expand All @@ -44,38 +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<Household, List<Error>> validate(HouseholdBulkRequest request) {
// Map to hold household entities and their error details
// Map to hold household entities and their associated error details
Map<Household, List<Error>> errorDetailsMap = new HashMap<>();

// Get the list of household entities from the request
List<Household> 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<String> 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<String, Household> 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 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<Household> existentEntities = householdRepository.findById(
clientReferenceIdList,
getIdFieldName(householdSearch),
Boolean.FALSE).getResponse();
// For each existing entity, populate error details for uniqueness
existentEntities.forEach(entity -> {
List<String> existingClientReferenceIds =
householdRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE);

// 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();
populateErrorDetails(entity, error, errorDetailsMap);
// 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;
}

Expand Down
2 changes: 1 addition & 1 deletion health-services/individual/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<dependency>
<groupId>org.egov.common</groupId>
<artifactId>health-services-common</artifactId>
<version>1.0.17-SNAPSHOT</version>
<version>1.0.18-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.egov.common</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
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;

/**
* 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
Expand All @@ -44,40 +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<Individual, List<Error>> validate(IndividualBulkRequest request) {
// Map to hold individual entities and their error details
// Map to hold individual entities and their associated error details
Map<Individual, List<Error>> errorDetailsMap = new HashMap<>();

// Get the list of individual entities from the request
List<Individual> 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<String> 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<String, Individual> 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 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<Individual> existentEntities = individualRepository.findById(
clientReferenceIdList,
getIdFieldName(individualSearch),
Boolean.FALSE).getResponse();
// For each existing entity, populate error details for uniqueness
existentEntities.forEach(entity -> {
List<String> existingClientReferenceIds =
individualRepository.validateClientReferenceIdsFromDB(clientReferenceIdList, Boolean.TRUE);

// 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();
populateErrorDetails(entity, error, errorDetailsMap);
// 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;
}

}

67 changes: 0 additions & 67 deletions health-services/libraries/docker-compose.yml

This file was deleted.

3 changes: 3 additions & 0 deletions health-services/libraries/health-services-common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion health-services/libraries/health-services-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<artifactId>health-services-common</artifactId>
<packaging>jar</packaging>
<name>health-services-common</name>
<version>1.0.17-SNAPSHOT</version>
<version>1.0.18-SNAPSHOT</version>
<description>Shared classes among services</description>

<parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,23 @@ public List<String> validateIds(List<String> idsToValidate, String columnName){
return validIds.stream().map((obj) -> (String) ReflectionUtils.invokeMethod(idMethod, obj))
.collect(Collectors.toList());
}

public List<String> validateClientReferenceIdsFromDB(List<String> clientReferenceIds, Boolean isDeletedKeyPresent) {
List<String> objFound = new ArrayList<>();

String query = null;

if(isDeletedKeyPresent) {
query = String.format("SELECT clientReferenceId FROM %s WHERE clientReferenceId IN (:ids) AND isDeleted = false", tableName);
} else {
query = String.format("SELECT clientReferenceId FROM %s WHERE clientReferenceId IN (:ids) ", tableName);
}

Map<String, Object> paramMap = new HashMap<>();
paramMap.put("ids", clientReferenceIds);

objFound.addAll(namedParameterJdbcTemplate.queryForList(query, paramMap, String.class));

return objFound;
}
}
Loading

0 comments on commit 8208b6f

Please sign in to comment.