Resolved conflicts

This commit is contained in:
Piyush
2025-05-28 11:56:17 +05:30
committed by rajesh
parent 4cba5f8e44
commit eafd47ba5f
10 changed files with 351 additions and 61 deletions

View File

@@ -159,7 +159,8 @@ public class ApplicationAmendmentRequestDao {
String file=applicationEvaluationEntity.getFile();
String checkList=applicationEvaluationEntity.getChecklist();
if(file != null){
evaluationFileRequests=Utils.convertJsonStringToList(file,FieldRequest.class);
log.info("Parsing evaluation file data for evaluationId={}", applicationEvaluationId);
evaluationFileRequests=Utils.convertJsonStringToList(file,FieldRequest.class);
}
if(applicationEvaluationEntity.getEvaluationVersion().equals(EvaluationVersionEnum.V1.getValue())) {
checklistValidationForEvaluationV1(evaluationFileRequests, checkList, checklistRequests);
@@ -326,6 +327,7 @@ public class ApplicationAmendmentRequestDao {
applicationAmendmentRequestEntity.setNote(applicationAmendmentRequest.getNote());
applicationAmendmentRequestEntity.setResponseDays(applicationAmendmentRequest.getResponseDays());
if(applicationAmendmentRequest.getResponseDays()==null || applicationAmendmentRequest.getResponseDays() < 0){
log.warn("Invalid responseDays received: {}", applicationAmendmentRequest.getResponseDays());
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.RESPONSE_DAYS_NOT_NULL));
}
applicationAmendmentRequestEntity.setEndDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()).plusDays(applicationAmendmentRequest.getResponseDays()));
@@ -378,6 +380,8 @@ public class ApplicationAmendmentRequestDao {
userEntity.getHub().getId(),false);
applicationAmendmentRequestEntity.setProtocol(protocolEntity);
ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity, null, VersionActionTypeEnum.INSERT);
log.info("Amendment request saved with ID={}", applicationAmendment.getId());
String evaluationStatusType = applicationEvaluationEntity.getStatus();
if (Boolean.FALSE.equals(evaluationStatusType.equals((ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue())))){
// applicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
@@ -416,7 +420,7 @@ public class ApplicationAmendmentRequestDao {
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldAssignedApplication).newData(assignedApplicationsEntity).build());
}
log.info("Amendment creation process completed successfully for applicationId={}, evaluationId={}", applicationId, applicationEvaluationId);
return applicationAmendment;
}
private void setAmendmentDocuments(String amendmentNotes, String amendmentFieldRequest,
@@ -507,7 +511,7 @@ public class ApplicationAmendmentRequestDao {
}
public DocumentResponseBean createDocumentResponseBean(String documentId) {
log.info("Initiating document response creation for documentId={}", documentId);
if (!StringUtils.isEmpty(documentId)) {
Optional<DocumentEntity> documentEntity = documentRepository.findByIdAndNotDeleted(Long.valueOf(documentId));
if(documentEntity.isPresent()){
@@ -671,7 +675,9 @@ public class ApplicationAmendmentRequestDao {
}
public List<GetAllAmendmentResponseBean> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId) {
log.info("Entering getAllApplicationAmendmentRequest with userId={}", userId);
if (validator.checkIsPreInstructor() && userId == null) {
log.warn("Access denied: Pre-instructor must provide userId for amendment request retrieval.");
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
}
if (userId != null) {
@@ -714,9 +720,11 @@ public class ApplicationAmendmentRequestDao {
isBeneficiary=true;
}
if(Boolean.TRUE.equals(isBeneficiary) && existingApplicationAmendment.getStatus().equals(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue())){
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
log.warn("Permission denied: Beneficiary tried to update amendment ID {} with status RESPONSE_RECEIVED", id);
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
}
if(Boolean.FALSE.equals(isBeneficiary) && existingApplicationAmendment.getStatus().equals(ApplicationAmendmentRequestEnum.AWAITING.getValue())){
log.warn("Permission denied: Non-beneficiary tried to update amendment ID {} with status AWAITING", id);
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
}
@@ -739,10 +747,12 @@ public class ApplicationAmendmentRequestDao {
}
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
if(updateRequest.getAmendmentDocuments()!=null && Boolean.FALSE.equals(updateRequest.getAmendmentDocuments().isEmpty())) {
log.debug("Setting amendment documents for amendment ID: {}", id);
setAmendmentDocuments(updateRequest.getAmendmentNotes(),updateRequest.getAmendmentDocuments(), existingApplicationAmendment);
}
ApplicationAmendmentRequestEntity updatedApplicationAmendment = saveApplicationAmendmentRequestEntity(existingApplicationAmendment,oldApplicationAmendmentEntity,VersionActionTypeEnum.UPDATE);
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment,false);
log.info("Successfully updated ApplicationAmendmentRequest with ID: {}", id);
log.info("Application Amendment updated successfully: {}", response);
return response;
}
@@ -1038,6 +1048,7 @@ public class ApplicationAmendmentRequestDao {
public List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(Long beneficiaryUserId) {
log.info("Fetching all amendment requests for beneficiaryUserId={}", beneficiaryUserId);
UserEntity userEntity = userService.validateUser(beneficiaryUserId);
List<ApplicationAmendmentRequestEntity> entities =
applicationAmendmentRequestRepository.findByUserId(beneficiaryUserId);
@@ -1057,6 +1068,8 @@ public class ApplicationAmendmentRequestDao {
existingApplicationAmendment.getApplicationEvaluationEntity().getId()
);
log.debug("Found {} amendment requests for ApplicationEvaluationId={}", amendmentRequestList.size(), existingApplicationAmendment.getApplicationEvaluationEntity().getId());
// Check if this is the last amendment being closed
boolean isLastRemaining = amendmentRequestList.stream()
.filter(amendment -> !amendment.getId().equals(id)) // Exclude the current amendment
@@ -1074,6 +1087,8 @@ public class ApplicationAmendmentRequestDao {
}
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment,false);
log.info("Updated amendment status to CLOSE for amendment ID: {}", id);
List<ApplicationAmendmentRequestEntity> amendmentRequests = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(
existingApplicationAmendment.getApplicationEvaluationEntity().getId());
Boolean allClosed = amendmentRequests.stream().allMatch(amendment -> (amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()) || amendment.getStatus().equals(ApplicationAmendmentRequestEnum.EXPIRED.getValue())));
@@ -1081,16 +1096,17 @@ public class ApplicationAmendmentRequestDao {
ApplicationEntity oldApplicationEntityData = Utils.getClonedEntityForData(application);
if (Boolean.TRUE.equals(allClosed)) {
existingApplicationAmendment.getApplicationEvaluationEntity().setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
if (allClosed) {
ApplicationEvaluationEntity existingApplicationEvaluationEntity = existingApplicationAmendment.getApplicationEvaluationEntity();
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(existingApplicationEvaluationEntity);
existingApplicationEvaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
applicationEvaluationRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity());
log.info("Updated ApplicationEvaluation status to OPEN for ID: {}", existingApplicationEvaluationEntity.getId());
application.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue());
applicationRepository.save(application);
log.info("Updated Application status to EVALUATION for Application ID: {}", application.getId());
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsDao.validateAssignedApplication(
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getId());
@@ -1098,7 +1114,7 @@ public class ApplicationAmendmentRequestDao {
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().setStatus(AssignedApplicationEnum.OPEN.getValue());
assignedApplicationsEntity = assignedApplicationsRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity());
log.info("Updated AssignedApplication status to OPEN for ID: {}", assignedApplicationsEntity.getId());
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.AMENDMENT_CLOSED);
@@ -1125,6 +1141,7 @@ public class ApplicationAmendmentRequestDao {
public ApplicationAmendmentRequestResponse extendResponseDays(Long id, Long newResponseDays) {
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = validatApplicationAmendmentRequestByStatus(id,ApplicationAmendmentRequestEnum.EXPIRED.getValue());
log.info("Extending response days for Application Amendment ID: {}, Additional Days: {}", id, newResponseDays);
if (newResponseDays != null && newResponseDays > 0) {
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(applicationAmendmentRequestEntity);
@@ -1177,6 +1194,7 @@ public class ApplicationAmendmentRequestDao {
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
if (Boolean.TRUE.equals(existingApplicationAmendment.getStatus().equals(ApplicationAmendmentRequestEnum.AWAITING.getValue())) && Boolean.TRUE.equals(statusTypeEnum.equals(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED))) {
log.info("Updating amendment ID {} status from {} to {}", id, existingApplicationAmendment.getStatus(), statusTypeEnum);
existingApplicationAmendment.setStatus(ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue());
existingApplicationAmendment.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
applicationAmendmentRequestRepository.save(existingApplicationAmendment);
@@ -1191,8 +1209,12 @@ public class ApplicationAmendmentRequestDao {
public EmailReminderResponse sendReminderEmail(Long amendmentId) {
log.info("Initiating reminder email process for Amendment ID: {}", amendmentId);
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(amendmentId)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
.orElseThrow(() -> { log.error("Amendment not found with ID: {}", amendmentId);
return new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG));
});
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
EmailReminderResponse emailReminderResponse = new EmailReminderResponse();
@@ -1205,6 +1227,7 @@ public class ApplicationAmendmentRequestDao {
String body = prepareBody(emailTemplate, amendment, beneficiaryUser);
String email = beneficiaryUser.getEmail();
if (Boolean.TRUE.equals(amendment.getIsEmail()) && email != null && !email.isEmpty()) {
log.info("Sending reminder email to: {}", email);
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(emailTemplate.getEmailScenario(), RecipientTypeEnum.USER, beneficiaryUser.getId(), email,
beneficiaryUser.getId(), applicationEntity.getId(), amendment.getId(), applicationEntity.getCall().getId());
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email), emailLogRequest);
@@ -1217,7 +1240,9 @@ public class ApplicationAmendmentRequestDao {
else{
emailReminderResponse.setEmailSendResponse(Collections.emptyList());
}
log.info("Reminder email sent successfully for Amendment ID: {}", amendmentId);
} else {
log.warn("Beneficiary email not found or isEmail flag is false for Amendment ID: {}", amendmentId);
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.BENEFICIARY_EMAIL_NOT_FOUND_MSG));
}
}
@@ -1303,7 +1328,9 @@ public class ApplicationAmendmentRequestDao {
return response;
}
private void softDeleteDocument(Long documentId) {
log.info("Initiating soft delete for Document ID: {}", documentId);
documentService.deleteFile(documentId);
log.info("Document ID: {} soft deleted successfully.", documentId);
}
// public PageableResponseBean<List<ApplicationAmendmentRequestResponse>> getApplicationAmendmentByPaginnation(Long userId, ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
@@ -1422,6 +1449,7 @@ public class ApplicationAmendmentRequestDao {
// }
public PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> getApplicationAmendmentByPaginationByView(Long userId, ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
log.info("Fetching paginated application amendments for userId: {}", userId);
Integer pageNo = null;
Integer pageLimit = null;
if (applicationAmendmentPaginationRequestBean.getGlobalFilters() != null) {
@@ -1453,6 +1481,7 @@ public class ApplicationAmendmentRequestDao {
pageableResponseBean.setTotalRecords(entityPage.getTotalElements());
pageableResponseBean.setPageSize(entityPage.getSize());
log.info("Paginated response prepared successfully for userId: {}", userId);
return pageableResponseBean;
}
public Specification<ApplicationAmendmentRequestView> searchPaginationByView(Long userId,ApplicationAmendmentPaginationRequestBean applicationAmendmentPaginationRequestBean) {
@@ -1484,6 +1513,7 @@ public class ApplicationAmendmentRequestDao {
private List<Predicate> getPredicatesByView(ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean,
CriteriaBuilder criteriaBuilder, Root<ApplicationAmendmentRequestView> root,Long userId) {
log.info("Building predicates for userId: {}", userId);
Integer year = null;
String search = null;
Map<String, FilterCriteria> filters = new HashMap<>();
@@ -1503,6 +1533,7 @@ public class ApplicationAmendmentRequestDao {
LocalDateTime startOfYear = LocalDateTime.of(filterYear, 1, 1, 0, 0);
LocalDateTime endOfYear = LocalDateTime.of(filterYear, 12, 31, 23, 59, 59);
log.debug("Filtering by year between {} and {}", startOfYear, endOfYear);
// Add the range comparison to filter records within the year
predicates.add(criteriaBuilder.between(root.get(GepafinConstant.CREATED_DATE), startOfYear, endOfYear));