Resolved conflict
This commit is contained in:
@@ -537,6 +537,20 @@ public class GepafinConstant {
|
||||
public static final String APPLICATION_STATUS="applicationStatus";
|
||||
|
||||
public static final String RINALDO_EMAIL = "rinaldo.bonazzo@bflows.net";
|
||||
public static final String RESEND_EMAIL_SENT_SUCCESS_MSG = "resend.email.sent.success.msg";
|
||||
public static final String RESEND_EMAIL_SENT_FAILED_MSG = "resend.email.sent.failed.msg";
|
||||
public static final String REMINDER_EMAIL_FAILED_MSG = "reminder.email.sent.failed.msg";
|
||||
|
||||
public static final String READMIT_APPLICATION_SUCCESS = "application.readmit.success";
|
||||
|
||||
public static final String NO_EMAIL_LOG_FOUND = "no.email.log.msg";
|
||||
public static final String USER_ACTION_ID_NOT_FOUND = "user.action.id.not.found";
|
||||
|
||||
public static final String CAUSE_STRING = "cause" ;
|
||||
public static final String ERROR_DESCRIPTION_STRING = "errorDescription" ;
|
||||
public static final String ERROR_STRING = "errors";
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
@@ -141,6 +142,12 @@ public class ApplicationAmendmentRequestDao {
|
||||
@Autowired
|
||||
private ApplicationDao applicationDao;
|
||||
|
||||
@Autowired
|
||||
private EmailLogRepository emailLogRepository;
|
||||
|
||||
@Autowired
|
||||
private EmailDao emailDao;
|
||||
|
||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(Long applicationEvaluationId) {
|
||||
log.info("Fetching the application data for the Amendment process {}", applicationEvaluationId);
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(applicationEvaluationId);
|
||||
@@ -301,6 +308,9 @@ public class ApplicationAmendmentRequestDao {
|
||||
log.info("Application submitted successfully for amendment", applicationAmendmentRequestResponse);
|
||||
if (Boolean.TRUE.equals(applicationAmendmentRequestResponse.getIsSendEmail())) {
|
||||
emailNotificationDao.sendMailToNotifyBeneficiaryRegardingNewAmendment(applicationAmendmentRequestEntity);
|
||||
EmailSendResponse emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
applicationAmendmentRequestResponse.setEmailSendResponse(emailSendResponse);
|
||||
saveEmailSendResponse(emailSendResponse, applicationAmendmentRequestEntity);
|
||||
}
|
||||
return applicationAmendmentRequestResponse;
|
||||
}
|
||||
@@ -645,12 +655,19 @@ public class ApplicationAmendmentRequestDao {
|
||||
log.info(" Application amendment deleted with ID: {}", id);
|
||||
}
|
||||
|
||||
public ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(Long id) {
|
||||
public ApplicationAmendmentRequestResponseBean getApplicationAmendmentRequestById(Long id) {
|
||||
log.info("Fetching application amendment with ID: {}", id);
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = validateApplicationAmendmentRequest(id);
|
||||
ApplicationAmendmentRequestResponse response = convertEntityToResponse(applicationAmendmentRequestEntity,true);
|
||||
log.info("Application Amendment fetched successfully by ID: {}", response);
|
||||
return response;
|
||||
ApplicationAmendmentRequestResponse sourceResponse = convertEntityToResponse(applicationAmendmentRequestEntity,true);
|
||||
ApplicationAmendmentRequestResponseBean targetResponse = Utils.convertSourceObjectToDestinationObject(
|
||||
sourceResponse, ApplicationAmendmentRequestResponseBean.class
|
||||
);
|
||||
|
||||
if (targetResponse != null) {
|
||||
targetResponse.setEmailSendResponse(applicationAmendmentRequestEntity.getEmailSendResponse());
|
||||
}
|
||||
log.info("Application Amendment fetched successfully by ID: {}", targetResponse);
|
||||
return targetResponse;
|
||||
}
|
||||
|
||||
public List<GetAllAmendmentResponseBean> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId) {
|
||||
@@ -1074,12 +1091,12 @@ public class ApplicationAmendmentRequestDao {
|
||||
|
||||
application.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue());
|
||||
applicationRepository.save(application);
|
||||
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().setStatus(AssignedApplicationEnum.OPEN.getValue());
|
||||
|
||||
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsDao.validateAssignedApplication(
|
||||
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getId());
|
||||
|
||||
AssignedApplicationsEntity oldAssignedApplicationData = Utils.getClonedEntityForData(assignedApplicationsEntity);
|
||||
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().setStatus(AssignedApplicationEnum.OPEN.getValue());
|
||||
|
||||
assignedApplicationsEntity = assignedApplicationsRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity());
|
||||
|
||||
|
||||
@@ -1172,12 +1189,13 @@ public class ApplicationAmendmentRequestDao {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void sendReminderEmail(Long amendmentId) {
|
||||
public EmailReminderResponse sendReminderEmail(Long amendmentId) {
|
||||
|
||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(amendmentId)
|
||||
.orElseThrow(() -> 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();
|
||||
if (entityOptional.isPresent()) {
|
||||
ApplicationEntity applicationEntity = applicationService.validateApplication(entityOptional.get().getApplicationId());
|
||||
UserEntity beneficiaryUser = userService.validateUser(applicationEntity.getUserId());
|
||||
@@ -1190,10 +1208,14 @@ public class ApplicationAmendmentRequestDao {
|
||||
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);
|
||||
EmailSendResponse emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
emailReminderResponse.setEmailSendResponse(emailSendResponse);
|
||||
saveEmailSendResponse(emailSendResponse, amendment);
|
||||
} else {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.BENEFICIARY_EMAIL_NOT_FOUND_MSG));
|
||||
}
|
||||
}
|
||||
return emailReminderResponse;
|
||||
}
|
||||
|
||||
private String prepareSubject(SystemEmailTemplateResponse template, ApplicationAmendmentRequestEntity amendment, UserEntity beneficiary) {
|
||||
@@ -1543,6 +1565,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
applicationAmendmentRequestViewResponse.setExpirationDate(applicationAmendmentRequestView.getExpirationDate());
|
||||
applicationAmendmentRequestViewResponse.setAssigendUserName(applicationAmendmentRequestView.getAssigendUserName());
|
||||
applicationAmendmentRequestViewResponse.setStatus(applicationAmendmentRequestView.getStatus());
|
||||
applicationAmendmentRequestViewResponse.setEmailSendResponse(applicationAmendmentRequestView.getEmailSendResponse());
|
||||
return applicationAmendmentRequestViewResponse;
|
||||
}
|
||||
|
||||
@@ -1628,11 +1651,17 @@ public class ApplicationAmendmentRequestDao {
|
||||
|
||||
|
||||
public ApplicationAmendmentRequestEntity validatApplicationAmendmentRequestByStatus(Long id,String status) {
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity= applicationAmendmentRequestRepository.findByIdAndIsDeletedFalseAndStatus(id,status);
|
||||
if(applicationAmendmentRequestEntity==null){
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG));
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalseAndStatus(id, status);
|
||||
if (applicationAmendmentRequestEntity == null) {
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG));
|
||||
}
|
||||
return applicationAmendmentRequestEntity;
|
||||
}
|
||||
private void saveEmailSendResponse(EmailSendResponse newResponses, ApplicationAmendmentRequestEntity amendment) {
|
||||
List<EmailSendResponse> mergedResponses = Utils.mergeEmailSendResponses(amendment.getEmailSendResponse(), newResponses);
|
||||
|
||||
amendment.setEmailSendResponse(mergedResponses);
|
||||
applicationAmendmentRequestRepository.save(amendment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1109,7 +1109,7 @@ public class ApplicationDao {
|
||||
if (userEntity.getBeneficiary() != null) {
|
||||
emailLogRequest.setRecipientType(RecipientTypeEnum.BENEFICIARY);
|
||||
email = userEntity.getBeneficiary().getEmail();
|
||||
emailLogRequest.setUserId(userEntity.getBeneficiary().getId());
|
||||
emailLogRequest.setRecipientId(userEntity.getBeneficiary().getId());
|
||||
}
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email),emailLogRequest);
|
||||
List<String> recipientEmails = new ArrayList<>();
|
||||
@@ -2134,4 +2134,119 @@ public class ApplicationDao {
|
||||
}
|
||||
|
||||
|
||||
public void sendApplicationSubmissionFailureEmail(EmailLogRequest emailLogRequest){
|
||||
|
||||
Long callId = emailLogRequest.getCallId();
|
||||
CallEntity call = callService.validateCall(callId);
|
||||
HubEntity hub = call.getHub();
|
||||
Long userId = emailLogRequest.getUserId();
|
||||
UserEntity user = userService.validateUser(userId);
|
||||
Long applicationId = emailLogRequest.getApplicatioId();
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
CompanyEntity company = companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
|
||||
|
||||
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService
|
||||
.retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum.APPLICATION_SUBMISSION_FAILURE_NOTIFICATION,
|
||||
hub, null);
|
||||
|
||||
Map<String, String> subjectPlaceholders = new HashMap<>();
|
||||
subjectPlaceholders.put("{{call_name}}", call.getName());
|
||||
|
||||
Map<String, String> bodyPlaceholders = new HashMap<>();
|
||||
bodyPlaceholders.put("{{scenario}}",emailLogRequest.getEmailType().getValue());
|
||||
bodyPlaceholders.put("{{call_name}}", call.getName());
|
||||
bodyPlaceholders.put("{{application_id}}", applicationEntity.getId().toString());
|
||||
bodyPlaceholders.put("{{company_name}}", company.getCompanyName());
|
||||
bodyPlaceholders.put("{{protocol_number}}", applicationEntity.getProtocol().getProtocolNumber().toString());
|
||||
bodyPlaceholders.put("{{user_action_id}}",emailLogRequest.getUserActionId().toString());
|
||||
|
||||
String subject = Utils.replacePlaceholders(systemEmailTemplateResponse.getSubject(), subjectPlaceholders);
|
||||
String body = Utils.replacePlaceholders(systemEmailTemplateResponse.getHtmlContent(), bodyPlaceholders);
|
||||
|
||||
emailLogRequest=emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(),RecipientTypeEnum.PROPERTIES,null,user.getEmail(),user.getId(),applicationEntity.getId(),null,callId);
|
||||
|
||||
emailLogRequest.setRecipientEmails(GepafinConstant.RINALDO_EMAIL);
|
||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(GepafinConstant.RINALDO_EMAIL),emailLogRequest);
|
||||
}
|
||||
|
||||
public ApplicationResponse readmitApplication(HttpServletRequest request, Long applicationId) {
|
||||
log.info("Re-admiting the Application with id : {}", applicationId);
|
||||
|
||||
ApplicationEntity applicationEntity = fetchRejectedApplication(applicationId);
|
||||
if(applicationEntity == null){
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG));
|
||||
}
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
|
||||
assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationEntity.getId())
|
||||
.ifPresent(assignedApp -> processAssignedAppAndEvaluation(request, applicationEntity, assignedApp));
|
||||
|
||||
return getApplicationResponse(applicationEntity);
|
||||
}
|
||||
private ApplicationEntity fetchRejectedApplication(Long applicationId) {
|
||||
return applicationRepository.findByIdAndStatusAndIsDeletedFalse(applicationId, ApplicationStatusTypeEnum.REJECTED.getValue());
|
||||
}
|
||||
|
||||
private void processAssignedAppAndEvaluation(HttpServletRequest request, ApplicationEntity applicationEntity, AssignedApplicationsEntity assignedApp) {
|
||||
applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndIsDeletedFalse(assignedApp.getId())
|
||||
.ifPresent(eval -> reopenApplication(request, applicationEntity, assignedApp, eval));
|
||||
}
|
||||
|
||||
|
||||
private void reopenApplication(HttpServletRequest request, ApplicationEntity applicationEntity,
|
||||
AssignedApplicationsEntity assignedApp, ApplicationEvaluationEntity evaluationEntity) {
|
||||
|
||||
ApplicationEntity oldApplication = Utils.getClonedEntityForData(applicationEntity);
|
||||
AssignedApplicationsEntity oldAssignedApp = Utils.getClonedEntityForData(assignedApp);
|
||||
ApplicationEvaluationEntity oldEvaluation = Utils.getClonedEntityForData(evaluationEntity);
|
||||
|
||||
updateApplicationStatus(applicationEntity);
|
||||
updateAssignedApplicationStatus(assignedApp);
|
||||
updateEvaluationEntity(applicationEntity.getHubId(), evaluationEntity);
|
||||
|
||||
saveEntities(applicationEntity, assignedApp, evaluationEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update Application" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplication).newData(applicationEntity).build());
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update Application Evaluation" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldEvaluation).newData(evaluationEntity).build());
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update Assigned Application" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldAssignedApp).newData(assignedApp).build());
|
||||
}
|
||||
|
||||
private void updateApplicationStatus(ApplicationEntity applicationEntity) {
|
||||
applicationEntity.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue());
|
||||
applicationEntity.setDateRejected(null);
|
||||
}
|
||||
|
||||
private void updateAssignedApplicationStatus(AssignedApplicationsEntity assignedApp) {
|
||||
assignedApp.setStatus(AssignedApplicationEnum.OPEN.getValue());
|
||||
}
|
||||
|
||||
private void updateEvaluationEntity(Long hubId, ApplicationEvaluationEntity evaluationEntity) {
|
||||
HubEntity hub = hubService.valdateHub(hubId);
|
||||
Long evaluationDays = (hub != null) ? hub.getEvaluationExpirationDays() : 30L;
|
||||
|
||||
LocalDateTime now = DateTimeUtil.DateServerToUTC(LocalDateTime.now());
|
||||
evaluationEntity.setStatus(ApplicationEvaluationStatusTypeEnum.OPEN.getValue());
|
||||
evaluationEntity.setClosingDate(null);
|
||||
evaluationEntity.setActiveDays(null);
|
||||
evaluationEntity.setEndDate(now.plusDays(evaluationDays));
|
||||
evaluationEntity.setStartDate(now);
|
||||
evaluationEntity.setRemainingDays(evaluationDays);
|
||||
evaluationEntity.setSuspendedDays(0L);
|
||||
evaluationEntity.setStopDateTime(null);
|
||||
}
|
||||
|
||||
private void saveEntities(ApplicationEntity app, AssignedApplicationsEntity assignedApp, ApplicationEvaluationEntity eval) {
|
||||
applicationRepository.save(app);
|
||||
assignedApplicationsRepository.save(assignedApp);
|
||||
applicationEvaluationRepository.save(eval);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -143,6 +143,9 @@ public class ApplicationEvaluationDao {
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Autowired
|
||||
private EmailDao emailDao;
|
||||
|
||||
|
||||
private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) {
|
||||
|
||||
@@ -311,7 +314,6 @@ public class ApplicationEvaluationDao {
|
||||
response.setUpdatedDate(entity.getUpdatedDate());
|
||||
response.setNumberOfCheck(entity.getAssignedApplicationsEntity().getApplication().getCall().getNumberOfCheck());
|
||||
response.setAppointmentTemplateId(entity.getAssignedApplicationsEntity().getApplication().getCall().getAppointmentTemplateId());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1090,7 +1092,7 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
validator.validatePreInstructor(request, assignedApplications.getUserId());
|
||||
}
|
||||
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(HttpServletRequest request, UserEntity user, Long applicationID, Long assignedApplicationID) {
|
||||
public ApplicationEvaluationResponseBean getApplicationEvaluationByApplicationId(HttpServletRequest request, UserEntity user, Long applicationID, Long assignedApplicationID) {
|
||||
Long applicationId;
|
||||
Long assignedApplicationId;
|
||||
validatePreinstructor(request, applicationID, assignedApplicationID);
|
||||
@@ -1124,10 +1126,17 @@ public class ApplicationEvaluationDao {
|
||||
} else {
|
||||
entityOptional = applicationEvaluationRepository.findFirstByIsDeletedFalseOrderByCreatedDateDesc();
|
||||
}
|
||||
return entityOptional.map(this::convertToResponse)
|
||||
.orElseGet(() -> {
|
||||
return getEvaluationResponseByApplicationid(user, applicationId, assignedApplicationId);
|
||||
});
|
||||
|
||||
if (entityOptional.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
ApplicationEvaluationEntity entity = entityOptional.get();
|
||||
ApplicationEvaluationResponse response = convertToResponse(entity);
|
||||
ApplicationEvaluationResponseBean targetResponse = Utils.convertSourceObjectToDestinationObject(response, ApplicationEvaluationResponseBean.class);
|
||||
if (targetResponse != null && entity.getEmailSendResponse() != null) {
|
||||
targetResponse.setEmailSendResponse(entity.getEmailSendResponse());
|
||||
}
|
||||
return targetResponse;
|
||||
}
|
||||
private List<EvaluationDocumentRequest> prepareEvaluationDocumentBeanList(ApplicationEvaluationEntity entity) {
|
||||
List<EvaluationDocumentRequest> docRequest = new ArrayList<>();
|
||||
@@ -1876,7 +1885,7 @@ public class ApplicationEvaluationDao {
|
||||
assignedApplicationsEntity.getId());
|
||||
ApplicationEvaluationEntity entity;
|
||||
|
||||
|
||||
EmailSendResponse emailSendResponse = new EmailSendResponse();
|
||||
if (existingEntityOptional.isPresent()) {
|
||||
ApplicationEvaluationEntity existingEntity = existingEntityOptional.get();
|
||||
// UserEntity userEntity = userService.validateUser(application.getUserId());
|
||||
@@ -1888,6 +1897,8 @@ public class ApplicationEvaluationDao {
|
||||
application.setStatus(newStatus.getValue());
|
||||
log.info("Status updated to ADMISSIBLE for applicationId: " + application.getId());
|
||||
emailNotificationDao.sendAdmissibilityNotificationEmailForAdmissibleApplication(application);
|
||||
emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
saveEmailSendResponseToEvaluation(emailSendResponse,existingEntity);
|
||||
}
|
||||
|
||||
if(newStatus.equals(ApplicationStatusForEvaluation.TECHNICAL_EVALUATION) && Boolean.TRUE.equals(application.getStatus().equals(ApplicationStatusTypeEnum.ADMISSIBLE.getValue()))){
|
||||
@@ -1944,17 +1955,29 @@ public class ApplicationEvaluationDao {
|
||||
application.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
application = applicationRepository.save(application);
|
||||
emailNotificationDao.sendInadmissibilityEmailForRejectedApplication(application,existingEntity);
|
||||
emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
saveEmailSendResponseToEvaluation(emailSendResponse,existingEntity);
|
||||
}
|
||||
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_RESULT);
|
||||
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.EVALUATION_RESULT);
|
||||
notificationDao.sendNotificationToInstructor(placeHolders,existingEntity,NotificationTypeEnum.EVALUATION_RESULT);
|
||||
|
||||
return convertToResponse(entity);
|
||||
ApplicationEvaluationResponse response = convertToResponse(entity);
|
||||
response.setEmailSendResponse(emailSendResponse);
|
||||
return response;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void saveEmailSendResponseToEvaluation(EmailSendResponse newResponse, ApplicationEvaluationEntity evaluationEntity) {
|
||||
List<EmailSendResponse> mergedResponses = Utils.mergeEmailSendResponses(
|
||||
evaluationEntity.getEmailSendResponse(), newResponse
|
||||
);
|
||||
evaluationEntity.setEmailSendResponse(mergedResponses);
|
||||
applicationEvaluationRepository.save(evaluationEntity);
|
||||
}
|
||||
|
||||
public ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId) {
|
||||
return applicationEvaluationRepository
|
||||
.findByApplicationIdAndIsDeletedFalse(applicationId)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3Client;
|
||||
import com.amazonaws.services.s3.model.GetObjectRequest;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -13,12 +12,14 @@ import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.config.jwt.TokenProvider;
|
||||
import net.gepafin.tendermanagement.constants.AppointmentApiConstant;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationAmendmentRequestEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||
import net.gepafin.tendermanagement.entities.HubEntity;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentSourceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.AppointmentCreationRequest;
|
||||
@@ -63,7 +64,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -145,6 +145,15 @@ public class AppointmentDao {
|
||||
@Autowired
|
||||
private AmazonS3Service amazonS3Service;
|
||||
|
||||
@Autowired
|
||||
private ApplicationDao applicationDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationAmendmentRequestDao applicationAmendmentRequestDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationDao applicationEvaluationDao;
|
||||
|
||||
private final Map<Long, ExecutorService> executorMap = new ConcurrentHashMap<>();
|
||||
|
||||
private final ConcurrentHashMap<Long, ExecutorService> threadForDocumentMap = new ConcurrentHashMap<>();
|
||||
@@ -175,9 +184,182 @@ public class AppointmentDao {
|
||||
return ndgResponse;
|
||||
}
|
||||
|
||||
private HubEntity loginToOdessa(HubEntity hub, ApplicationEntity application) {
|
||||
// private HubEntity loginToOdessa(HubEntity hub, ApplicationEntity application) {
|
||||
//
|
||||
// int maxRetries = 3;
|
||||
// int attempt = 0;
|
||||
// boolean success = false;
|
||||
// while (attempt < maxRetries && !success) {
|
||||
// attempt++;
|
||||
// try {
|
||||
// //code to generate token with payload having "iat" epoch timestamp and secret key with no expiry and send in below method call
|
||||
// String authJwtToken = Utils.generateAuthTokenForLoginToOdessa();
|
||||
// log.info("Got the auth for login to odessa {}", authJwtToken);
|
||||
// hub.setAuthToken(authJwtToken);
|
||||
// hubRepository.save(hub);
|
||||
// Map<String, Object> body = Collections.emptyMap();
|
||||
// ResponseEntity<Object> responseLogin = appointmentApiService.loginWithOdessa(authJwtToken, source, context, user, password, body);
|
||||
// if (responseLogin.getStatusCode() == HttpStatus.OK) {
|
||||
// log.info("Login successful to odessa. Parsing response.");
|
||||
// String loginResponseJson = Utils.convertObjectToJson(responseLogin.getBody());
|
||||
// AppointmentLoginResponse parsedResponse = parseLoginResponse(loginResponseJson);
|
||||
//
|
||||
// // Validate and save token
|
||||
// if (parsedResponse.getTokenId() != null) {
|
||||
// hub.setAppointmentAuthTokenId(parsedResponse.getTokenId());
|
||||
// hub.setAreaCode(parsedResponse.getAreaCode());
|
||||
// hubRepository.save(hub);
|
||||
// log.info("Saved new authToken and areaCode for Hub.");
|
||||
// success = true;
|
||||
// return hub;
|
||||
// } else {
|
||||
// throw new RuntimeException("Login response is missing a valid tokenId for login to odessa system, please try again.");
|
||||
// }
|
||||
// }
|
||||
// throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ERROR_IN_GENERATING_NDG_TRY_AGAIN));
|
||||
// } catch (FeignException.Forbidden forbiddenException) {
|
||||
// log.error("Failed to login to odessa due to some error");
|
||||
//
|
||||
// // Extract raw response body
|
||||
// String responseBody = forbiddenException.contentUTF8(); // Extract raw JSON response
|
||||
//
|
||||
// // Parse JSON to check for "PasswordExpired"
|
||||
// try {
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// JsonNode rootNode = objectMapper.readTree(responseBody);
|
||||
// JsonNode errorsNode = rootNode.path("errors");
|
||||
//
|
||||
// if (errorsNode.isArray()) {
|
||||
// for (JsonNode error : errorsNode) {
|
||||
// // Check the main errorCode
|
||||
// if (GepafinConstant.PASSWORD_EXPIRED.equals(error.path("errorCode").asText())) {
|
||||
// application.setNdgStatus(GepafinConstant.NDG_FAILED);
|
||||
// applicationRepository.save(application);
|
||||
// throw new CustomValidationException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PASSWORD_EXPIRED_LOGIN_TO_ODESSA));
|
||||
// }
|
||||
//
|
||||
// // Check inside "subErrors"
|
||||
// JsonNode subErrorsNode = error.path("subErrors");
|
||||
// if (subErrorsNode.isArray()) {
|
||||
// for (JsonNode subError : subErrorsNode) {
|
||||
// if (GepafinConstant.PASSWORD_EXPIRED.equals(subError.path("errorCode").asText())) {
|
||||
// application.setNdgStatus(GepafinConstant.NDG_FAILED);
|
||||
// applicationRepository.save(application);
|
||||
// throw new CustomValidationException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PASSWORD_EXPIRED_LOGIN_TO_ODESSA));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// log.error("Error parsing JSON response: {}", e.getMessage());
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error("Failed to authenticate user on Odessa : {}", e.getMessage(), e);
|
||||
// throw new RuntimeException("Authentication failed on Odessa. try again", e);
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private HubEntity authenticateAndSaveToken(HubEntity hub) {
|
||||
//
|
||||
// int maxRetries = 3;
|
||||
// int attempt = 0;
|
||||
// boolean success = false;
|
||||
// while (attempt < maxRetries && !success) {
|
||||
// attempt++;
|
||||
// try {
|
||||
// //code to generate token with payload having "iat" epoch timestamp and secret key with no expiry and send in below method call
|
||||
// String authJwtToken = Utils.generateAuthTokenForLoginToOdessa();
|
||||
// log.info("Got the auth for login to odessa {}", authJwtToken);
|
||||
// hub.setAuthToken(authJwtToken);
|
||||
// hubRepository.save(hub);
|
||||
// // Prepare the request body (adjust if necessary for login API)
|
||||
// Map<String, Object> body = Collections.emptyMap();
|
||||
// // Perform login API call
|
||||
// ResponseEntity<Object> responseLogin = appointmentApiService.loginWithOdessa(authJwtToken, source, context, user, password, body);
|
||||
//
|
||||
// // Handle successful login
|
||||
// if (responseLogin.getStatusCode() == HttpStatus.OK) {
|
||||
// log.info("Login successful to odessa. Parsing response.");
|
||||
// String loginResponseJson = Utils.convertObjectToJson(responseLogin.getBody());
|
||||
// AppointmentLoginResponse parsedResponse = parseLoginResponse(loginResponseJson);
|
||||
//
|
||||
// // Validate and save token
|
||||
// if (parsedResponse.getTokenId() != null) {
|
||||
// hub.setAppointmentAuthTokenId(parsedResponse.getTokenId());
|
||||
// hub.setAreaCode(parsedResponse.getAreaCode());
|
||||
// hubRepository.save(hub);
|
||||
//
|
||||
// log.info("Saved new authToken and areaCode for Hub.");
|
||||
// success = true;
|
||||
// return hub;
|
||||
// } else {
|
||||
// throw new RuntimeException("Login response is missing a valid tokenId for login to odessa system, please try again.");
|
||||
// }
|
||||
// }
|
||||
// // Handle non-OK response
|
||||
// throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ERROR_IN_GENERATING_NDG_TRY_AGAIN));
|
||||
// } catch (FeignException.Forbidden forbiddenException) {
|
||||
// log.error("Failed to login to odessa due to some error occurred.");
|
||||
//
|
||||
// // Extract raw response body
|
||||
// String responseBody = forbiddenException.contentUTF8(); // Extract raw JSON response
|
||||
//
|
||||
// // Parse JSON to check for "PasswordExpired"
|
||||
// try {
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
// JsonNode rootNode = objectMapper.readTree(responseBody);
|
||||
// JsonNode errorsNode = rootNode.path("errors");
|
||||
//
|
||||
// if (errorsNode.isArray()) {
|
||||
// for (JsonNode error : errorsNode) {
|
||||
// // Check the main errorCode
|
||||
// if (GepafinConstant.PASSWORD_EXPIRED.equals(error.path("errorCode").asText())) {
|
||||
// throw new CustomValidationException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PASSWORD_EXPIRED_LOGIN_TO_ODESSA));
|
||||
// }
|
||||
//
|
||||
// // Check inside "subErrors"
|
||||
// JsonNode subErrorsNode = error.path("subErrors");
|
||||
// if (subErrorsNode.isArray()) {
|
||||
// for (JsonNode subError : subErrorsNode) {
|
||||
// if (GepafinConstant.PASSWORD_EXPIRED.equals(subError.path("errorCode").asText())) {
|
||||
// throw new CustomValidationException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PASSWORD_EXPIRED_LOGIN_TO_ODESSA));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// log.error("Error parsing JSON response: {}", e.getMessage());
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error("Failed to authenticate user on Odessa : {}", e.getMessage(), e);
|
||||
// throw new RuntimeException("Authentication failed on Odessa. try again", e);
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
private void loginToOdessa(HubEntity hub, ApplicationEntity application) {
|
||||
|
||||
performOdessaLogin(hub, application);
|
||||
}
|
||||
|
||||
private HubEntity authenticateAndSaveToken(HubEntity hub, ApplicationEntity application) {
|
||||
|
||||
return performOdessaLogin(hub, application);
|
||||
}
|
||||
|
||||
private HubEntity performOdessaLogin(HubEntity hub, ApplicationEntity application) {
|
||||
|
||||
int maxRetries = 3;
|
||||
int attempt = 0;
|
||||
while (attempt < maxRetries) {
|
||||
attempt++;
|
||||
try {
|
||||
//code to generate token with payload having "iat" epoch timestamp and secret key with no expiry and send in below method call
|
||||
String authJwtToken = Utils.generateAuthTokenForLoginToOdessa();
|
||||
log.info("Got the auth for login to odessa {}", authJwtToken);
|
||||
hub.setAuthToken(authJwtToken);
|
||||
@@ -189,7 +371,6 @@ public class AppointmentDao {
|
||||
String loginResponseJson = Utils.convertObjectToJson(responseLogin.getBody());
|
||||
AppointmentLoginResponse parsedResponse = parseLoginResponse(loginResponseJson);
|
||||
|
||||
// Validate and save token
|
||||
if (parsedResponse.getTokenId() != null) {
|
||||
hub.setAppointmentAuthTokenId(parsedResponse.getTokenId());
|
||||
hub.setAreaCode(parsedResponse.getAreaCode());
|
||||
@@ -201,53 +382,52 @@ public class AppointmentDao {
|
||||
}
|
||||
}
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ERROR_IN_GENERATING_NDG_TRY_AGAIN));
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
log.error("Failed to login to odessa due to forbidden error.");
|
||||
|
||||
CheckPasswordExpiredOrErrorInResponse(application, forbiddenException);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to authenticate user on Odessa (Attempt {}): {}", attempt, e.getMessage(), e);
|
||||
}
|
||||
catch (FeignException.Forbidden forbiddenException) {
|
||||
logForbiddenError();
|
||||
}
|
||||
throw new RuntimeException("Max retries exceeded. Failed to login to Odessa.");
|
||||
}
|
||||
private void CheckPasswordExpiredOrErrorInResponse(ApplicationEntity application, FeignException.Forbidden forbiddenException) {
|
||||
|
||||
// Extract raw response body
|
||||
String responseBody = forbiddenException.contentUTF8(); // Extract raw JSON response
|
||||
String responseBody = forbiddenException.contentUTF8();
|
||||
|
||||
// Parse JSON to check for "PasswordExpired"
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode rootNode = objectMapper.readTree(responseBody);
|
||||
JsonNode errorsNode = rootNode.path("errors");
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode rootNode = objectMapper.readTree(responseBody);
|
||||
JsonNode errorsNode = rootNode.path("errors");
|
||||
|
||||
if (errorsNode.isArray()) {
|
||||
for (JsonNode error : errorsNode) {
|
||||
// Check the main errorCode
|
||||
if (GepafinConstant.PASSWORD_EXPIRED.equals(error.path("errorCode").asText())) {
|
||||
application.setNdgStatus(GepafinConstant.NDG_FAILED);
|
||||
applicationRepository.save(application);
|
||||
throw new CustomValidationException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PASSWORD_EXPIRED_LOGIN_TO_ODESSA));
|
||||
}
|
||||
if (errorsNode.isArray()) {
|
||||
for (JsonNode error : errorsNode) {
|
||||
if (GepafinConstant.PASSWORD_EXPIRED.equals(error.path("errorCode").asText())) {
|
||||
if (application != null) {
|
||||
application.setNdgStatus(GepafinConstant.NDG_FAILED);
|
||||
applicationRepository.save(application);
|
||||
}
|
||||
throw new CustomValidationException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PASSWORD_EXPIRED_LOGIN_TO_ODESSA));
|
||||
}
|
||||
|
||||
// Check inside "subErrors"
|
||||
JsonNode subErrorsNode = error.path("subErrors");
|
||||
if (subErrorsNode.isArray()) {
|
||||
for (JsonNode subError : subErrorsNode) {
|
||||
if (GepafinConstant.PASSWORD_EXPIRED.equals(subError.path("errorCode").asText())) {
|
||||
application.setNdgStatus(GepafinConstant.NDG_FAILED);
|
||||
applicationRepository.save(application);
|
||||
throw new CustomValidationException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PASSWORD_EXPIRED_LOGIN_TO_ODESSA));
|
||||
}
|
||||
JsonNode subErrorsNode = error.path("subErrors");
|
||||
if (subErrorsNode.isArray()) {
|
||||
for (JsonNode subError : subErrorsNode) {
|
||||
if (GepafinConstant.PASSWORD_EXPIRED.equals(subError.path("errorCode").asText())) {
|
||||
if (application != null) {
|
||||
application.setNdgStatus(GepafinConstant.NDG_FAILED);
|
||||
applicationRepository.save(application);
|
||||
}
|
||||
throw new CustomValidationException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PASSWORD_EXPIRED_LOGIN_TO_ODESSA));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Error parsing JSON response: {}", e.getMessage());
|
||||
}
|
||||
|
||||
// Regenerate the token and retry
|
||||
loginToOdessa(hub, application);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("Failed to authenticate user on Odessa : {}", e.getMessage(), e);
|
||||
throw new RuntimeException("Authentication failed on Odessa. try again", e);
|
||||
}
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
log.error("Error parsing JSON response: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void startAsyncNdgProcessing(Long applicationId) {
|
||||
@@ -296,7 +476,7 @@ public class AppointmentDao {
|
||||
try {
|
||||
// Authenticate and fetch token if required
|
||||
if (hub.getAppointmentAuthTokenId() == null || hub.getAreaCode() == null) {
|
||||
authenticateAndSaveToken(hub);
|
||||
authenticateAndSaveToken(hub, application);
|
||||
}
|
||||
|
||||
String authorizationToken = getBearerToken(hub);
|
||||
@@ -342,10 +522,11 @@ public class AppointmentDao {
|
||||
application.setStatus(ApplicationStatusTypeEnum.NDG.getValue());
|
||||
applicationRepository.save(application);
|
||||
companyRepository.save(company);
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(application.getApplicationEvaluationId());
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(
|
||||
application.getApplicationEvaluationId());
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.NDG_GENERATION);
|
||||
notificationDao.sendNotificationToInstructor(placeHolders, applicationEvaluationEntity, NotificationTypeEnum.NDG_GENERATION);
|
||||
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.NDG_GENERATION);
|
||||
notificationDao.sendNotificationToSuperUser(application, placeHolders, NotificationTypeEnum.NDG_GENERATION);
|
||||
log.info("NDG saved successfully for applicationId: {}", application.getId());
|
||||
break;
|
||||
}
|
||||
@@ -395,7 +576,7 @@ public class AppointmentDao {
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(application.getApplicationEvaluationId());
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.NDG_GENERATION);
|
||||
notificationDao.sendNotificationToInstructor(placeHolders, applicationEvaluationEntity, NotificationTypeEnum.NDG_GENERATION);
|
||||
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.NDG_GENERATION);
|
||||
notificationDao.sendNotificationToSuperUser(application, placeHolders, NotificationTypeEnum.NDG_GENERATION);
|
||||
log.info("NDG saved for applicationId: {}, {}", application.getId(), application.getNdg());
|
||||
}
|
||||
|
||||
@@ -413,7 +594,7 @@ public class AppointmentDao {
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
log.error("403 Forbidden received while getting visuraList for Ndg code. Regenerating token...");
|
||||
// Regenerate the token and retry
|
||||
String newAuthorizationToken = regenerateTokenAndSave(hub);
|
||||
String newAuthorizationToken = regenerateTokenAndSave(hub, application);
|
||||
return getVisuraList(idVisura, newAuthorizationToken, application, hub);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to fetch Ndg code: {}", e.getMessage(), e);
|
||||
@@ -421,82 +602,6 @@ public class AppointmentDao {
|
||||
}
|
||||
}
|
||||
|
||||
private HubEntity authenticateAndSaveToken(HubEntity hub) {
|
||||
|
||||
try {
|
||||
//code to generate token with payload having "iat" epoch timestamp and secret key with no expiry and send in below method call
|
||||
String authJwtToken = Utils.generateAuthTokenForLoginToOdessa();
|
||||
log.info("Got the auth for login to odessa {}", authJwtToken);
|
||||
hub.setAuthToken(authJwtToken);
|
||||
hubRepository.save(hub);
|
||||
// Prepare the request body (adjust if necessary for login API)
|
||||
Map<String, Object> body = Collections.emptyMap();
|
||||
// Perform login API call
|
||||
ResponseEntity<Object> responseLogin = appointmentApiService.loginWithOdessa(authJwtToken, source, context, user, password, body);
|
||||
|
||||
// Handle successful login
|
||||
if (responseLogin.getStatusCode() == HttpStatus.OK) {
|
||||
log.info("Login successful to odessa. Parsing response.");
|
||||
String loginResponseJson = Utils.convertObjectToJson(responseLogin.getBody());
|
||||
AppointmentLoginResponse parsedResponse = parseLoginResponse(loginResponseJson);
|
||||
|
||||
// Validate and save token
|
||||
if (parsedResponse.getTokenId() != null) {
|
||||
hub.setAppointmentAuthTokenId(parsedResponse.getTokenId());
|
||||
hub.setAreaCode(parsedResponse.getAreaCode());
|
||||
hubRepository.save(hub);
|
||||
|
||||
log.info("Saved new authToken and areaCode for Hub.");
|
||||
return hub;
|
||||
} else {
|
||||
throw new RuntimeException("Login response is missing a valid tokenId for login to odessa system, please try again.");
|
||||
}
|
||||
}
|
||||
// Handle non-OK response
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ERROR_IN_GENERATING_NDG_TRY_AGAIN));
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
logForbiddenError();
|
||||
|
||||
// Extract raw response body
|
||||
String responseBody = forbiddenException.contentUTF8(); // Extract raw JSON response
|
||||
|
||||
// Parse JSON to check for "PasswordExpired"
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode rootNode = objectMapper.readTree(responseBody);
|
||||
JsonNode errorsNode = rootNode.path("errors");
|
||||
|
||||
if (errorsNode.isArray()) {
|
||||
for (JsonNode error : errorsNode) {
|
||||
// Check the main errorCode
|
||||
if (GepafinConstant.PASSWORD_EXPIRED.equals(error.path("errorCode").asText())) {
|
||||
throw new CustomValidationException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PASSWORD_EXPIRED_LOGIN_TO_ODESSA));
|
||||
}
|
||||
|
||||
// Check inside "subErrors"
|
||||
JsonNode subErrorsNode = error.path("subErrors");
|
||||
if (subErrorsNode.isArray()) {
|
||||
for (JsonNode subError : subErrorsNode) {
|
||||
if (GepafinConstant.PASSWORD_EXPIRED.equals(subError.path("errorCode").asText())) {
|
||||
throw new CustomValidationException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PASSWORD_EXPIRED_LOGIN_TO_ODESSA));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("Error parsing JSON response: {}", e.getMessage());
|
||||
}
|
||||
|
||||
// Regenerate the token and retry
|
||||
regenerateTokenAndSave(hub);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to authenticate user on Odessa : {}", e.getMessage(), e);
|
||||
throw new RuntimeException("Authentication failed on Odessa. try again", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private AppointmentLoginResponse retrieveNdgByVatNumber(String vatNumber, String authorizationToken, HubEntity hub, ApplicationEntity application) {
|
||||
|
||||
try {
|
||||
@@ -510,7 +615,7 @@ public class AppointmentDao {
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
logForbiddenError();
|
||||
// Regenerate the token and retry
|
||||
String newAuthorizationToken = regenerateTokenAndSave(hub);
|
||||
String newAuthorizationToken = regenerateTokenAndSave(hub, application);
|
||||
return retrieveNdgByVatNumber(vatNumber, newAuthorizationToken, hub, application);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to retrieve NDG by VAT number: {}", e.getMessage(), e);
|
||||
@@ -518,9 +623,10 @@ public class AppointmentDao {
|
||||
}
|
||||
}
|
||||
|
||||
private String regenerateTokenAndSave(HubEntity hub) {
|
||||
hub = authenticateAndSaveToken(hub);
|
||||
return "Bearer " + hub.getAppointmentAuthTokenId();
|
||||
private String regenerateTokenAndSave(HubEntity hub, ApplicationEntity application) {
|
||||
|
||||
hub = authenticateAndSaveToken(hub, application);
|
||||
return "Bearer " + hub.getAppointmentAuthTokenId();
|
||||
}
|
||||
|
||||
private AppointmentLoginResponse createVisura(CompanyEntity company, String authorizationToken, HubEntity hub) {
|
||||
@@ -533,7 +639,7 @@ public class AppointmentDao {
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
logForbiddenError();
|
||||
// Regenerate the token and retry
|
||||
String newAuthorizationToken = regenerateTokenAndSave(hub);
|
||||
String newAuthorizationToken = regenerateTokenAndSave(hub, null);
|
||||
return createVisura(company, newAuthorizationToken, hub);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to create Visura for Ndg : {}", e.getMessage());
|
||||
@@ -703,9 +809,8 @@ public class AppointmentDao {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.NDG_NOT_FOUND_FOR_APPLICATION));
|
||||
}
|
||||
|
||||
hub = authenticateAndSaveToken(hub);
|
||||
// Generate authorization token and fetch template data
|
||||
String authorizationToken = getBearerToken(hub);
|
||||
String authorizationToken = regenerateTokenAndSave(hub, application);
|
||||
Long appointmentTemplateId = application.getCall().getAppointmentTemplateId();
|
||||
if (appointmentTemplateId == null) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPOINTMENT_CANNOT_BE_CREATED));
|
||||
@@ -749,7 +854,7 @@ public class AppointmentDao {
|
||||
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
log.error("403 Forbidden received while retrieving template. Regenerating token...");
|
||||
regenerateTokenAndSave(hub);
|
||||
regenerateTokenAndSave(hub, application);
|
||||
return createAppointment(applicationId, createAppointmentRequest);
|
||||
}
|
||||
}
|
||||
@@ -758,12 +863,31 @@ public class AppointmentDao {
|
||||
|
||||
if (appointmentResponse.getBody() != null) {
|
||||
log.info("Appointment API Response : {}", appointmentResponse.getBody());
|
||||
Map<String, Object> responseBody = (Map<String, Object>) appointmentResponse.getBody();
|
||||
if (responseBody.containsKey(GepafinConstant.DATA_STRING)) {
|
||||
Map<String, Object> data = (Map<String, Object>) responseBody.get(GepafinConstant.DATA_STRING);
|
||||
if (data != null && data.containsKey(GepafinConstant.ID_STRING)) {
|
||||
return data.get(GepafinConstant.ID_STRING).toString();
|
||||
try {
|
||||
Map<String, Object> responseBody = (Map<String, Object>) appointmentResponse.getBody();
|
||||
// 1. Try to get appointment ID from data.id
|
||||
if (responseBody.containsKey(GepafinConstant.DATA_STRING)) {
|
||||
Map<String, Object> data = (Map<String, Object>) responseBody.get(GepafinConstant.DATA_STRING);
|
||||
if (data != null && data.containsKey(GepafinConstant.ID_STRING)) {
|
||||
return data.get(GepafinConstant.ID_STRING).toString();
|
||||
}
|
||||
}
|
||||
// 2. If ID not present, check errors[0].cause.errorDescription
|
||||
if (responseBody.containsKey(GepafinConstant.ERROR_STRING)) {
|
||||
List<Map<String, Object>> errors = (List<Map<String, Object>>) responseBody.get(GepafinConstant.ERROR_STRING);
|
||||
if (errors != null && !errors.isEmpty()) {
|
||||
Map<String, Object> firstError = errors.get(0);
|
||||
if (firstError.containsKey(GepafinConstant.CAUSE_STRING)) {
|
||||
Map<String, Object> cause = (Map<String, Object>) firstError.get(GepafinConstant.CAUSE_STRING);
|
||||
if (cause != null && cause.containsKey(GepafinConstant.ERROR_DESCRIPTION_STRING)) {
|
||||
String errorDescription = cause.get(GepafinConstant.ERROR_DESCRIPTION_STRING).toString();
|
||||
log.warn("Appointment creation failed: {}", errorDescription);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error while extracting appointment ID or parsing error message", e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -793,20 +917,20 @@ public class AppointmentDao {
|
||||
JsonNode prodottoNode = richiestaNode.path(AppointmentApiConstant.PRODOTTO);
|
||||
String prodottoCode = prodottoNode.path(AppointmentApiConstant.PRODOTTO_CODE).asText();
|
||||
|
||||
richiestaCliente.setCodProdotto(prodottoCode);
|
||||
richiestaCliente.setIdMotivazione(getIntValue(richiestaNode));
|
||||
richiestaCliente.setCodAbi(getTextValue(richiestaNode, AppointmentApiConstant.COD_ABI));
|
||||
richiestaCliente.setCodCab(getTextValue(richiestaNode, AppointmentApiConstant.COD_CAB));
|
||||
richiestaCliente.setIdNota(getTextValue(richiestaNode, AppointmentApiConstant.ID_NOTA));
|
||||
richiestaCliente.setImportoAgevolato(getTextValue(richiestaNode, AppointmentApiConstant.IMPORTO_AGEVOLATO));
|
||||
richiestaCliente.setImportoMedioLungoTermine(getTextValue(richiestaNode, AppointmentApiConstant.IMPORTO_MEDIOLUNGO_TERMINE));
|
||||
richiestaCliente.setCodTipoProdotto(getTextValue(richiestaNode, AppointmentApiConstant.COD_TIPO_PRODOTTO));
|
||||
richiestaCliente.setCodCategoriaProdotto(getTextValue(richiestaNode, AppointmentApiConstant.COD_CATEGORIA_PRODOTTO));
|
||||
richiestaCliente.setCodFormaTecnica(getTextValue(richiestaNode, AppointmentApiConstant.COD_FORMATECNICA));
|
||||
richiestaCliente.setCodOperazione(getTextValue(richiestaNode, AppointmentApiConstant.COD_OPERAZIONE));
|
||||
richiestaCliente.setCodProdotto(prodottoCode);
|
||||
richiestaCliente.setIdMotivazione(getIntValue(richiestaNode));
|
||||
richiestaCliente.setCodAbi(getTextValue(richiestaNode, AppointmentApiConstant.COD_ABI));
|
||||
richiestaCliente.setCodCab(getTextValue(richiestaNode, AppointmentApiConstant.COD_CAB));
|
||||
richiestaCliente.setIdNota(getTextValue(richiestaNode, AppointmentApiConstant.ID_NOTA));
|
||||
richiestaCliente.setImportoAgevolato(getTextValue(richiestaNode, AppointmentApiConstant.IMPORTO_AGEVOLATO));
|
||||
richiestaCliente.setImportoMedioLungoTermine(getTextValue(richiestaNode, AppointmentApiConstant.IMPORTO_MEDIOLUNGO_TERMINE));
|
||||
richiestaCliente.setCodTipoProdotto(getTextValue(richiestaNode, AppointmentApiConstant.COD_TIPO_PRODOTTO));
|
||||
richiestaCliente.setCodCategoriaProdotto(getTextValue(richiestaNode, AppointmentApiConstant.COD_CATEGORIA_PRODOTTO));
|
||||
richiestaCliente.setCodFormaTecnica(getTextValue(richiestaNode, AppointmentApiConstant.COD_FORMATECNICA));
|
||||
richiestaCliente.setCodOperazione(getTextValue(richiestaNode, AppointmentApiConstant.COD_OPERAZIONE));
|
||||
|
||||
richiestaClienteList.add(richiestaCliente);
|
||||
}
|
||||
richiestaClienteList.add(richiestaCliente);
|
||||
}
|
||||
|
||||
input.setRichiestaCliente(richiestaClienteList);
|
||||
appointmentCreationRequest.setInput(input);
|
||||
@@ -867,13 +991,40 @@ public class AppointmentDao {
|
||||
// Check if the document is already being processed
|
||||
DocumentEntity systemDoc = documentDao.validateDocument(documentId);
|
||||
|
||||
ApplicationEntity application = null;
|
||||
|
||||
if (systemDoc != null) {
|
||||
DocumentSourceTypeEnum sourceType = DocumentSourceTypeEnum.valueOf(systemDoc.getSource());
|
||||
|
||||
switch (sourceType) {
|
||||
case APPLICATION:
|
||||
application = applicationDao.validateApplication(systemDoc.getSourceId());
|
||||
break;
|
||||
case AMENDMENT:
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentEntity = applicationAmendmentRequestDao.validateApplicationAmendmentRequest(systemDoc.getSourceId());
|
||||
application = applicationDao.validateApplication(applicationAmendmentEntity.getApplicationId());
|
||||
break;
|
||||
case EVALUATION:
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationDao.validateApplicationEvaluation(systemDoc.getSourceId());
|
||||
application = applicationDao.validateApplication(applicationEvaluationEntity.getApplicationId());
|
||||
break;
|
||||
|
||||
case CALL:
|
||||
break;
|
||||
|
||||
default:
|
||||
log.warn("Unhandled document source type: {}", sourceType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Claims claims = tokenProvider.getClaimsFromToken(tokenProvider.extractTokenFromRequest(request));
|
||||
Long hubId = Utils.extractHubIdFromPayload(claims.getSubject());
|
||||
|
||||
// Authenticate the hub before proceeding
|
||||
HubEntity hub = hubRepository.findByHubId(hubId);
|
||||
authenticateAndSaveToken(hub);
|
||||
if (systemDoc.getDocumentAttachmentId() != null) {
|
||||
authenticateAndSaveToken(hub, application);
|
||||
if (systemDoc != null && systemDoc.getDocumentAttachmentId() != null) {
|
||||
// If the documentAttachmentId is already set, return the response
|
||||
log.info("Document already uploaded with documentAttachmentId: {}", systemDoc.getDocumentAttachmentId());
|
||||
DocumentUploadResponse response = new DocumentUploadResponse();
|
||||
@@ -893,11 +1044,12 @@ public class AppointmentDao {
|
||||
});
|
||||
threadForDocumentMap.put(documentId, executor);
|
||||
|
||||
ApplicationEntity finalApplication = application;
|
||||
executor.submit(() -> {
|
||||
threadLocalHubId.set(hubId);
|
||||
try {
|
||||
log.info("Starting async document upload for documentId: {}", documentId);
|
||||
uploadDocumentToExternalSystemSync(documentId, docToExternalSystemRequest);
|
||||
uploadDocumentToExternalSystemSync(documentId, docToExternalSystemRequest, finalApplication);
|
||||
} catch (Exception e) {
|
||||
log.error("Error in async document upload for documentId: {}", documentId, e);
|
||||
} finally {
|
||||
@@ -913,7 +1065,7 @@ public class AppointmentDao {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void uploadDocumentToExternalSystemSync(Long documentId, UploadDocToExternalSystemRequest docToExternalSystemRequest) {
|
||||
private void uploadDocumentToExternalSystemSync(Long documentId, UploadDocToExternalSystemRequest docToExternalSystemRequest, ApplicationEntity application) {
|
||||
// Synchronous upload logic
|
||||
DocumentEntity systemDoc = documentDao.validateDocument(documentId);
|
||||
|
||||
@@ -954,8 +1106,8 @@ public class AppointmentDao {
|
||||
log.info("Document uploaded successfully to external system: {}", parsedResponse);
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
log.error("403 Forbidden received while uploading document. Regenerating token...");
|
||||
regenerateTokenAndSave(hub);
|
||||
uploadDocumentToExternalSystemSync(documentId, docToExternalSystemRequest);
|
||||
regenerateTokenAndSave(hub, application);
|
||||
uploadDocumentToExternalSystemSync(documentId, docToExternalSystemRequest, application);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception during document upload: {}", e.getMessage(), e);
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.EXTERNAL_DOCUMENT_UPLOAD_FAILURE_MSG));
|
||||
|
||||
@@ -315,7 +315,8 @@ public class AssignedApplicationsDao {
|
||||
if (pageNo == null || pageNo <= 0) {
|
||||
pageNo = GepafinConstant.DEFAULT_PAGE;
|
||||
}
|
||||
Specification<AssignedApplicationsView> spec = searchByPagination( assignedApplicationPageableRequestBean, user,userId);
|
||||
Long hubId=user.getHub().getId();
|
||||
Specification<AssignedApplicationsView> spec = searchByPagination( assignedApplicationPageableRequestBean,hubId,userId);
|
||||
Page<AssignedApplicationsView> entityPage = assignedApplicationsViewRepository.findAll(spec, PageRequest.of(pageNo - 1, pageLimit));
|
||||
// Prepare the response
|
||||
|
||||
@@ -333,10 +334,10 @@ public class AssignedApplicationsDao {
|
||||
return pageableResponseBean;
|
||||
}
|
||||
|
||||
public Specification<AssignedApplicationsView> searchByPagination(AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean, UserEntity userEntity,Long userId) {
|
||||
public Specification<AssignedApplicationsView> searchByPagination(AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean, Long hubId,Long userId) {
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
|
||||
List<Predicate> predicates = getPredicates(assignedApplicationPageableRequestBean, criteriaBuilder, root, userEntity,userId);
|
||||
List<Predicate> predicates = getPredicates(assignedApplicationPageableRequestBean, criteriaBuilder, root, hubId,userId);
|
||||
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||
|
||||
if (assignedApplicationPageableRequestBean.getGlobalFilters() != null
|
||||
@@ -377,7 +378,7 @@ public class AssignedApplicationsDao {
|
||||
|
||||
|
||||
private List<Predicate> getPredicates(AssignedApplicationPageableRequestBean assignedApplicationPageableRequestBean,
|
||||
CriteriaBuilder criteriaBuilder, Root<AssignedApplicationsView> root, UserEntity userEntity,Long userId) {
|
||||
CriteriaBuilder criteriaBuilder, Root<AssignedApplicationsView> root,Long hubId,Long userId) {
|
||||
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
@@ -448,6 +449,8 @@ public class AssignedApplicationsDao {
|
||||
}
|
||||
predicates.add(criteriaBuilder.isFalse(root.get(GepafinConstant.IS_DELETED)));
|
||||
|
||||
predicates.add(criteriaBuilder.equal(root.get(GepafinConstant.HUB_ID), hubId));
|
||||
|
||||
Utils.applyFiltersByPagination(root, criteriaBuilder, predicates, filters);
|
||||
|
||||
return predicates;
|
||||
@@ -470,6 +473,7 @@ public class AssignedApplicationsDao {
|
||||
response.setCompanyName(view.getCompanyName());
|
||||
response.setCreatedDate(view.getCreatedDate());
|
||||
response.setUpdatedDate(view.getUpdatedDate());
|
||||
response.setEmailSendResponse(view.getEmailSendResponse());
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -986,7 +986,7 @@ public class CallDao {
|
||||
return callEntity;
|
||||
}
|
||||
|
||||
public PageableResponseBean<List<CallDetailsResponseBean>> getAllCallsByPagination(HttpServletRequest request,UserEntity user,Long companyId , Boolean onlyPreferredCall, CallPageableRequestBean callPageableRequestBean) {
|
||||
public PageableResponseBean<List<CallDetailsResponseBean>> getAllCallsByPagination(HttpServletRequest request,UserEntity user,Long companyId , Boolean onlyPreferredCall, Boolean onlyConfidiCall, CallPageableRequestBean callPageableRequestBean) {
|
||||
Integer pageNo = null;
|
||||
Integer pageLimit = null;
|
||||
if (callPageableRequestBean.getGlobalFilters() != null) {
|
||||
@@ -1006,7 +1006,7 @@ public class CallDao {
|
||||
);
|
||||
}
|
||||
expirePublishedCalls(request);
|
||||
Specification<CallEntity> spec = search(request,user, callPageableRequestBean);
|
||||
Specification<CallEntity> spec = search(request,user, callPageableRequestBean,onlyConfidiCall);
|
||||
Page<CallEntity> entityPage;
|
||||
if (Boolean.TRUE.equals(onlyPreferredCall)) {
|
||||
validator.validateUserWithCompany(request, companyId);
|
||||
@@ -1056,10 +1056,10 @@ public class CallDao {
|
||||
return pageableResponseBean;
|
||||
}
|
||||
|
||||
public Specification<CallEntity> search(HttpServletRequest request,UserEntity userEntity, CallPageableRequestBean callPageableRequestBean) {
|
||||
public Specification<CallEntity> search(HttpServletRequest request,UserEntity userEntity, CallPageableRequestBean callPageableRequestBean,Boolean onlyConfidiCall) {
|
||||
return (root, query, criteriaBuilder) -> {
|
||||
|
||||
List<Predicate> predicates = getPredicates(request,callPageableRequestBean, criteriaBuilder, root, userEntity);
|
||||
List<Predicate> predicates = getPredicates(request,callPageableRequestBean, criteriaBuilder, root, userEntity,onlyConfidiCall);
|
||||
SortBy sortBy = new SortBy(GepafinConstant.CREATED_DATE, true);
|
||||
|
||||
if (callPageableRequestBean.getGlobalFilters() != null
|
||||
@@ -1083,7 +1083,7 @@ public class CallDao {
|
||||
|
||||
|
||||
private List<Predicate> getPredicates(HttpServletRequest request,CallPageableRequestBean callPageableRequestBean,
|
||||
CriteriaBuilder criteriaBuilder, Root<CallEntity> root, UserEntity userEntity) {
|
||||
CriteriaBuilder criteriaBuilder, Root<CallEntity> root, UserEntity userEntity,Boolean onlyConfidiCall) {
|
||||
Integer year = null;
|
||||
String search = null;
|
||||
Map<String, FilterCriteria> filters = new HashMap<>();
|
||||
@@ -1137,7 +1137,7 @@ public class CallDao {
|
||||
predicates.add(root.get(GepafinConstant.STATUS).in(statusValues));
|
||||
}
|
||||
applyFilters(root, criteriaBuilder, predicates, filters);
|
||||
Boolean isConfidi = callPageableRequestBean.getConfidi();
|
||||
Boolean isConfidi =onlyConfidiCall;
|
||||
|
||||
if (validator.checkIsConfidi()) {
|
||||
|
||||
|
||||
210
src/main/java/net/gepafin/tendermanagement/dao/EmailDao.java
Normal file
210
src/main/java/net/gepafin/tendermanagement/dao/EmailDao.java
Normal file
@@ -0,0 +1,210 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.EmailServiceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.RecipientTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.StatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||
import net.gepafin.tendermanagement.model.response.EmailResendResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.CallService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@Log4j2
|
||||
public class EmailDao {
|
||||
|
||||
@Autowired
|
||||
EmailLogRepository emailLogRepository;
|
||||
|
||||
@Autowired
|
||||
EmailNotificationDao emailNotificationDao;
|
||||
|
||||
@Autowired
|
||||
private CallService callService;
|
||||
|
||||
@Autowired
|
||||
private EmailLogDao emailLogDao;
|
||||
|
||||
@Autowired
|
||||
private UserActionsRepository userActionsRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationAmendmentRequestRepository applicationAmendmentRequestRepository;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationRepository applicationEvaluationRepository;
|
||||
|
||||
public EmailResendResponseBean resendEmail(HttpServletRequest request , Long userActionId){
|
||||
UserActionEntity userActionEntity = userActionsRepository.findUserActionByIdAndIsDeletedFalse(userActionId);
|
||||
if(userActionEntity == null){
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.USER_ACTION_ID_NOT_FOUND));
|
||||
}
|
||||
List<EmailLogEntity> emailLogs = emailLogRepository.findByUserActionIdAndEmailServiceTypeAndSendStatus(userActionId,EmailServiceTypeEnum.PEC_SERVICE.getValue(),StatusTypeEnum.FAILED.getValue());
|
||||
|
||||
if (emailLogs.isEmpty()) {
|
||||
log.info("No emails found for given userActionId: {}",userActionId);
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.NO_EMAIL_LOG_FOUND));
|
||||
}
|
||||
EmailResendResponseBean emailResendResponseBean = new EmailResendResponseBean();
|
||||
for (EmailLogEntity log : emailLogs){
|
||||
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(EmailScenarioTypeEnum.valueOf(log.getEmailType()),
|
||||
RecipientTypeEnum.valueOf(log.getRecipientType()),
|
||||
log.getRecipientId(),
|
||||
log.getRecipientEmails(),
|
||||
log.getUserId(),
|
||||
log.getApplicationId(),
|
||||
log.getAmendmentId(),
|
||||
log.getCallId()
|
||||
);
|
||||
|
||||
List<String> recipients = Utils.commaSeparatedStringToList(log.getRecipientEmails());
|
||||
CallEntity call = callService.validateCall(log.getCallId());
|
||||
emailNotificationDao.sendMail(
|
||||
call.getHub().getId(),
|
||||
log.getEmailSubject(),
|
||||
log.getEmailBody(),
|
||||
recipients,
|
||||
emailLogRequest
|
||||
);
|
||||
}
|
||||
EmailSendResponse emailSendResponse = buildEmailSendResponseFromRequest(request);
|
||||
emailResendResponseBean.setEmailSendResponse(emailSendResponse);
|
||||
|
||||
if (Boolean.TRUE.equals(emailSendResponse.getIsEmailSend())){
|
||||
updateEmailSendStatusIfSuccessful(emailSendResponse);
|
||||
}
|
||||
return emailResendResponseBean;
|
||||
}
|
||||
|
||||
private void updateEmailSendStatusIfSuccessful(EmailSendResponse emailSendResponse){
|
||||
Long actionId = emailSendResponse.getUserActionId();
|
||||
|
||||
EmailLogEntity emailLog = emailLogRepository.findTopByUserActionIdAndEmailServiceTypeAndSendStatusOrderByIdDesc(
|
||||
actionId,
|
||||
EmailServiceTypeEnum.PEC_SERVICE.getValue(),
|
||||
StatusTypeEnum.SUCCESS.getValue()
|
||||
);
|
||||
if (emailLog != null) {
|
||||
switch (emailSendResponse.getEmailScenario()) {
|
||||
case APPLICATION_AMENDMENT_REQUESTED:
|
||||
case APPLICATION_AMENDMENT_REMINDER:
|
||||
updateApplicationAmendmentStatus(emailLog, emailSendResponse.getEmailScenario().getValue());
|
||||
break;
|
||||
|
||||
case USER_CREATION:
|
||||
case PASSWORD_RESET_REQUEST:
|
||||
updateUserEmailStatus(emailLog, emailSendResponse.getEmailScenario().getValue());
|
||||
break;
|
||||
|
||||
case APPLICATION_ADMISSIBLE:
|
||||
case APPLICATION_REJECTED:
|
||||
updateApplicationEvaluationStatus(emailLog, emailSendResponse.getEmailScenario().getValue());
|
||||
break;
|
||||
|
||||
default:
|
||||
log.warn("Unhandled email scenario: {}", emailSendResponse.getEmailScenario());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateApplicationAmendmentStatus(EmailLogEntity log, String scenario) {
|
||||
if (log.getAmendmentId() != null) {
|
||||
applicationAmendmentRequestRepository.findById(log.getAmendmentId()).ifPresent(amendment -> {
|
||||
if (updateEmailSendResponse(amendment.getEmailSendResponse(), scenario)) {
|
||||
applicationAmendmentRequestRepository.save(amendment);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void updateApplicationEvaluationStatus(EmailLogEntity log, String scenario) {
|
||||
if (log.getApplicationId() != null) {
|
||||
ApplicationEvaluationEntity evaluation = applicationEvaluationRepository.findByApplicationId(log.getApplicationId());
|
||||
if (evaluation != null && updateEmailSendResponse(evaluation.getEmailSendResponse(), scenario)) {
|
||||
applicationEvaluationRepository.save(evaluation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUserEmailStatus(EmailLogEntity log, String scenario) {
|
||||
if (log.getUserId() != null) {
|
||||
userRepository.findById(log.getUserId()).ifPresent(user -> {
|
||||
if (updateEmailSendResponse(user.getEmailSendResponse(), scenario)) {
|
||||
userRepository.save(user);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private boolean updateEmailSendResponse(List<EmailSendResponse> responses, String scenario) {
|
||||
if (responses == null || responses.isEmpty()) return false;
|
||||
|
||||
for (EmailSendResponse response : responses) {
|
||||
if (scenario.equals(response.getEmailScenario().getValue())) {
|
||||
response.setIsEmailSend(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public EmailSendResponse buildEmailSendResponseFromRequest(HttpServletRequest request) {
|
||||
Long userActionId = (Long) request.getAttribute(GepafinConstant.USER_ACTION_ID);
|
||||
List<EmailLogEntity> emailLogs = emailLogRepository.findByUserActionIdAndEmailServiceType(userActionId,EmailServiceTypeEnum.PEC_SERVICE.getValue());
|
||||
|
||||
boolean allSuccess = true;
|
||||
String emailScenario = null;
|
||||
|
||||
for (EmailLogEntity log : emailLogs) {
|
||||
|
||||
if (emailScenario == null) {
|
||||
emailScenario = log.getEmailType();
|
||||
}
|
||||
boolean isSuccess = StatusTypeEnum.SUCCESS.getValue().equals(log.getSendStatus());
|
||||
if (Boolean.FALSE.equals(isSuccess)) {
|
||||
allSuccess = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return buildResponse(userActionId, allSuccess, emailScenario);
|
||||
}
|
||||
|
||||
private EmailSendResponse buildResponse(Long userActionId, boolean allSuccess, String emailScenario) {
|
||||
EmailSendResponse response = new EmailSendResponse();
|
||||
response.setUserActionId(userActionId);
|
||||
response.setIsEmailSend(allSuccess);
|
||||
response.setEmailScenario(emailScenario != null ? EmailScenarioTypeEnum.valueOf(emailScenario) : null);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.EmailLogEntity;
|
||||
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.EmailEntityTypeEnum;
|
||||
@@ -9,6 +10,7 @@ import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.repositories.EmailLogRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserActionsRepository;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -22,6 +24,12 @@ public class EmailLogDao {
|
||||
@Autowired
|
||||
private EmailLogRepository emailLogRepository;
|
||||
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private LoggingUtil loggingUtil;
|
||||
|
||||
|
||||
public EmailLogEntity createEmailLog(EmailLogRequest emailLogRequest) {
|
||||
|
||||
@@ -42,8 +50,8 @@ public class EmailLogDao {
|
||||
emailLogEntity.setApplicationId(emailLogRequest.getApplicatioId());
|
||||
emailLogEntity.setAmendmentId(emailLogRequest.getAmendmentId());
|
||||
emailLogEntity.setCallId(emailLogRequest.getCallId());
|
||||
emailLogEntity.setUserAction(loggingUtil.getUserActionLogById(emailLogRequest.getUserActionId()));
|
||||
emailLogEntity = saveEmailLogEntity(emailLogEntity);
|
||||
|
||||
return emailLogEntity;
|
||||
}
|
||||
public EmailLogEntity saveEmailLogEntity(EmailLogEntity emailLogEntity){
|
||||
@@ -52,6 +60,7 @@ public class EmailLogDao {
|
||||
public EmailLogRequest createEmailLogRequest(EmailScenarioTypeEnum emailType, RecipientTypeEnum recipientType, Long recipientId,
|
||||
String recipientEmails, Long userId,Long applicationId,Long amendmentId,Long callId) {
|
||||
EmailLogRequest emailLogRequest = new EmailLogRequest();
|
||||
Long userActionId =(Long) request.getAttribute(GepafinConstant.USER_ACTION_ID);
|
||||
emailLogRequest.setEmailType(emailType);
|
||||
emailLogRequest.setRecipientType(recipientType);
|
||||
emailLogRequest.setRecipientId(recipientId);
|
||||
@@ -60,6 +69,7 @@ public class EmailLogDao {
|
||||
emailLogRequest.setApplicatioId(applicationId);
|
||||
emailLogRequest.setAmendmentId(amendmentId);
|
||||
emailLogRequest.setCallId(callId);
|
||||
emailLogRequest.setUserActionId(userActionId);
|
||||
return emailLogRequest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public class EmailNotificationDao {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rinaldoEmail != null) {
|
||||
if (GepafinConstant.RINALDO_EMAIL.equals(rinaldoEmail)) {
|
||||
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.PROPERTIES,null ,
|
||||
rinaldoEmail, userEntity.getId(), applicationEntity.getId(), amendmentId, applicationEntity.getCall().getId());
|
||||
|
||||
@@ -283,12 +283,11 @@ public class EmailNotificationDao {
|
||||
if (recipientEmails.stream().anyMatch(email -> email.equals(GepafinConstant.RINALDO_EMAIL))) {
|
||||
emailConfig.setEmailServiceType(EmailServiceTypeEnum.SYSTEM_EMAIL_SERVICE.getValue());
|
||||
EmailService emailService = emailServiceFactory.getEmailService(emailConfig.getEmailServiceType());
|
||||
emailService.sendEmail(subject, body, recipientEmails, emailConfig, emailLogRequest);
|
||||
emailService.sendEmail(subject, body, recipientEmails, emailConfig, emailLogRequest);
|
||||
} else {
|
||||
emailConfig = retrieveEmailConfig(hubId);
|
||||
EmailService emailService = emailServiceFactory.getEmailService(emailConfig.getEmailServiceType());
|
||||
emailService.sendEmail(subject, body, recipientEmails, emailConfig, emailLogRequest);
|
||||
|
||||
emailService.sendEmail(subject, body, recipientEmails, emailConfig, emailLogRequest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.model.util.SortBy;
|
||||
import net.gepafin.tendermanagement.repositories.BeneficiaryRepository;
|
||||
import net.gepafin.tendermanagement.repositories.EmailLogRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.service.HubService;
|
||||
import net.gepafin.tendermanagement.service.RoleService;
|
||||
@@ -42,6 +43,7 @@ import org.springframework.stereotype.Component;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
@@ -109,9 +111,15 @@ public class UserDao {
|
||||
@Autowired
|
||||
private EmailNotificationDao emailNotificationDao;
|
||||
|
||||
@Autowired
|
||||
private EmailLogRepository emailLogRepository;
|
||||
|
||||
@Value("${fe.base.url}")
|
||||
private String feBaseUrl;
|
||||
|
||||
@Autowired
|
||||
EmailDao emailDao;
|
||||
|
||||
public JWTToken createUser(HttpServletRequest request, String tempToken, UserReq userReq) {
|
||||
|
||||
if (StringUtils.isEmpty(userReq.getHubUuid())) {
|
||||
@@ -134,7 +142,6 @@ public class UserDao {
|
||||
authenticationService.createSuccessLoginAttempt(loginAttemptEntity);
|
||||
}
|
||||
|
||||
JWTToken token = authService.getJWTTokenBean(userEntity, Boolean.TRUE, loginAttemptEntity.getId());
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Create beneficiary" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).newData(beneficiary).build());
|
||||
@@ -142,12 +149,32 @@ public class UserDao {
|
||||
/** This code is responsible for adding a version history log for the "Create user" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).newData(userEntity).build());
|
||||
|
||||
EmailSendResponse emailSendResponse = new EmailSendResponse();
|
||||
if(Boolean.FALSE.equals(roleEntity.getRoleType().equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue()))){
|
||||
sendEmailToOnboardingUser(userEntity, userReq );
|
||||
boolean isEmailSendSuccess = isEmailSentSuccessfully(userEntity.getId());
|
||||
emailSendResponse.setIsEmailSend(isEmailSendSuccess);
|
||||
Long userActionId =(Long)request.getAttribute(GepafinConstant.USER_ACTION_ID);
|
||||
emailSendResponse.setUserActionId(userActionId);
|
||||
emailSendResponse.setEmailScenario(EmailScenarioTypeEnum.USER_CREATION);
|
||||
saveEmailSendResponseToUser(emailSendResponse,userEntity);
|
||||
}
|
||||
JWTToken token = authService.getJWTTokenBean(userEntity, Boolean.TRUE, loginAttemptEntity.getId(),emailSendResponse);
|
||||
return token;
|
||||
}
|
||||
public void sendEmailToOnboardingUser(UserEntity userEntity,UserReq userReq){
|
||||
|
||||
public boolean isEmailSentSuccessfully(Long userId) {
|
||||
Optional<EmailLogEntity> latestLogOpt = emailLogRepository
|
||||
.findTopByUserIdAndEmailTypeAndIsDeletedFalseOrderByCreatedDateDesc(userId, EmailScenarioTypeEnum.USER_CREATION.getValue());
|
||||
|
||||
return latestLogOpt
|
||||
.map(log -> StatusTypeEnum.SUCCESS.getValue().equals(log.getSendStatus()))
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void sendEmailToOnboardingUser(UserEntity userEntity,UserReq userReq){
|
||||
SystemEmailTemplateResponse emailTemplate;
|
||||
RoleStatusEnum roleStatus = RoleStatusEnum.valueOf(userEntity.getRoleEntity().getRoleType());
|
||||
|
||||
@@ -382,6 +409,7 @@ public class UserDao {
|
||||
RoleResponseBean roleResponseBean = roleDao.convertRoleEntityToRoleResponse(userEntity.getRoleEntity());
|
||||
userResponseBean.setRole(roleResponseBean);
|
||||
userResponseBean.setLastLogin(userEntity.getLastLogin());
|
||||
userResponseBean.setEmailSendResponse(userEntity.getEmailSendResponse());
|
||||
List<CompanyResponse> companyResponseBeans = companyDao.getCompanyByUserId(userEntity.getId());
|
||||
userResponseBean.setCompanies(companyResponseBeans);
|
||||
if (userEntity.getBeneficiary() == null) {
|
||||
@@ -459,7 +487,7 @@ public class UserDao {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void initiatePasswordReset(InitiatePasswordResetReq resetReq) {
|
||||
public InitiatePasswordResetResponse initiatePasswordReset(InitiatePasswordResetReq resetReq) {
|
||||
UserEntity user = userRepository.findUserExcludingRoleType(
|
||||
resetReq.getEmail(),
|
||||
resetReq.getHubUuid(),
|
||||
@@ -478,9 +506,22 @@ public class UserDao {
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldUserEntity).newData(user).build());
|
||||
|
||||
log.info("Password reset token generated for user: {}", resetReq.getEmail());
|
||||
|
||||
sendResetPasswordTokenEmail(user, token);
|
||||
InitiatePasswordResetResponse initiatePasswordResetResponse = new InitiatePasswordResetResponse();
|
||||
EmailSendResponse emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
initiatePasswordResetResponse.setEmailSendResponse(emailSendResponse);
|
||||
saveEmailSendResponseToUser(emailSendResponse,user);
|
||||
return initiatePasswordResetResponse;
|
||||
}
|
||||
|
||||
private void saveEmailSendResponseToUser(EmailSendResponse newResponse, UserEntity user) {
|
||||
List<EmailSendResponse> mergedResponses = Utils.mergeEmailSendResponses(
|
||||
user.getEmailSendResponse(), newResponse
|
||||
);
|
||||
user.setEmailSendResponse(mergedResponses);
|
||||
userRepository.save(user);
|
||||
}
|
||||
|
||||
public void sendResetPasswordTokenEmail(UserEntity user, String token) {
|
||||
|
||||
SystemEmailTemplateResponse emailTemplate = systemEmailTemplatesService.retrieveTemplateByTypeAndCall(
|
||||
|
||||
@@ -2,7 +2,10 @@ package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name="application_amendment_request")
|
||||
@@ -53,7 +56,10 @@ public class ApplicationAmendmentRequestEntity extends BaseEntity {
|
||||
@Column(name = "amendment_document")
|
||||
private String amendmentDocument;
|
||||
|
||||
|
||||
@Column(name = "CLOSING_DATE")
|
||||
private LocalDateTime closingDate;
|
||||
|
||||
@Convert(converter = EmailSendResponseConverter.class)
|
||||
@Column(name = "EMAIL_SEND_RESPONSE", columnDefinition = "TEXT")
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@ package net.gepafin.tendermanagement.entities;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Immutable
|
||||
@@ -13,12 +16,12 @@ import java.time.LocalDateTime;
|
||||
@Getter
|
||||
@Setter
|
||||
@IdClass(ApplicationAmendmentRequestViewId.class)
|
||||
public class ApplicationAmendmentRequestView {
|
||||
public class ApplicationAmendmentRequestView extends BaseEntity {
|
||||
|
||||
|
||||
@Id
|
||||
@Column(name = "ID")
|
||||
private Long id;
|
||||
// @Id
|
||||
// @Column(name = "ID")
|
||||
// private Long id;
|
||||
|
||||
@Column(name = "APPLICATION_ID")
|
||||
private Long applicationId;
|
||||
@@ -56,12 +59,17 @@ public class ApplicationAmendmentRequestView {
|
||||
@Column(name = "APPLICATION_USER_ID")
|
||||
private Long applicationUserId;
|
||||
|
||||
@Column(name = "CREATED_DATE")
|
||||
private String createdDate;
|
||||
|
||||
@Column(name = "UPDATED_DATE")
|
||||
private String updatedDate;
|
||||
// @Column(name = "CREATED_DATE")
|
||||
// private String createdDate;
|
||||
//
|
||||
// @Column(name = "UPDATED_DATE")
|
||||
// private String updatedDate;
|
||||
|
||||
@Column(name = "IS_DELETED")
|
||||
private Boolean isDeleted;
|
||||
|
||||
@Convert(converter = EmailSendResponseConverter.class)
|
||||
@Column(name = "EMAIL_SEND_RESPONSE", columnDefinition = "TEXT")
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@@ -71,4 +73,7 @@ public class ApplicationEvaluationEntity extends BaseEntity{
|
||||
@Column(name = "evaluationVersion")
|
||||
private String evaluationVersion;
|
||||
|
||||
@Convert(converter = EmailSendResponseConverter.class)
|
||||
@Column(name = "EMAIL_SEND_RESPONSE", columnDefinition = "TEXT")
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Immutable
|
||||
@@ -58,4 +60,11 @@ public class AssignedApplicationsView{
|
||||
|
||||
@Column(name = "IS_DELETED")
|
||||
private Boolean isDeleted;
|
||||
|
||||
@Convert(converter = EmailSendResponseConverter.class)
|
||||
@Column(name = "EMAIL_SEND_RESPONSE", columnDefinition = "TEXT")
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
|
||||
@Column(name = "HUB_ID")
|
||||
private Long hubId;
|
||||
}
|
||||
|
||||
@@ -56,5 +56,9 @@ public class EmailLogEntity extends BaseEntity{
|
||||
|
||||
@Column(name = "is_deleted")
|
||||
private Boolean isDeleted;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "user_action_id")
|
||||
private UserActionEntity userAction;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.persistence.AttributeConverter;
|
||||
import jakarta.persistence.Converter;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Converter
|
||||
public class EmailSendResponseConverter implements AttributeConverter<List<EmailSendResponse>, String> {
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public String convertToDatabaseColumn(List<EmailSendResponse> attribute) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(attribute);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new IllegalArgumentException("Error converting list to JSON", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EmailSendResponse> convertToEntityAttribute(String dbData) {
|
||||
if (dbData == null || dbData.isBlank()) {
|
||||
return List.of(); // or null if you prefer
|
||||
}
|
||||
try {
|
||||
return objectMapper.readValue(dbData, new TypeReference<List<EmailSendResponse>>() {});
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("Error reading JSON from database", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ public class SystemEmailTemplatesEntity extends BaseEntity {
|
||||
USER_ONBOARDING_CONFIDI("USER_ONBOARDING_CONFIDI"),
|
||||
USER_ONBOARDING_BANDI("USER_ONBOARDING_BANDI"),
|
||||
PASSWORD_RESET("PASSWORD_RESET"),
|
||||
INADMISSIBILITY_TEMPLATE("INADMISSIBILITY_NOTIFICATION");
|
||||
INADMISSIBILITY_TEMPLATE("INADMISSIBILITY_NOTIFICATION"),
|
||||
APPLICATION_SUBMISSION_FAILURE_NOTIFICATION("APPLICATION_SUBMISSION_FAILURE_NOTIFICATION");
|
||||
private String value;
|
||||
|
||||
SystemEmailTemplatesEntityTypeEnum(String value) {
|
||||
|
||||
@@ -7,8 +7,10 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "GEPAFIN_USER")
|
||||
@@ -69,4 +71,9 @@ public class UserEntity extends BaseEntity {
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "HUB_ID")
|
||||
private HubEntity hub;
|
||||
|
||||
@Convert(converter = EmailSendResponseConverter.class)
|
||||
@Column(name = "EMAIL_SEND_RESPONSE", columnDefinition = "TEXT")
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ public enum EmailScenarioTypeEnum {
|
||||
APPLICATION_ADMISSIBLE("APPLICATION_ADMISSIBLE"),
|
||||
USER_CREATION("USER_CREATION"),
|
||||
PASSWORD_RESET_REQUEST("PASSWORD_RESET_REQUEST"),
|
||||
APPLICATION_REJECTED("APPLICATION_REJECTED");
|
||||
APPLICATION_REJECTED("APPLICATION_REJECTED"),
|
||||
APPLICATION_SUBMISSION_FAILURE("APPLICATION_SUBMISSION_FAILURE");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ public enum NotificationTypeEnum {
|
||||
EVALUATION_EXPIRED("EVALUATION_EXPIRED"),
|
||||
AMENDMENT_EXPIRATION_REMINDER("AMENDMENT_EXPIRATION_REMINDER"),
|
||||
EVALUATION_EXPIRATION_REMINDER("EVALUATION_EXPIRATION_REMINDER"),
|
||||
COMPANY_DOCUMENT_EXPIRATION_REMINDER("COMPANY_DOCUMENT_EXPIRATION_REMINDER");
|
||||
COMPANY_DOCUMENT_EXPIRATION_REMINDER("COMPANY_DOCUMENT_EXPIRATION_REMINDER"),
|
||||
PEC_EMAIL_SENDING_FAILURE("PEC_EMAIL_SENDING_FAILURE");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ public enum UserActionContextEnum {
|
||||
GET_SIGNED_DOCUMENT("GET_SIGNED_DOCUMENT"),
|
||||
GET_NEXT_PREVIOUS_FORM("GET_NEXT_PREVIOUS_FORM"),
|
||||
DOWNLOAD_APPLICATION_DOC_ZIP("DOWNLOAD_APPLICATION_DOC_ZIP"),
|
||||
READMIT_APPLICATION("READMIT_APPLICATION"),
|
||||
|
||||
/** FAQ action context **/
|
||||
CREATE_FAQ("CREATE_FAQ"),
|
||||
@@ -215,7 +216,9 @@ public enum UserActionContextEnum {
|
||||
GET_ALL_USER_ACTION_BY_PAGINATION("GET_ALL_USER_ACTION_BY_PAGINATION"),
|
||||
GET_ALL_USER_BY_PAGINATION("GET_ALL_USER_BY_PAGINATION"),
|
||||
UPDATE_CALL_END_DATE_AND_TIME("UPDATE_CALL_END_DATE_AND_TIME"),
|
||||
UPDATE_EXPIRED_CALL("UPDATE_EXPIRED_CALL") ;
|
||||
UPDATE_EXPIRED_CALL("UPDATE_EXPIRED_CALL"),
|
||||
RESEND_EMAIL("RESEND_EMAIL"),
|
||||
SEND_REMINDER_EMAIL("SEND_REMINDER_EMAIL");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ public enum UserActionLogsEnum {
|
||||
DOWNLOAD("DOWNLOAD"),
|
||||
UPLOAD("UPLOAD"),
|
||||
SCHEDULER("SCHEDULER"),
|
||||
SCRIPT("SCRIPT");
|
||||
SCRIPT("SCRIPT"),
|
||||
EMAIL("EMAIL");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
||||
@@ -14,6 +14,4 @@ public class CallPageableRequestBean {
|
||||
private List<CallStatusEnum> status;
|
||||
|
||||
private Map<String, FilterCriteria> filters;
|
||||
|
||||
private Boolean confidi;
|
||||
}
|
||||
|
||||
@@ -37,4 +37,6 @@ public class EmailLogRequest {
|
||||
|
||||
private Long callId;
|
||||
|
||||
private Long userActionId;
|
||||
|
||||
}
|
||||
|
||||
@@ -32,4 +32,5 @@ public class ApplicationAmendmentRequestResponse {
|
||||
private String internalNote;
|
||||
private ApplicationAmendmentRequestEnum status;
|
||||
private String emailTemplate;
|
||||
private EmailSendResponse emailSendResponse;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApplicationAmendmentRequestResponseBean {
|
||||
private Long id;
|
||||
private String callEmail;
|
||||
private String note;
|
||||
private Long responseDays;
|
||||
private LocalDateTime startDate;
|
||||
private Boolean isSendNotification;
|
||||
private Boolean isSendEmail;
|
||||
private Long protocolNumber;
|
||||
private String callName;
|
||||
private String beneficiaryName;
|
||||
private String companyName;
|
||||
private List<AmendmentFormFieldResponse> formFields;
|
||||
private List<ApplicationFormFieldResponseBean> applicationFormFields;
|
||||
private List<DocumentResponseBean> amendmentDocuments;
|
||||
private String amendmentNotes;
|
||||
private Boolean valid;
|
||||
private Long applicationId;
|
||||
private Long applicationEvaluationId;
|
||||
private LocalDateTime evaluationEndDate;
|
||||
private LocalDateTime expirationDate;
|
||||
private List<CommunicationResponseBean> commentsList;
|
||||
private String internalNote;
|
||||
private ApplicationAmendmentRequestEnum status;
|
||||
private String emailTemplate;
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.model.response;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApplicationAmendmentRequestViewResponse {
|
||||
@@ -24,4 +25,6 @@ public class ApplicationAmendmentRequestViewResponse {
|
||||
private String assigendUserName;
|
||||
|
||||
private String status;
|
||||
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
|
||||
@@ -49,5 +49,6 @@ public class ApplicationEvaluationResponse {
|
||||
private EvaluationVersionEnum evaluationVersion;
|
||||
private String companyVatNumber;
|
||||
private String companyCodiceAteco;
|
||||
private EmailSendResponse emailSendResponse;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.EvaluationVersionEnum;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ApplicationEvaluationResponseBean {
|
||||
|
||||
private Long id;
|
||||
private Long applicationId;
|
||||
private ApplicationStatusTypeEnum applicationStatus;
|
||||
private Long assignedApplicationId;
|
||||
private String note;
|
||||
private ApplicationEvaluationStatusTypeEnum status;
|
||||
private Long minScore;
|
||||
private List<CriteriaResponse> criteria;
|
||||
private List<ChecklistResponse> checklist;
|
||||
private List<FieldResponse> files;
|
||||
private List<EvaluationDocumentResponse> evaluationDocument;
|
||||
private List<AmendmentDocumentResponseBean> amendmentDetails;
|
||||
private LocalDateTime createdDate;
|
||||
private LocalDateTime updatedDate;
|
||||
private String beneficiary;
|
||||
private Long assignedUserId;
|
||||
private String assignedUserName;
|
||||
private Long protocolNumber;
|
||||
private String callName;
|
||||
private String motivation;
|
||||
private LocalDateTime submissionDate;
|
||||
private LocalDateTime evaluationEndDate;
|
||||
private LocalDateTime callEndDate;
|
||||
private String companyName;
|
||||
private LocalDateTime assignedAt;
|
||||
private String ndg;
|
||||
private String appointmentId;
|
||||
private BigDecimal amountRequested;
|
||||
private BigDecimal amountAccepted;
|
||||
private LocalDateTime dateAccepted;
|
||||
private LocalDateTime dateRejected;
|
||||
private Long numberOfCheck;
|
||||
private Long appointmentTemplateId;
|
||||
private EvaluationVersionEnum evaluationVersion;
|
||||
private String companyVatNumber;
|
||||
private String companyCodiceAteco;
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import net.gepafin.tendermanagement.enums.AssignedApplicationEnum;
|
||||
import net.gepafin.tendermanagement.model.BaseBean;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AssignedApplicationViewResponse extends BaseBean {
|
||||
@@ -20,5 +21,7 @@ public class AssignedApplicationViewResponse extends BaseBean {
|
||||
private Long protocolNumber;
|
||||
private String callName;
|
||||
private String companyName;
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EmailReminderResponse {
|
||||
|
||||
@JsonProperty("emailSendResponse")
|
||||
private EmailSendResponse emailSendResponse;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class EmailResendResponseBean {
|
||||
|
||||
private EmailSendResponse emailSendResponse;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
|
||||
|
||||
@Data
|
||||
public class EmailSendResponse {
|
||||
private Boolean isEmailSend;
|
||||
private Long userActionId;
|
||||
private EmailScenarioTypeEnum emailScenario;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class InitiatePasswordResetResponse {
|
||||
private EmailSendResponse emailSendResponse;
|
||||
}
|
||||
@@ -48,4 +48,5 @@ public class UserResponseBean extends BaseBean {
|
||||
private Boolean thirdParty;
|
||||
|
||||
private String emailPec;
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.model.util;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
import net.gepafin.tendermanagement.model.response.LoginResponse;
|
||||
|
||||
/**
|
||||
@@ -15,10 +16,20 @@ public class JWTToken {
|
||||
|
||||
@JsonProperty("user")
|
||||
private LoginResponse loginResponse;
|
||||
|
||||
@JsonProperty("emailSendResponse")
|
||||
private EmailSendResponse emailSendResponse;
|
||||
|
||||
public JWTToken(String token, LoginResponse loginResponse) {
|
||||
this.token = token;
|
||||
this.loginResponse = loginResponse;
|
||||
}
|
||||
|
||||
public JWTToken(String token, LoginResponse loginResponse, EmailSendResponse emailSendResponse) {
|
||||
this.token = token;
|
||||
this.loginResponse = loginResponse;
|
||||
this.emailSendResponse = emailSendResponse;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -76,5 +76,14 @@ public interface ApplicationEvaluationRepository extends JpaRepository<Applicati
|
||||
@Param("assignedApplicationId") Long assignedApplicationId
|
||||
);
|
||||
|
||||
Optional<ApplicationEvaluationEntity> findByAssignedApplicationsEntity_IdAndStatusAndIsDeletedFalse(
|
||||
Long assignedApplicationId,
|
||||
String status
|
||||
);
|
||||
@Query("SELECT ae FROM ApplicationEvaluationEntity ae WHERE ae.applicationId = :applicationId AND ae.isDeleted = false")
|
||||
ApplicationEvaluationEntity findByApplicationId(@Param("applicationId") Long applicationId);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -178,4 +178,7 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
||||
void resetNdgStatusForInProgress(@Param("status") String status);
|
||||
|
||||
boolean existsByCallId(Long callId);
|
||||
|
||||
ApplicationEntity findByIdAndStatusAndIsDeletedFalse( Long id, String status);
|
||||
|
||||
}
|
||||
|
||||
@@ -110,4 +110,8 @@ public interface AssignedApplicationsRepository extends JpaRepository<AssignedAp
|
||||
@Param("sevenDaysAgo") LocalDateTime sevenDaysAgo);
|
||||
|
||||
|
||||
Optional<AssignedApplicationsEntity> findByApplicationIdAndStatusAndIsDeletedFalse( Long applicationId, String status);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.EmailLogEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface EmailLogRepository extends JpaRepository<EmailLogEntity,Long> {
|
||||
|
||||
List<EmailLogEntity> findByUserIdAndAmendmentIdAndIsDeletedFalse(Long userId,Long amendmentId);
|
||||
List<EmailLogEntity> findByUserActionId(Long userActionId);
|
||||
List<EmailLogEntity> findByUserActionIdAndEmailServiceTypeAndSendStatus(
|
||||
Long userActionId, String emailServiceType, String sendStatus);
|
||||
Optional<EmailLogEntity> findTopByUserIdAndEmailTypeAndIsDeletedFalseOrderByCreatedDateDesc(Long userId, String emailType);
|
||||
List<EmailLogEntity> findByUserActionIdAndEmailServiceType(
|
||||
Long userActionId, String emailServiceType);
|
||||
|
||||
EmailLogEntity findTopByUserActionIdAndEmailServiceTypeAndSendStatusOrderByIdDesc(
|
||||
Long userActionId,
|
||||
String emailServiceType,
|
||||
String sendStatus
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,10 +8,7 @@ import net.gepafin.tendermanagement.model.request.ApplicationAmendmentPagination
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestViewResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,7 +16,7 @@ public interface ApplicationAmendmentRequestService {
|
||||
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(HttpServletRequest request,Long applicationEvaluationId);
|
||||
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest);
|
||||
void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id);
|
||||
ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id);
|
||||
ApplicationAmendmentRequestResponseBean getApplicationAmendmentRequestById(HttpServletRequest request,Long id);
|
||||
List<GetAllAmendmentResponseBean> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId);
|
||||
ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean);
|
||||
ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long applicationAmendmentId);
|
||||
@@ -29,6 +26,6 @@ public interface ApplicationAmendmentRequestService {
|
||||
public List<ApplicationAmendmentRequestResponse> getAmendmentByApplicationId(HttpServletRequest request,Long applicationId,List<ApplicationAmendmentRequestEnum> statuses);
|
||||
public ApplicationAmendmentRequestResponse updateApplicationAmendmentStatus(HttpServletRequest request, Long applicationAmendmentId, ApplicationAmendmentRequestEnum status);
|
||||
|
||||
void sendReminderEmail(HttpServletRequest request,Long amendmentId);
|
||||
EmailReminderResponse sendReminderEmail(HttpServletRequest request, Long amendmentId);
|
||||
PageableResponseBean<List<ApplicationAmendmentRequestViewResponse>> getApplicationAmendmentByPaginnation(HttpServletRequest request, Long userId, ApplicationAmendmentPaginationRequestBean amendmentPaginationRequestBean);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public interface ApplicationEvaluationService {
|
||||
|
||||
void deleteApplicationEvaluation(HttpServletRequest request,Long id);
|
||||
|
||||
ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId,Long assignedApplicationId);
|
||||
ApplicationEvaluationResponseBean getApplicationEvaluationByApplicationId(HttpServletRequest request,Long applicationId,Long assignedApplicationId);
|
||||
ApplicationEvaluationEntity validateApplicationEvaluation(Long applicationEvaluationId);
|
||||
|
||||
ApplicationEvaluationEntity validateApplicationEvaluationByApplicationId(Long applicationId);
|
||||
|
||||
@@ -50,4 +50,6 @@ public interface ApplicationService {
|
||||
|
||||
public byte[] exportCsv(HttpServletRequest request, Long callId);
|
||||
|
||||
public ApplicationResponse readmitApplication(HttpServletRequest request, Long applicationId);
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public interface CallService {
|
||||
|
||||
byte[] downloadCallDocumentsAsZip(HttpServletRequest request, Long callId);
|
||||
|
||||
PageableResponseBean<List<CallDetailsResponseBean>> getAllCallsByPagination(HttpServletRequest request, Long companyId , Boolean onlyPreferredCall,CallPageableRequestBean callPageableRequestBean);
|
||||
PageableResponseBean<List<CallDetailsResponseBean>> getAllCallsByPagination(HttpServletRequest request, Long companyId , Boolean onlyPreferredCall,Boolean onlyConfidiCall,CallPageableRequestBean callPageableRequestBean);
|
||||
|
||||
CallResponse createCallStep2EvaluationV2(HttpServletRequest request, Long callId, CreateCallRequestStep2EvaluationV2 createCallRequest);
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.model.response.EmailResendResponseBean;
|
||||
|
||||
|
||||
public interface ResendEmailService {
|
||||
EmailResendResponseBean resendEmail(HttpServletRequest request , Long userActionId);
|
||||
}
|
||||
@@ -8,9 +8,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
|
||||
import java.util.List;
|
||||
@@ -28,7 +26,7 @@ public interface UserService {
|
||||
|
||||
UserEntity validateUser(Long userId);
|
||||
|
||||
void initiatePasswordReset(InitiatePasswordResetReq resetReq);
|
||||
InitiatePasswordResetResponse initiatePasswordReset(InitiatePasswordResetReq resetReq);
|
||||
|
||||
Boolean resetPassword(ResetPasswordReq resetPasswordReq);
|
||||
|
||||
|
||||
@@ -12,10 +12,7 @@ import net.gepafin.tendermanagement.model.request.ApplicationAmendmentPagination
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.CloseAmendmentRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestViewResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationAmendmentRequestRepository;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationEvaluationRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
||||
@@ -78,7 +75,7 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id) {
|
||||
public ApplicationAmendmentRequestResponseBean getApplicationAmendmentRequestById(HttpServletRequest request,Long id) {
|
||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
|
||||
@@ -145,17 +142,18 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
|
||||
|
||||
}
|
||||
@Override
|
||||
public void sendReminderEmail(HttpServletRequest request,Long amendmentId) {
|
||||
public EmailReminderResponse sendReminderEmail(HttpServletRequest request, Long amendmentId) {
|
||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(amendmentId)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
|
||||
|
||||
EmailReminderResponse response = new EmailReminderResponse();
|
||||
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
|
||||
if (entityOptional.isPresent()) {
|
||||
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
|
||||
|
||||
applicationAmendmentRequestDao.sendReminderEmail(amendmentId);
|
||||
response = applicationAmendmentRequestDao.sendReminderEmail(amendmentId);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.gepafin.tendermanagement.model.request.ApplicationEvaluationFormReque
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationFormResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationVersionResponse;
|
||||
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
|
||||
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
|
||||
@@ -56,7 +57,7 @@ public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationSe
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(
|
||||
public ApplicationEvaluationResponseBean getApplicationEvaluationByApplicationId(
|
||||
HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
|
||||
UserEntity preInstructor = validator.validateUser(request);
|
||||
return applicationEvaluationDao.getApplicationEvaluationByApplicationId(
|
||||
|
||||
@@ -170,5 +170,10 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
|
||||
return csvBytes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationResponse readmitApplication(HttpServletRequest request, Long applicationId) {
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
return applicationDao.readmitApplication(request, applicationId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,7 @@ import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.*;
|
||||
import net.gepafin.tendermanagement.model.request.LoginReq;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
||||
import net.gepafin.tendermanagement.model.response.LoginResponse;
|
||||
import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.repositories.LoginAttemptRepository;
|
||||
import net.gepafin.tendermanagement.repositories.SamlResponseRepository;
|
||||
@@ -122,7 +119,7 @@ public class AuthenticationService {
|
||||
createFailedLoginAttempt(loginAttemptEntity, e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
return getJWTTokenBean(user, loginReq.getRememberMe(), loginAttemptEntity.getId());
|
||||
return getJWTTokenBean(user, loginReq.getRememberMe(), loginAttemptEntity.getId(),null);
|
||||
}
|
||||
|
||||
public LoginAttemptEntity prepareLoginAttemptEntity(LoginReq loginUserReq, HttpServletRequest request) {
|
||||
@@ -145,7 +142,7 @@ public class AuthenticationService {
|
||||
loginAttemptEntity.setErrorMsg(errorMsg);
|
||||
loginAttemptDao.createLoginAttempt(loginAttemptEntity);
|
||||
}
|
||||
public JWTToken getJWTTokenBean(UserEntity user, Boolean rememberMe, Long loginAttemptId) {
|
||||
public JWTToken getJWTTokenBean(UserEntity user, Boolean rememberMe, Long loginAttemptId, EmailSendResponse emailSendResponse) {
|
||||
UserEntity oldUserEntity = Utils.getClonedEntityForData(user);
|
||||
user.setLastLogin(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
user = userRepository.save(user);
|
||||
@@ -156,7 +153,7 @@ public class AuthenticationService {
|
||||
|
||||
LoginResponse loginResponse = getLoginResponse(user, roleResponseBean);
|
||||
|
||||
JWTToken jwtToken = new JWTToken(token, loginResponse);
|
||||
JWTToken jwtToken = new JWTToken(token, loginResponse , emailSendResponse);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Create user Or Update user" operation. **/
|
||||
loggingUtil.addVersionHistoryWithoutToken(VersionHistoryRequest.builder().request(request).oldData(oldUserEntity).newData(user).actionType(VersionActionTypeEnum.UPDATE).build());
|
||||
@@ -238,7 +235,7 @@ public class AuthenticationService {
|
||||
loginAttemptEntity = prepareLoginAttemptEntity(loginReq, request);
|
||||
loginAttemptEntity.setUserId(userEntity.getId());
|
||||
LoginAttemptEntity loginAttempt = createSuccessLoginAttempt(loginAttemptEntity);
|
||||
return getJWTTokenBean(userEntity, Boolean.TRUE, loginAttempt.getId());
|
||||
return getJWTTokenBean(userEntity, Boolean.TRUE, loginAttempt.getId(),null);
|
||||
} catch (Exception e) {
|
||||
log.info("Authentication login failed for email: {}",e.getMessage());
|
||||
loginAttemptEntity.setUserId(userId);
|
||||
|
||||
@@ -105,9 +105,9 @@ public class CallServiceImpl implements CallService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public PageableResponseBean<List<CallDetailsResponseBean>> getAllCallsByPagination(HttpServletRequest request,Long companyId , Boolean onlyPreferredCall, CallPageableRequestBean callPageableRequestBean) {
|
||||
public PageableResponseBean<List<CallDetailsResponseBean>> getAllCallsByPagination(HttpServletRequest request,Long companyId , Boolean onlyPreferredCall,Boolean onlyConfidiCall, CallPageableRequestBean callPageableRequestBean) {
|
||||
UserEntity user = validator.validateUser(request);
|
||||
return callDao.getAllCallsByPagination(request,user,companyId,onlyPreferredCall,callPageableRequestBean);
|
||||
return callDao.getAllCallsByPagination(request,user,companyId,onlyPreferredCall,onlyConfidiCall,callPageableRequestBean);
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
@@ -1,25 +1,32 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mashape.unirest.http.HttpResponse;
|
||||
import com.mashape.unirest.http.Unirest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.dao.ApplicationDao;
|
||||
import net.gepafin.tendermanagement.dao.EmailLogDao;
|
||||
import net.gepafin.tendermanagement.entities.EmailLogEntity;
|
||||
import net.gepafin.tendermanagement.dao.NotificationDao;
|
||||
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.EmailServiceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.StatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.request.PecEmailRequest;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
|
||||
import org.opensaml.xmlsec.signature.G;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -30,20 +37,26 @@ public class PecEmailService implements EmailService {
|
||||
|
||||
@Value("${isPecServiceEnabled}")
|
||||
private String isPecServiceEnabled;
|
||||
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private EmailLogDao emailLogDao;
|
||||
|
||||
@Autowired
|
||||
private NotificationDao notificationDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationDao applicationDao;
|
||||
|
||||
@Override
|
||||
public void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig, EmailLogRequest emailLogRequest) {
|
||||
|
||||
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PecEmailRequest emailRequest = new PecEmailRequest();
|
||||
emailRequest.setSender(emailConfig.getSender());
|
||||
emailRequest.setSubject(subject);
|
||||
@@ -67,13 +80,27 @@ public class PecEmailService implements EmailService {
|
||||
.header("Content-Type", "application/json")
|
||||
.body(Utils.convertObjectToJson(emailRequest)) // Serialize the emailRequest object to JSON
|
||||
.asString();
|
||||
|
||||
if (!isSuccessfulPecResponse(response2.getBody())) {
|
||||
String errorMsg = "PEC sending failed: " + response2.getBody();
|
||||
emailLogRequest.setSendStatus(StatusTypeEnum.FAILED.getValue());
|
||||
emailLogRequest.setEmailServiceType(EmailServiceTypeEnum.PEC_SERVICE);
|
||||
emailLogRequest.setErrorMessage(errorMsg);
|
||||
sendNotificationOnFailure(emailLogRequest.getUserId(),emailLogRequest.getEmailType());
|
||||
|
||||
if (EmailScenarioTypeEnum.APPLICATION_SUBMITTED.equals(emailLogRequest.getEmailType())) {
|
||||
applicationDao.sendApplicationSubmissionFailureEmail(emailLogRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch(Exception e) {
|
||||
emailLogRequest.setSendStatus(StatusTypeEnum.FAILED.getValue());
|
||||
emailLogRequest.setEmailServiceType(EmailServiceTypeEnum.PEC_SERVICE);
|
||||
emailLogRequest.setErrorMessage(e.getMessage());
|
||||
emailLogDao.createEmailLog(emailLogRequest);
|
||||
throw new RuntimeException("Failed to send email via PEC: " + response2.getStatus());
|
||||
sendNotificationOnFailure(emailLogRequest.getUserId(),emailLogRequest.getEmailType());
|
||||
if (EmailScenarioTypeEnum.APPLICATION_SUBMITTED.equals(emailLogRequest.getEmailType())) {
|
||||
applicationDao.sendApplicationSubmissionFailureEmail(emailLogRequest);
|
||||
}
|
||||
}
|
||||
if(response2 != null) {
|
||||
emailLogRequest.setEmailServiceResponse(response2.getBody());
|
||||
@@ -82,6 +109,57 @@ public class PecEmailService implements EmailService {
|
||||
emailLogRequest.setEmailServiceType(EmailServiceTypeEnum.PEC_SERVICE);
|
||||
emailLogDao.createEmailLog(emailLogRequest);
|
||||
}
|
||||
|
||||
private void sendNotificationOnFailure(Long userId, EmailScenarioTypeEnum emailScenarioTypeEnum) {
|
||||
if (userId == null) {
|
||||
log.warn("Cannot send notification: userId is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("{{email_scenario}}", emailScenarioTypeEnum.getValue());
|
||||
|
||||
NotificationReq notificationReq = notificationDao.createNotificationReq(
|
||||
NotificationTypeEnum.PEC_EMAIL_SENDING_FAILURE.getValue(),
|
||||
placeholders,
|
||||
userId,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
try {
|
||||
notificationDao.sendNotification(notificationReq);
|
||||
log.info("Sent PEC failure notification to user {}", userId);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to send PEC failure notification to user {}: {}", userId, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSuccessfulPecResponse(String responseBody) {
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode jsonNode = objectMapper.readTree(responseBody);
|
||||
|
||||
boolean success = jsonNode.has("success") && jsonNode.get("success").asBoolean();
|
||||
boolean hasNoError = !jsonNode.has("error") || jsonNode.get("error").isNull();
|
||||
|
||||
if (jsonNode.has("success") && !success) {
|
||||
log.error("PEC response indicates failure: {}", responseBody);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (responseBody.contains("403") || responseBody.toLowerCase().contains("<html") || responseBody.toLowerCase().contains("<!doctype html>")) {
|
||||
log.error("PEC response is a 403 HTML Forbidden page or invalid format: {}", responseBody);
|
||||
return false;
|
||||
}
|
||||
|
||||
return success && hasNoError;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Invalid PEC response format: {}", responseBody);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.dao.EmailDao;
|
||||
import net.gepafin.tendermanagement.model.response.EmailResendResponseBean;
|
||||
import net.gepafin.tendermanagement.service.ResendEmailService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ResendEmailServiceImpl implements ResendEmailService {
|
||||
|
||||
@Autowired
|
||||
Validator validator;
|
||||
|
||||
@Autowired
|
||||
EmailDao emailDao;
|
||||
|
||||
@Override
|
||||
public EmailResendResponseBean resendEmail(HttpServletRequest request, Long userActionId) {
|
||||
validator.validateUser(request);
|
||||
return emailDao.resendEmail(request,userActionId);
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class SystemEmailService implements EmailService {
|
||||
emailLogRequest.setEmailBody(body);
|
||||
emailLogRequest.setSendStatus(StatusTypeEnum.SUCCESS.getValue());
|
||||
emailLogRequest.setRecipientEmails(Utils.listToCommaSeparatedString(recipientEmails));
|
||||
|
||||
emailLogRequest.setEmailServiceType(EmailServiceTypeEnum.SYSTEM_EMAIL_SERVICE);
|
||||
if (Boolean.FALSE.equals(validator.isTestProfileActivated())) {
|
||||
MessageResponse response = null;
|
||||
try {
|
||||
|
||||
@@ -11,9 +11,7 @@ import net.gepafin.tendermanagement.model.request.UpdateUserReq;
|
||||
import net.gepafin.tendermanagement.model.request.UserReq;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
@@ -78,8 +76,8 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initiatePasswordReset(InitiatePasswordResetReq resetReq) {
|
||||
userDao.initiatePasswordReset(resetReq);
|
||||
public InitiatePasswordResetResponse initiatePasswordReset(InitiatePasswordResetReq resetReq) {
|
||||
return userDao.initiatePasswordReset(resetReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -36,9 +37,11 @@ import jakarta.persistence.criteria.Root;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.EmailScenarioTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.MatchModeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.FilterCriteria;
|
||||
import net.gepafin.tendermanagement.model.request.GlobalFilters;
|
||||
import net.gepafin.tendermanagement.model.response.EmailSendResponse;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.*;
|
||||
import net.objecthunter.exp4j.Expression;
|
||||
import net.objecthunter.exp4j.ExpressionBuilder;
|
||||
@@ -291,11 +294,14 @@ public class Utils {
|
||||
return pattern.matcher(email).matches();
|
||||
}
|
||||
|
||||
// public static String randomKey(Integer range) {
|
||||
// String data = String.valueOf(System.currentTimeMillis());
|
||||
// return data.substring(data.length() - range);
|
||||
//
|
||||
// }
|
||||
public static String randomKey(Integer range) {
|
||||
String data = String.valueOf(System.currentTimeMillis());
|
||||
return data.substring(data.length() - range);
|
||||
return UUID.randomUUID().toString().replace("-", "").substring(0, range);
|
||||
}
|
||||
|
||||
public static String convertObjectToJsonString(Object object) {
|
||||
try {
|
||||
// Check if the object is a string
|
||||
@@ -1011,5 +1017,31 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> commaSeparatedStringToList(String emails) {
|
||||
if (emails == null || emails.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return Arrays.stream(emails.split(","))
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
public static List<EmailSendResponse> mergeEmailSendResponses(List<EmailSendResponse> existingResponses, EmailSendResponse newResponse) {
|
||||
Map<EmailScenarioTypeEnum, EmailSendResponse> responseMap = Optional.ofNullable(existingResponses)
|
||||
.orElse(new ArrayList<>())
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
EmailSendResponse::getEmailScenario,
|
||||
Function.identity(),
|
||||
(oldVal, newVal) -> newVal,
|
||||
LinkedHashMap::new
|
||||
));
|
||||
|
||||
responseMap.put(newResponse.getEmailScenario(), newResponse);
|
||||
|
||||
return new ArrayList<>(responseMap.values());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public interface ApplicationAmendmentRequestApi {
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "", produces = "application/json")
|
||||
ResponseEntity<Response<ApplicationAmendmentRequestResponse>> getApplicationAmendmentRequestById(HttpServletRequest request,@Parameter(description = "The application amendment id", required = true) @RequestParam(value = "id", required = true) Long id);
|
||||
ResponseEntity<Response<ApplicationAmendmentRequestResponseBean>> getApplicationAmendmentRequestById(HttpServletRequest request,@Parameter(description = "The application amendment id", required = true) @RequestParam(value = "id", required = true) Long id);
|
||||
|
||||
@Operation(summary = "Api to get all applications amendment request by preInstructor user Id (deprecated)",
|
||||
responses = {
|
||||
@@ -183,7 +183,7 @@ public interface ApplicationAmendmentRequestApi {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@PostMapping(value = "/{amendmentId}/reminder", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<Void>> sendReminderEmail(HttpServletRequest request,
|
||||
ResponseEntity<Response<EmailReminderResponse>> sendReminderEmail(HttpServletRequest request,
|
||||
@Parameter( required = true)
|
||||
@PathVariable(value = "amendmentId") Long amendmentId);
|
||||
|
||||
|
||||
@@ -238,6 +238,20 @@ public interface ApplicationApi {
|
||||
public ResponseEntity<byte[]> exportCsv(
|
||||
HttpServletRequest request, @Parameter(description = "The call id", required = true) @PathVariable(value = "callId", required = true) Long callId);
|
||||
|
||||
@Operation(summary = "Api to re-admit an application",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@PutMapping(value = "/{applicationId}/readmit", produces = { "application/json" })
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')|| hasRole('ROLE_INSTRUCTOR_MANAGER')|| hasRole('ROLE_PRE_INSTRUCTOR')")
|
||||
ResponseEntity<Response<ApplicationResponse>> readmitApplication(HttpServletRequest request,
|
||||
@Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface ApplicationEvaluationApi {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@GetMapping(value = "/application", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<ApplicationEvaluationResponse>> getApplicationEvaluationByApplicationId(
|
||||
ResponseEntity<Response<ApplicationEvaluationResponseBean>> getApplicationEvaluationByApplicationId(
|
||||
HttpServletRequest request,
|
||||
@Parameter(required = false) @RequestParam(value = "applicationId", required = false) Long applicationId,
|
||||
@Parameter( required = false) @RequestParam(value = "assignedApplicationId", required = false) Long assignedApplicationId);
|
||||
|
||||
@@ -159,7 +159,7 @@ public interface CallApi {
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = @ExampleObject(value =
|
||||
ErrorConstants.BADREQUEST_ERROR_EXAMPLE))) })
|
||||
@PostMapping(value = "/pagination", consumes = "application/json", produces = "application/json")
|
||||
ResponseEntity<Response<PageableResponseBean<List<CallDetailsResponseBean>>>> getAllCallsByPagination(HttpServletRequest request,@RequestParam(value = "companyId", required = false) Long companyId , @RequestParam(value = "onlyPreferredCall", required = false, defaultValue = "false") Boolean onlyPreferredCall, @RequestBody CallPageableRequestBean callPageableRequestBean);
|
||||
ResponseEntity<Response<PageableResponseBean<List<CallDetailsResponseBean>>>> getAllCallsByPagination(HttpServletRequest request,@RequestParam(value = "companyId", required = false) Long companyId , @RequestParam(value = "onlyPreferredCall", required = false, defaultValue = "false") Boolean onlyPreferredCall, @RequestParam(value = "onlyConfidiCall", required = false) Boolean onlyConfidiCall, @RequestBody CallPageableRequestBean callPageableRequestBean);
|
||||
|
||||
|
||||
@Operation(summary = "Api to update call step 2 (Evaluation V2)",
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.response.CallResponse;
|
||||
import net.gepafin.tendermanagement.model.response.EmailResendResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Validated
|
||||
public interface EmailApi {
|
||||
@Operation(summary = "Api to resend the email",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@PostMapping(value = "/resend", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<Response<EmailResendResponseBean>> resendEmail(
|
||||
HttpServletRequest request,
|
||||
@Parameter(description = "The User Action ID", required = true)
|
||||
@RequestParam("userActionId") Long userActionId);
|
||||
}
|
||||
@@ -10,10 +10,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.SummaryPageResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
@@ -121,8 +118,8 @@ public interface UserApi {
|
||||
@RequestMapping(value = "/reset-password/initiate",
|
||||
produces = {"application/json"},
|
||||
method = RequestMethod.POST)
|
||||
ResponseEntity<Response<Void>> initiatePasswordReset(HttpServletRequest request,
|
||||
@Parameter(description = "Initiate password reset request object", required = true) @Valid @RequestBody InitiatePasswordResetReq initiatePasswordResetReq);
|
||||
ResponseEntity<Response<InitiatePasswordResetResponse>> initiatePasswordReset(HttpServletRequest request,
|
||||
@Parameter(description = "Initiate password reset request object", required = true) @Valid @RequestBody InitiatePasswordResetReq initiatePasswordResetReq);
|
||||
|
||||
@Operation(summary = "Api to reset password",
|
||||
responses = {
|
||||
|
||||
@@ -8,10 +8,7 @@ import net.gepafin.tendermanagement.enums.ApplicationAmendmentRequestEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
|
||||
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestViewResponse;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.GetAllAmendmentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
@@ -72,14 +69,14 @@ public class ApplicationAmendmentRequestController implements ApplicationAmendme
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<ApplicationAmendmentRequestResponse>> getApplicationAmendmentRequestById(HttpServletRequest request,Long id) {
|
||||
public ResponseEntity<Response<ApplicationAmendmentRequestResponseBean>> getApplicationAmendmentRequestById(HttpServletRequest request,Long id) {
|
||||
log.info("Get Application Amendment Request By Id");
|
||||
|
||||
/** This code is responsible for creating user action logs for the "get application amendment by id" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW)
|
||||
.actionContext(UserActionContextEnum.GET_AMENDMENT).build());
|
||||
|
||||
ApplicationAmendmentRequestResponse applicationAmendmentRequestResponse = applicationAmendmentRequestService.getApplicationAmendmentRequestById(request,id);
|
||||
ApplicationAmendmentRequestResponseBean applicationAmendmentRequestResponse = applicationAmendmentRequestService.getApplicationAmendmentRequestById(request,id);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(applicationAmendmentRequestResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_AMENDMENT_SUCCESS_MSG)));
|
||||
}
|
||||
@@ -176,15 +173,25 @@ public class ApplicationAmendmentRequestController implements ApplicationAmendme
|
||||
.body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_UPDATE_SUCCESSFULLY_MSG)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> sendReminderEmail(
|
||||
public ResponseEntity<Response<EmailReminderResponse>> sendReminderEmail(
|
||||
HttpServletRequest request,
|
||||
Long amendmentId) {
|
||||
|
||||
log.info("Sending reminder email for Amendment ID: {}", amendmentId);
|
||||
applicationAmendmentRequestService.sendReminderEmail(request,amendmentId);
|
||||
|
||||
/** This code is responsible for "sending reminder email" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.EMAIL)
|
||||
.actionContext(UserActionContextEnum.SEND_REMINDER_EMAIL).build());
|
||||
|
||||
EmailReminderResponse emailSendResponse = applicationAmendmentRequestService.sendReminderEmail(request,amendmentId);
|
||||
|
||||
if (!emailSendResponse.getEmailSendResponse().getIsEmailSend()) {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(emailSendResponse, Status.EXCEPTION_ERROR, Translator.toLocale(GepafinConstant.REMINDER_EMAIL_FAILED_MSG)));
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.REMINDER_EMAIL_SENT_SUCCESS_MSG)));
|
||||
.body(new Response<>(emailSendResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.REMINDER_EMAIL_SENT_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -242,5 +242,16 @@ public class ApplicationApiController implements ApplicationApi {
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
.body(csvBytes);
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<Response<ApplicationResponse>> readmitApplication(HttpServletRequest request, Long applicationId) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "re-admit application" operation. **/
|
||||
loggingUtil.logUserAction(
|
||||
UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.UPDATE).actionContext(UserActionContextEnum.READMIT_APPLICATION).build());
|
||||
|
||||
ApplicationResponse applicationResponse = applicationService.readmitApplication(request, applicationId);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.READMIT_APPLICATION_SUCCESS)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<ApplicationEvaluationResponse>> getApplicationEvaluationByApplicationId(
|
||||
public ResponseEntity<Response<ApplicationEvaluationResponseBean>> getApplicationEvaluationByApplicationId(
|
||||
HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ApplicationEvaluationApiController implements ApplicationEvaluation
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_APPLICATION_EVALUATION).build());
|
||||
|
||||
|
||||
ApplicationEvaluationResponse response = null;
|
||||
ApplicationEvaluationResponseBean response = null;
|
||||
response = applicationEvaluationService.getApplicationEvaluationByApplicationId(request, applicationId,assignedApplicationId);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_FETCHED_SUCCESSFULLY)));
|
||||
|
||||
@@ -152,12 +152,12 @@ public class CallApiController implements CallApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<PageableResponseBean<List<CallDetailsResponseBean>>>> getAllCallsByPagination(HttpServletRequest request, Long companyId , Boolean onlyPreferredCall, CallPageableRequestBean callPageableRequestBean) {
|
||||
public ResponseEntity<Response<PageableResponseBean<List<CallDetailsResponseBean>>>> getAllCallsByPagination(HttpServletRequest request, Long companyId , Boolean onlyPreferredCall,Boolean onlyConfidiCall, CallPageableRequestBean callPageableRequestBean) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "get all call by pagination" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_ALL_CALL_BY_PAGINATION).build());
|
||||
|
||||
PageableResponseBean<List<CallDetailsResponseBean>> callsByPagination=callService.getAllCallsByPagination(request,companyId,onlyPreferredCall,callPageableRequestBean);
|
||||
PageableResponseBean<List<CallDetailsResponseBean>> callsByPagination=callService.getAllCallsByPagination(request,companyId,onlyPreferredCall,onlyConfidiCall,callPageableRequestBean);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(callsByPagination, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.EmailResendResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.ResendEmailService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.web.rest.api.EmailApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/email}")
|
||||
@Log4j2
|
||||
public class EmailApiController implements EmailApi {
|
||||
|
||||
@Autowired
|
||||
LoggingUtil loggingUtil;
|
||||
|
||||
@Autowired
|
||||
ResendEmailService emailService;
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<EmailResendResponseBean>> resendEmail(HttpServletRequest request, Long userActionId) {
|
||||
|
||||
/** This code is responsible for creating user action logs for the "Resend Email" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.INSERT)
|
||||
.actionContext(UserActionContextEnum.RESEND_EMAIL).build());
|
||||
|
||||
EmailResendResponseBean emailResendResponseBean = emailService.resendEmail(request, userActionId);
|
||||
|
||||
if (!emailResendResponseBean.getEmailSendResponse().getIsEmailSend()) {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(emailResendResponseBean, Status.EXCEPTION_ERROR, Translator.toLocale(GepafinConstant.RESEND_EMAIL_SENT_FAILED_MSG)));
|
||||
}
|
||||
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(emailResendResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.RESEND_EMAIL_SENT_SUCCESS_MSG)));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,7 @@ import net.gepafin.tendermanagement.enums.UserActionContextEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserActionLogsEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.PageableResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
@@ -135,16 +133,16 @@ public class UserApiController implements UserApi {
|
||||
return ResponseEntity.ok(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.SUCCESS_PASSWORD_CHANGED)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> initiatePasswordReset(HttpServletRequest httpServletRequest,InitiatePasswordResetReq request) {
|
||||
public ResponseEntity<Response<InitiatePasswordResetResponse>> initiatePasswordReset(HttpServletRequest httpServletRequest, InitiatePasswordResetReq request) {
|
||||
log.info("Initiating password reset for email: {}", request.getEmail());
|
||||
|
||||
/** This code is responsible for "Initiating Password Reset Request" operation. **/
|
||||
loggingUtil.logUserAction(UserActionRequest.builder().request(httpServletRequest).actionType(UserActionLogsEnum.UPDATE)
|
||||
.actionContext(UserActionContextEnum.INITIATE_PASSWORD_RESET_REQUEST).build());
|
||||
|
||||
userService.initiatePasswordReset(request);
|
||||
InitiatePasswordResetResponse emailSendResponse = userService.initiatePasswordReset(request);
|
||||
log.info("Password reset token generated for email: {}", request.getEmail());
|
||||
return ResponseEntity.ok(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.RESET_PASSWORD_INITIATED)));
|
||||
return ResponseEntity.ok(new Response<>(emailSendResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.RESET_PASSWORD_INITIATED)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2746,4 +2746,63 @@
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/update_system_email_template_28_04_2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="22-04-2025_PK_192400" author="Piyush Kag">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/update_json_template_for_notification_22_04_2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="24-04-2025_PK_121820" author="Piyush Kag">
|
||||
<addColumn tableName="email_log">
|
||||
<column name="user_action_id" type="INTEGER">
|
||||
<constraints foreignKeyName="fk_email_log_user_action" references="user_action(id)"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="30-04-2025_PK_125515" author="Piyush Kag">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/insert_system_email_template_for_application_submission_failure_30_04_2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="06-05-2025_PK_193412" author="Piyush Kag">
|
||||
<addColumn tableName="application_amendment_request">
|
||||
<column name="email_send_response" type="TEXT">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
|
||||
<addColumn tableName="application_evaluation">
|
||||
<column name="email_send_response" type="TEXT">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
|
||||
<addColumn tableName="gepafin_user">
|
||||
<column name="email_send_response" type="TEXT">
|
||||
<constraints nullable="true"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="07-05-2025_PK_195815" author="Piyush Kag">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/update_application_amendment_request_view.sql"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="07-05-2025_PK_201518" author="Piyush Kag">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/update_assigned_application_view.sql"/>
|
||||
</changeSet>
|
||||
|
||||
|
||||
<changeSet id="08-05-2025_PK_203515" author="Piyush Kag">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/update_system_email_template_for_application_submission_failure_08_05_2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="14-05-2025_NK_163815" author="Nisha Kashyap">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/update_assigned_application_view_14_5_2025.sql"/>
|
||||
</changeSet>
|
||||
</databaseChangeLog>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
INSERT INTO gepafin_schema.system_email_template (
|
||||
template_name,
|
||||
"type",
|
||||
html_content,
|
||||
subject,
|
||||
"json",
|
||||
"system",
|
||||
is_deleted,
|
||||
created_date,
|
||||
updated_date,
|
||||
email_scenario)
|
||||
VALUES (
|
||||
'Application submission failure notification',
|
||||
'APPLICATION_SUBMISSION_FAILURE_NOTIFICATION',
|
||||
'<html>
|
||||
<body style="font-family: Arial, sans-serif; color: #333; line-height: 1.6;">
|
||||
<div style="padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 650px; margin: auto;">
|
||||
<p>Buongiorno,</p>
|
||||
|
||||
<p>
|
||||
Si prega di notare che si è verificato un errore durante linvio dell email "{{scenario}}" per la chiamata: <strong>{{call_name}}</strong>. </p>
|
||||
<p>
|
||||
<strong>Dettagli:</strong><br/>
|
||||
- ID Applicazione: {{application_id}}<br/>
|
||||
- Nome Azienda: {{company_name}}<br/>
|
||||
- Numero Protocollo: {{protocol_number}}<br/>
|
||||
- ID Azione Utente: {{user_action_id}}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Si prega di effettuare i controlli appropriati e di adottare le misure correttive necessarie.
|
||||
</p>
|
||||
|
||||
<p>Cordiali saluti,</p>
|
||||
<p><strong>Gepafin S.p.a.</strong></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>',
|
||||
'ERRORE INVIO EMAIL - BANDO {{call_name}}',
|
||||
NULL,
|
||||
true,
|
||||
false,
|
||||
CURRENT_TIMESTAMP,
|
||||
CURRENT_TIMESTAMP,
|
||||
'APPLICATION_SUBMISSION_FAILURE'
|
||||
);
|
||||
@@ -0,0 +1,27 @@
|
||||
CREATE OR REPLACE VIEW application_amendment_request_view AS
|
||||
|
||||
SELECT a.id,
|
||||
a.application_id,
|
||||
p.protocol_number,
|
||||
cl.name AS call_name,
|
||||
c.company_name,
|
||||
a.start_date,
|
||||
a.end_date AS expiration_date,
|
||||
COALESCE(NULLIF(TRIM(BOTH FROM concat(COALESCE(u.first_name, ''), ' ', COALESCE(u.last_name, ''))), ''), '') AS assigned_user_name,
|
||||
aa.user_id AS assigned_user_id,
|
||||
a.status,
|
||||
a.note,
|
||||
a.internal_note,
|
||||
app.user_id AS application_user_id,
|
||||
a.created_date,
|
||||
a.updated_date,
|
||||
a.is_deleted,
|
||||
a.email_send_response
|
||||
FROM gepafin_schema.application_amendment_request a
|
||||
LEFT JOIN gepafin_schema.application app ON a.application_id = app.id AND (app.is_deleted IS FALSE OR app.is_deleted IS NULL)
|
||||
LEFT JOIN gepafin_schema.call cl ON app.call_id = cl.id
|
||||
LEFT JOIN gepafin_schema.company c ON app.company_id = c.id
|
||||
LEFT JOIN gepafin_schema.protocol p ON a.protocol_id = p.id
|
||||
LEFT JOIN gepafin_schema.assigned_applications aa ON app.id = aa.application_id AND (aa.is_deleted IS FALSE OR aa.is_deleted IS NULL)
|
||||
LEFT JOIN gepafin_schema.gepafin_user u ON aa.user_id = u.id
|
||||
WHERE a.is_deleted IS FALSE OR a.is_deleted IS NULL ORDER BY id;
|
||||
@@ -0,0 +1,53 @@
|
||||
CREATE OR REPLACE VIEW assigned_applications_view AS
|
||||
SELECT
|
||||
-- From assigned_applications
|
||||
aa.id AS id,
|
||||
aa.user_id AS user_id,
|
||||
aa.status AS status,
|
||||
aa.created_date AS created_date,
|
||||
aa.updated_date AS updated_date,
|
||||
aa.is_deleted AS is_deleted,
|
||||
|
||||
-- From application
|
||||
a.id AS application_id,
|
||||
a.status AS application_status,
|
||||
a.submission_date AS submission_date,
|
||||
ae.end_date AS evaluation_end_date,
|
||||
a.ndg AS ndg,
|
||||
a.appointment_id AS appointment_id,
|
||||
|
||||
-- From protocol (OneToOne)
|
||||
p.protocol_number AS protocol_number,
|
||||
|
||||
-- From call (ManyToOne)
|
||||
cl.name AS call_name,
|
||||
|
||||
-- From company (ManyToOne)
|
||||
c.company_name AS company_name,
|
||||
ae.email_send_response AS email_send_response
|
||||
|
||||
FROM gepafin_schema.assigned_applications aa
|
||||
|
||||
-- Join application (ManyToOne from assigned_applications)
|
||||
LEFT JOIN gepafin_schema.application a
|
||||
ON aa.application_id = a.id
|
||||
AND (a.is_deleted IS FALSE OR a.is_deleted IS NULL)
|
||||
|
||||
-- Join application_evaluation (application_id matches + not deleted)
|
||||
LEFT JOIN gepafin_schema.application_evaluation ae
|
||||
ON ae.application_id = a.id
|
||||
AND (ae.is_deleted IS FALSE OR ae.is_deleted IS NULL)
|
||||
|
||||
-- Join protocol (OneToOne from application)
|
||||
LEFT JOIN gepafin_schema.protocol p
|
||||
ON a.protocol_number = p.id
|
||||
|
||||
-- Join call (ManyToOne from application)
|
||||
LEFT JOIN gepafin_schema.call cl
|
||||
ON a.call_id = cl.id
|
||||
|
||||
-- Join company (ManyToOne from application)
|
||||
LEFT JOIN gepafin_schema.company c
|
||||
ON a.company_id = c.id
|
||||
|
||||
WHERE aa.is_deleted IS FALSE OR aa.is_deleted IS NULL;
|
||||
@@ -0,0 +1,57 @@
|
||||
|
||||
DROP VIEW IF EXISTS gepafin_schema.assigned_applications_view ;
|
||||
|
||||
CREATE OR REPLACE VIEW gepafin_schema.assigned_applications_view AS
|
||||
SELECT
|
||||
-- From assigned_applications
|
||||
aa.id AS id,
|
||||
aa.user_id AS user_id,
|
||||
aa.status AS status,
|
||||
aa.created_date AS created_date,
|
||||
aa.updated_date AS updated_date,
|
||||
aa.is_deleted AS is_deleted,
|
||||
|
||||
-- From application
|
||||
a.id AS application_id,
|
||||
a.hub_id as hub_id,
|
||||
a.status AS application_status,
|
||||
a.submission_date AS submission_date,
|
||||
ae.end_date AS evaluation_end_date,
|
||||
a.ndg AS ndg,
|
||||
a.appointment_id AS appointment_id,
|
||||
|
||||
-- From protocol (OneToOne)
|
||||
p.protocol_number AS protocol_number,
|
||||
|
||||
-- From call (ManyToOne)
|
||||
cl.name AS call_name,
|
||||
|
||||
-- From company (ManyToOne)
|
||||
c.company_name AS company_name,
|
||||
ae.email_send_response AS email_send_response
|
||||
|
||||
FROM gepafin_schema.assigned_applications aa
|
||||
|
||||
-- Join application (ManyToOne from assigned_applications)
|
||||
LEFT JOIN gepafin_schema.application a
|
||||
ON aa.application_id = a.id
|
||||
AND (a.is_deleted IS FALSE OR a.is_deleted IS NULL)
|
||||
|
||||
-- Join application_evaluation (application_id matches + not deleted)
|
||||
LEFT JOIN gepafin_schema.application_evaluation ae
|
||||
ON ae.application_id = a.id
|
||||
AND (ae.is_deleted IS FALSE OR ae.is_deleted IS NULL)
|
||||
|
||||
-- Join protocol (OneToOne from application)
|
||||
LEFT JOIN gepafin_schema.protocol p
|
||||
ON a.protocol_number = p.id
|
||||
|
||||
-- Join call (ManyToOne from application)
|
||||
LEFT JOIN gepafin_schema.call cl
|
||||
ON a.call_id = cl.id
|
||||
|
||||
-- Join company (ManyToOne from application)
|
||||
LEFT JOIN gepafin_schema.company c
|
||||
ON a.company_id = c.id
|
||||
|
||||
WHERE aa.is_deleted IS FALSE OR aa.is_deleted IS NULL;
|
||||
@@ -0,0 +1,9 @@
|
||||
INSERT INTO notification_type (notification_name, title, json_template, created_date, updated_date, is_deleted)
|
||||
VALUES
|
||||
('PEC_EMAIL_SENDING_FAILURE',
|
||||
'Invio Email Fallito',
|
||||
'Non è stato possibile inviare lemail per lo scenario: {{email_scenario}}.',
|
||||
'2025-01-03T10:16:26.472Z',
|
||||
'2025-01-03T10:16:26.472Z',
|
||||
'false'
|
||||
);
|
||||
@@ -0,0 +1,29 @@
|
||||
UPDATE gepafin_schema.system_email_template
|
||||
SET html_content = '<html>
|
||||
<body style="font-family: Arial, sans-serif; color: #333; line-height: 1.6;">
|
||||
<div style="padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 650px; margin: auto;">
|
||||
<p>Buongiorno,</p>
|
||||
|
||||
<p>
|
||||
<p>
|
||||
Si prega di notare che si è verificato un errore durante linvio dell e-mail nello scenario "{{scenario}}" per la chiamata: <strong>{{call_name}}</strong>.
|
||||
</p>
|
||||
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Dettagli:</strong><br/>
|
||||
- ID Applicazione: {{application_id}}<br/>
|
||||
- Nome Azienda: {{company_name}}<br/>
|
||||
- Numero Protocollo: {{protocol_number}}<br/>
|
||||
- ID Azione Utente: {{user_action_id}}
|
||||
</p>
|
||||
|
||||
<p>Si prega di effettuare i controlli appropriati e di adottare le misure correttive necessarie.</p>
|
||||
|
||||
<p>Cordiali saluti,</p>
|
||||
<p><strong>Gepafin S.p.a.</strong></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>'
|
||||
WHERE template_name = 'Application submission failure notification';
|
||||
@@ -400,3 +400,11 @@ insufficient.score.msg = Insufficient score to pass to the technical and economi
|
||||
|
||||
password.expired.for.login.to.odessa = Odessa login password has been expired.
|
||||
invalid.user=Invalid user.
|
||||
|
||||
reminder.email.sent.failed.msg = Failed to send reminder email
|
||||
resend.email.sent.success.msg = Email resend successfully
|
||||
resend.email.sent.failed.msg = Failed to resend the email.
|
||||
|
||||
application.readmit.success=Application has been readmitted successfully.
|
||||
no.email.log.msg = No failed emails found for given userActionId.
|
||||
user.action.id.not.found = User Action id not found.
|
||||
|
||||
@@ -53,7 +53,7 @@ call.update.successfully=Chiamata aggiornata con successo.
|
||||
call.fetch.success=Dettagli della chiamata recuperati con successo.
|
||||
call.not.found=Chiamata non trovata.
|
||||
score.not.null=Il punteggio non pu? essere nullo o zero.
|
||||
field.not.null={0} non può essere vuoto.
|
||||
field.not.null={0} non pu<EFBFBD> essere vuoto.
|
||||
field.not.empty=la {0} non pu? essere vuota.
|
||||
update_call_status_success_msg=Lo stato della chiamata ? stato aggiornato con successo.
|
||||
status.same.error=Lo stato ? gi? impostato.
|
||||
@@ -389,5 +389,13 @@ error.invalid.limit=Il limite dovrebbe essere compreso tra 1 e 3000.
|
||||
insufficient.score.msg = Punteggio non sufficiente per passaggio alla valutazione tecnica ed economico finanziaria
|
||||
validation.table.message=I dati per il campo {0} non sono presenti.
|
||||
|
||||
password.expired.for.login.to.odessa = La password di accesso a Odessa è scaduta
|
||||
invalid.user=Utente non valido.
|
||||
password.expired.for.login.to.odessa = La password di accesso a Odessa <EFBFBD> scaduta
|
||||
invalid.user=Utente non valido.
|
||||
|
||||
reminder.email.sent.failed.msg = Impossibile inviare l'e-mail di promemoria
|
||||
resend.email.sent.success.msg = Email reinviata con successo
|
||||
resend.email.sent.failed.msg = Impossibile inviare nuovamente l'e-mail.
|
||||
|
||||
application.readmit.success=L'applicazione è stata riammessa con successo.
|
||||
no.email.log.msg = Nessuna email trovata per userActionId specificato.
|
||||
user.action.id.not.found = ID azione utente non trovato.
|
||||
|
||||
Reference in New Issue
Block a user