Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #1362

Merged
merged 31 commits into from
Jan 28, 2025
Merged

Dev #1362

Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0e1092f
Hlm 6385 irs changes (#841)
kanishq-egov Aug 5, 2024
948e75a
Hcmpre 240 (#846)
kanishq-egov Aug 8, 2024
852e041
HLM rowmapper issue in household, referral fixed (#848)
kanishq-egov Aug 8, 2024
b41383e
added logic for cascading project date updates (#834)
nitish-egov Aug 8, 2024
3bef90b
HLM fixed issues in useraction existent entity validator (#850)
kanishq-egov Aug 9, 2024
af4b8ed
updated version for hcm v1.5 release (#852)
kanishq-egov Aug 12, 2024
2705fed
Hcmpre 309 rebase (#857)
kanishq-egov Aug 19, 2024
f99475a
HCMPRE-169 code review comments (#835)
Priyanka-eGov Sep 5, 2024
1ed7c59
HCMPRE-218 adding validation for plan config name (#844)
Priyanka-eGov Sep 5, 2024
6498f88
HCMPRE-646: added changes (#897)
kanishq-egov Sep 23, 2024
958201f
Update CODEOWNERS (#924)
kavi-egov Sep 30, 2024
de909f1
Hcmpre 639 shashwat changes (#919)
kanishq-egov Sep 30, 2024
1a73719
Fixed multiple role search in individual service (#992)
shashwat-egov Oct 16, 2024
caaf707
Hcmpre 639 shashwat changes (#973)
Shashwat12-egov Nov 6, 2024
46751ca
HCMPRE-371: Added service definition update api (#996)
yashita-egov Nov 11, 2024
e1cefd6
Update ValidatorUtil.java (#1112)
Shashwat12-egov Nov 13, 2024
9bba4d0
added-search-criterias-project-service (#1169)
nitish-egov Nov 25, 2024
26763cf
Service additional field (#1146)
Shashwat12-egov Dec 4, 2024
ff4c11b
Hcmpre 469 pagination all (#891)
kanishq-egov Dec 9, 2024
7d3c4cb
PR to develop branch for Microplanning v0.1 (changes in plan-service,…
Priyanka-eGov Dec 12, 2024
4c2631f
Merge branch 'master' into dev
kavi-egov Dec 13, 2024
de07af9
HCMPRE-874: Model changes (#1305)
yashita-egov Jan 3, 2025
958bdde
Hcmpre 874: Beneficiary Type Enum added (#1033)
yashita-egov Jan 3, 2025
93df243
updated changelog for health-services-model (#1313)
yashita-egov Jan 3, 2025
235cb3e
[HCMPRE-857, HCMPRE-1139, HCMPRE-1303, HCMPRE-1158] Changes in hrms-s…
tanishi-egov Jan 27, 2025
cfbfc8a
Added support to search projects based on ancestor project id (#1298)
holashchand Jan 27, 2025
23c0ddc
HCMPRE-1254-Adding household type for communal living facility (#1124)
shubhang-eGov Jan 28, 2025
3364b06
enrich skill and localityCode in individual (#1363)
yashita-egov Jan 28, 2025
7202414
Dev merge resolve (#1364)
holashchand Jan 28, 2025
beca052
Merge branch 'master' into dev
kavi-egov Jan 28, 2025
786d735
added changelog for household service (#1365)
yashita-egov Jan 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core-services/egov-hrms/pom.xml
Original file line number Diff line number Diff line change
@@ -39,11 +39,11 @@
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>9.22.3</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.1</version>
</dependency>
<dependency>
<groupId>org.egov.services</groupId>
Original file line number Diff line number Diff line change
@@ -82,7 +82,13 @@ public class PropertiesManager {

@Value("${egov.idgen.path}")
public String idGenEndpoint;


// Email
@Value("${kafka.topics.notification.email}")
private String emailNotifTopic;

@Value("${notification.email.enabled}")
private Boolean isEmailNotificationEnabled;

//Kafka Topics
@Value("${kafka.topics.save.service}")
@@ -96,7 +102,9 @@ public class PropertiesManager {

@Value("${kafka.topics.hrms.updateData}")
public String updateTopic;


@Value("${kafka.topics.hrms.email.notification}")
public String hrmsEmailNotifTopic;

//Variables
@Value("${egov.idgen.ack.name}")
@@ -140,4 +148,10 @@ public class PropertiesManager {

@Value("${egov.boundary.search.url}")
private String boundarySearchUrl;

@Value("${hrms.email.notification.implementation.partner}")
public String emailNotificationImplementationPartner;

@Value("${hrms.email.notification.website.link}")
public String emailNotificationWebsiteLink;
}
Original file line number Diff line number Diff line change
@@ -32,12 +32,17 @@ public class HrmsConsumer {
@Autowired
private PropertiesManager propertiesManager;

@KafkaListener(topics = {"${kafka.topics.hrms.updateData}"})
@KafkaListener(topics = {"${kafka.topics.hrms.updateData}", "${kafka.topics.hrms.email.notification}"})
public void listenUpdateEmployeeData(final HashMap<String, Object> record,@Header(KafkaHeaders.RECEIVED_TOPIC) String topic) {
try {
EmployeeRequest employeeRequest = mapper.convertValue(record, EmployeeRequest.class);
hrmsProducer.push(propertiesManager.getUpdateEmployeeTopic(), employeeRequest);
notificationService.sendReactivationNotification(employeeRequest);

if(topic.equals(propertiesManager.getHrmsEmailNotifTopic())) {
notificationService.processEmailNotification(employeeRequest);
} else {
hrmsProducer.push(propertiesManager.getUpdateEmployeeTopic(), employeeRequest);
notificationService.sendReactivationNotification(employeeRequest);
}
} catch (final Exception e) {

log.error("Error while listening to value: " + record + " on topic: " + topic + ": ", e);
Original file line number Diff line number Diff line change
@@ -103,6 +103,9 @@ public class EmployeeService {
@Autowired
private ObjectMapper objectMapper;

@Autowired
private IndividualService individualService;

/**
* Service method for create employee. Does following:
* 1. Sets ids to all the objects using idgen service.
@@ -121,8 +124,12 @@ public EmployeeResponse create(EmployeeRequest employeeRequest) {
enrichCreateRequest(employee, requestInfo);
createUser(employee, requestInfo);
pwdMap.put(employee.getUuid(), employee.getUser().getPassword());
employee.getUser().setPassword(null);
});
hrmsProducer.push(propertiesManager.getHrmsEmailNotifTopic(), employeeRequest);

// Setting password as null after sending employeeRequest to email notification topic to send email.
employeeRequest.getEmployees().forEach(employee -> employee.getUser().setPassword(null));

hrmsProducer.push(propertiesManager.getSaveEmployeeTopic(), employeeRequest);
notificationService.sendNotification(employeeRequest, pwdMap);
return generateResponse(employeeRequest);
@@ -137,6 +144,7 @@ public EmployeeResponse create(EmployeeRequest employeeRequest) {
*/
public EmployeeResponse search(EmployeeSearchCriteria criteria, RequestInfo requestInfo) {
boolean userChecked = false;
Long totalCount = 0L;
/*if(null == criteria.getIsActive() || criteria.getIsActive())
criteria.setIsActive(true);
else
@@ -156,6 +164,7 @@ public EmployeeResponse search(EmployeeSearchCriteria criteria, RequestInfo requ
userSearchCriteria.put(HRMSConstants.HRMS_USER_SEARCH_CRITERA_USERNAME, criteria.getCodes().get(0));
}
UserResponse userResponse = userService.getUser(requestInfo, userSearchCriteria);
totalCount = userResponse.getTotalCount();
userChecked =true;
if(!CollectionUtils.isEmpty(userResponse.getUser())) {
mapOfUsers.putAll(userResponse.getUser().stream()
@@ -178,6 +187,7 @@ public EmployeeResponse search(EmployeeSearchCriteria criteria, RequestInfo requ
userSearchCriteria.put(HRMSConstants.HRMS_USER_SEARCH_CRITERA_TENANTID,criteria.getTenantId());
userSearchCriteria.put(HRMSConstants.HRMS_USER_SEARCH_CRITERA_NAME,name);
UserResponse userResponse = userService.getUser(requestInfo, userSearchCriteria);
totalCount = userResponse.getTotalCount();
userChecked =true;
if(!CollectionUtils.isEmpty(userResponse.getUser())) {
mapOfUsers.putAll(userResponse.getUser().stream()
@@ -191,6 +201,32 @@ public EmployeeResponse search(EmployeeSearchCriteria criteria, RequestInfo requ
else
criteria.setUuids(userUUIDs);
}

if(!CollectionUtils.isEmpty(criteria.getUserServiceUuids())) {
List<String> userUUIDs = new ArrayList<>();
Map<String, Object> userSearchCriteria = new HashMap<>();

userSearchCriteria.put(HRMSConstants.HRMS_USER_SERACH_CRITERIA_USERTYPE_CODE, HRMSConstants.HRMS_USER_SERACH_CRITERIA_USERTYPE);
userSearchCriteria.put(HRMSConstants.HRMS_USER_SEARCH_CRITERA_TENANTID, criteria.getTenantId());
userSearchCriteria.put(HRMSConstants.HRMS_USER_SEARCH_CRITERA_USER_SERVICE_UUIDS, criteria.getUserServiceUuids());
if(!CollectionUtils.isEmpty(criteria.getNames()))
userSearchCriteria.put(HRMSConstants.HRMS_USER_SEARCH_CRITERA_NAME, criteria.getNames().get(0));
UserResponse userResponse = userService.getUser(requestInfo, userSearchCriteria);
totalCount = userResponse.getTotalCount();
userChecked =true;
if(!CollectionUtils.isEmpty(userResponse.getUser())) {
mapOfUsers.putAll(userResponse.getUser().stream()
.collect(Collectors.toMap(User::getUuid, Function.identity())));
}

List<String> uuids = userResponse.getUser().stream().map(User :: getUuid).collect(Collectors.toList());
userUUIDs.addAll(uuids);

if(!CollectionUtils.isEmpty(criteria.getUuids()))
criteria.setUuids(criteria.getUuids().stream().filter(userUUIDs::contains).collect(Collectors.toList()));
else
criteria.setUuids(userUUIDs);
}
}
if(userChecked)
criteria.setTenantId(null);
@@ -207,6 +243,7 @@ public EmployeeResponse search(EmployeeSearchCriteria criteria, RequestInfo requ
if(mapOfUsers.isEmpty()){
log.info("searching in user service");
UserResponse userResponse = userService.getUser(requestInfo, userSearchCriteria);
totalCount = userResponse.getTotalCount();
if(!CollectionUtils.isEmpty(userResponse.getUser())) {
mapOfUsers = userResponse.getUser().stream()
.collect(Collectors.toMap(User :: getUuid, Function.identity()));
@@ -217,7 +254,8 @@ public EmployeeResponse search(EmployeeSearchCriteria criteria, RequestInfo requ
}
}
return EmployeeResponse.builder().responseInfo(factory.createResponseInfoFromRequestInfo(requestInfo, true))
.employees(employees).build();
.employees(employees)
.totalCount(totalCount).build();
}


@@ -231,7 +269,14 @@ private void createUser(Employee employee, RequestInfo requestInfo) {
enrichUser(employee);
UserRequest request = UserRequest.builder().requestInfo(requestInfo).user(employee.getUser()).build();
try {
UserResponse response = userService.createUser(request);
UserResponse response;
if(userService instanceof IndividualService) {
String localityCode = (employee.getJurisdictions()!=null && !employee.getJurisdictions().isEmpty())? employee.getJurisdictions().get(0).getBoundary() : null;
response = individualService.createUserByLocality(request, localityCode);
}
else{
response = userService.createUser(request);
}
User user = response.getUser().get(0);
employee.setId(UUID.fromString(user.getUuid()).getMostSignificantBits());
employee.setUuid(user.getUuid());
Original file line number Diff line number Diff line change
@@ -17,26 +17,19 @@
import org.apache.commons.lang3.StringUtils;
import org.egov.common.contract.request.RequestInfo;
import org.egov.common.models.core.Role;
import org.egov.common.models.individual.Address;
import org.egov.common.models.individual.AddressType;
import org.egov.common.models.individual.Gender;
import org.egov.common.models.individual.Identifier;
import org.egov.common.models.individual.Individual;
import org.egov.common.models.individual.IndividualBulkResponse;
import org.egov.common.models.individual.IndividualRequest;
import org.egov.common.models.individual.IndividualResponse;
import org.egov.common.models.individual.Name;
import org.egov.common.models.individual.UserDetails;
import org.egov.common.models.individual.*;
import org.egov.hrms.config.PropertiesManager;
import org.egov.hrms.repository.RestCallRepository;
import org.egov.hrms.utils.HRMSConstants;
import org.egov.hrms.web.contract.User;
import org.egov.hrms.web.contract.UserRequest;
import org.egov.hrms.web.contract.UserResponse;
import org.egov.hrms.web.models.IndividualBulkResponse;
import org.egov.hrms.web.models.IndividualSearch;
import org.egov.hrms.web.models.IndividualSearchRequest;
import org.springframework.beans.factory.annotation.Autowired;

import static org.egov.hrms.utils.HRMSConstants.HRMS_USER_SEARCH_CRITERA_USER_SERVICE_UUIDS;
import static org.egov.hrms.utils.HRMSConstants.SYSTEM_GENERATED;

@Slf4j
@@ -56,7 +49,7 @@ public IndividualService(PropertiesManager propertiesManager,

@Override
public UserResponse createUser(UserRequest userRequest) {
IndividualRequest request = mapToIndividualRequest(userRequest);
IndividualRequest request = mapToIndividualRequest(userRequest, null);
StringBuilder uri = new StringBuilder();
uri.append(propertiesManager.getIndividualHost());
uri.append(propertiesManager.getIndividualCreateEndpoint());
@@ -70,6 +63,21 @@ public UserResponse createUser(UserRequest userRequest) {
return userResponse;
}

public UserResponse createUserByLocality(UserRequest userRequest, String localityCode) {
IndividualRequest request = mapToIndividualRequest(userRequest,localityCode);
StringBuilder uri = new StringBuilder();
uri.append(propertiesManager.getIndividualHost());
uri.append(propertiesManager.getIndividualCreateEndpoint());
IndividualResponse response = restCallRepository
.fetchResult(uri, request, IndividualResponse.class);
UserResponse userResponse = null;
if (response != null && response.getIndividual() != null) {
log.info("response received from individual service");
userResponse = mapToUserResponse(response);
}
return userResponse;
}

/**
* Updates a user by searching for the corresponding individual and updating their details.
*
@@ -210,6 +218,7 @@ public UserResponse getUser(RequestInfo requestInfo, Map<String, Object> userSea
mobileNumberList
)
.id((List<String>) userSearchCriteria.get("uuid"))
.userUuid((List<String>) userSearchCriteria.get(HRMS_USER_SEARCH_CRITERA_USER_SERVICE_UUIDS))
.roleCodes((List<String>) userSearchCriteria.get("roleCodes"))
.username(usernameList)
// given name
@@ -256,7 +265,7 @@ private static Date convertMillisecondsToDate(long milliseconds) {
}
}

private static IndividualRequest mapToIndividualRequest(UserRequest userRequest) {
private static IndividualRequest mapToIndividualRequest(UserRequest userRequest, String localityCode) {
Individual individual = Individual.builder()
.id(userRequest.getUser().getUuid())
.userId(userRequest.getUser().getId() != null ?
@@ -276,6 +285,7 @@ private static IndividualRequest mapToIndividualRequest(UserRequest userRequest)
.type(AddressType.CORRESPONDENCE)
.addressLine1(userRequest.getUser().getCorrespondenceAddress())
.clientReferenceId(String.valueOf(UUID.randomUUID()))
.locality((localityCode!=null) ? Boundary.builder().code(localityCode).build() : null)
.isDeleted(Boolean.FALSE)
.build()))
/*
@@ -306,6 +316,9 @@ private static IndividualRequest mapToIndividualRequest(UserRequest userRequest)
.build()).collect(Collectors.toList()))
.userType(UserType.fromValue(userRequest.getUser().getType()))
.build())
.skills(userRequest.getUser().getRoles().stream().map(role -> Skill.builder()
.type(role.getCode()).level(role.getCode())
.build()).collect(Collectors.toList()))
.isDeleted(Boolean.FALSE)
.clientAuditDetails(AuditDetails.builder().createdBy(userRequest.getRequestInfo().getUserInfo().getUuid()).lastModifiedBy(userRequest.getRequestInfo().getUserInfo().getUuid()).build())
.rowVersion(userRequest.getUser().getRowVersion())
@@ -331,6 +344,7 @@ private static UserResponse mapToUserResponse(IndividualBulkResponse response) {
.responseInfo(response.getResponseInfo())
.user(response.getIndividual().stream()
.map(IndividualService::getUser).collect(Collectors.toList()))
.totalCount(response.getTotalCount())
.build();
return userResponse;
}
Original file line number Diff line number Diff line change
@@ -11,30 +11,40 @@
import org.egov.hrms.producer.HRMSProducer;
import org.egov.hrms.repository.RestCallRepository;
import org.egov.hrms.utils.HRMSConstants;
import org.egov.hrms.utils.NotificationUtil;
import org.egov.hrms.web.contract.EmailRequest;
import org.egov.hrms.web.contract.EmployeeRequest;
import org.egov.hrms.web.contract.RequestInfoWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.jayway.jsonpath.JsonPath;

import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;

import static org.egov.hrms.utils.HRMSConstants.HEALTH_HRMS_EMAIL_LOCALIZATION_CODE;

@Service
@Slf4j
public class NotificationService {

@Autowired

private HRMSProducer producer;

@Autowired

private RestCallRepository repository;

@Autowired
private RestTemplate restTemplate;

private NotificationUtil notificationUtil;

public NotificationService(HRMSProducer producer, RestCallRepository repository, RestTemplate restTemplate, NotificationUtil notificationUtil) {
this.producer = producer;
this.repository = repository;
this.restTemplate = restTemplate;
this.notificationUtil = notificationUtil;
}

@Value("${kafka.topics.notification.sms}")
private String smsTopic;

@@ -193,4 +203,26 @@ public Map<String, Map<String, String>> getLocalisedMessages(RequestInfo request
return localizedMessageMap;
}

/**
* Creates and sends email notification to the employees whose details are provided in the employeeRequest.
*
* @param employeeRequest The employee request with employee details.
*/
public void processEmailNotification(EmployeeRequest employeeRequest) {
if (employeeRequest == null || CollectionUtils.isEmpty(employeeRequest.getEmployees())) {
log.error("Invalid employee request received for email notification");
return;
}
try {
// Fetch localization messages and get email message template for HEALTH_HRMS_EMAIL_LOCALIZATION_CODE template code.
String localizationMessages = notificationUtil.getLocalizationMessages(employeeRequest);
String messageTemplate = notificationUtil.getMessageTemplate(HEALTH_HRMS_EMAIL_LOCALIZATION_CODE, localizationMessages);

// Create email requests from the employee details provided in the employeeRequest.
List<EmailRequest> emailRequests = notificationUtil.createEmailRequest(employeeRequest, messageTemplate);
notificationUtil.sendEmail(emailRequests);
} catch (Exception e) {
log.error("Error processing email notification for given employees");
}
}
}
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ public class HRMSConstants {
public static final String HRMS_EMP_CREATE_LOCLZN_CODE = "hrms.employee.create.notification";
public static final String HRMS_EMP_REACTIVATE_LOCLZN_CODE = "hrms.employee.reactivation.notification";
public static final String HRMS_LOCALIZATION_MODULE_CODE = "egov-hrms";
public static final String HEALTH_HRMS_LOCALIZATION_MODULE_CODE = "rainmaker-hr";
public static final String HEALTH_HRMS_EMAIL_LOCALIZATION_CODE = "HEALTH_HRMS_EMAIL_CODE";
public static final String HRMS_LOCALIZATION_ENG_LOCALE_CODE = "en_IN";
public static final String HRMS_TENANTBOUNDARY_HIERARCHY_JSONPATH = "$.TenantBoundary[?(@.boundary.code ==\"%s\")].hierarchyType.code";
public static final String HRMS_TENANTBOUNDARY_BOUNDARY_TYPE_JSONPATH ="$.TenantBoundary[?(@.hierarchyType.name==\"%1$s\" && @.boundary.code ==\"%2$s\")]..label";
@@ -39,6 +41,7 @@ public class HRMSConstants {
public static final String HRMS_MDMS_CODE_FLITER = "[?(@.active == true)].code";

public static final String HRMS_USER_SEARCH_CRITERA_UUID = "uuid";
public static final String HRMS_USER_SEARCH_CRITERA_USER_SERVICE_UUIDS = "userServiceUuids";
public static final String HRMS_USER_SEARCH_CRITERA_ROLECODES = "roleCodes";
public static final String HRMS_USER_SEARCH_CRITERA_TENANTID = "tenantId";
public static final String HRMS_USER_SEARCH_CRITERA_MOBILENO = "mobileNumber";
Loading
Loading