Resolved Conflicts
This commit is contained in:
24
pom.xml
24
pom.xml
@@ -251,6 +251,24 @@
|
||||
<version>0.4.8</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-csv</artifactId>
|
||||
<version>1.10.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Jakarta email support -->
|
||||
<!-- https://jakarta.ee/specifications/mail/ -->
|
||||
<!-- https://github.com/jakartaee/mail-api -->
|
||||
<!-- https://mvnrepository.com/artifact/jakarta.mail/jakarta.mail-api -->
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>jakarta.mail</artifactId>
|
||||
<version>2.0.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
@@ -271,8 +289,8 @@
|
||||
<artifactId>liquibase-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<propertyFile>src/main/resources/application.properties</propertyFile>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -510,10 +510,67 @@ public class GepafinConstant {
|
||||
public static final String APPLICATION_USER_ID="applicationUserId";
|
||||
public static final String INVALID_USER_ID="invalid.user";
|
||||
public static final String COMPANY_NAME="companyName";
|
||||
public static final String TABLE_COLUMNS="table_columns";
|
||||
public static final String PREDEFINED="predefined";
|
||||
public static final String EBABLE_CSV="enableCsv";
|
||||
public static final String LABEL_CSV="labelCsv";
|
||||
public static final String GET="get";
|
||||
public static final String REPORT_COLUMNS="reportColumns";
|
||||
public static final String FIELD_TYPE="fieldtype";
|
||||
public static final String ENABLE_FORMULA="enableFormula";
|
||||
public static final String STATE_FIELD_DATA="stateFieldData";
|
||||
public static final String REPORT_ENABLE="reportEnable";
|
||||
public static final String TABLE="table";
|
||||
public static final String GET_FIELD_TYPE="getFieldType";
|
||||
public static final String GET_APPLICATION_FORM_ID="getApplicationFormId";
|
||||
public static final String GET_APPLICATION_ID="getApplicationId";
|
||||
public static final String GET_ID="getId";
|
||||
public static final String GET_CLASS="getClass";
|
||||
public static final String GET_FORM_ID="getFormId";
|
||||
public static final String GET_FIELD_ID="getFieldId";
|
||||
public static final String GET_FIELD_LABEL="getFieldLabel";
|
||||
public static final String GET_FIELD_VALUE="getFieldValue";
|
||||
public static final String GET_REPORT_ENABLE="getReportEnable";
|
||||
public static final String GET_REPORT_HEADER="getReportHeader";
|
||||
|
||||
public static final String APPOINTMENT_ID="appointmentId";
|
||||
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";
|
||||
public static final String PROTOCOL_SERVICE_URL="http://65.108.55.96:8080";
|
||||
public static final String PROTOCOL_SERVICE_BEARER_TOKEN="/auth/login";
|
||||
public static final String PROTOCOL_SERVICE_CREATE_PROTOCOL="/documenti/protocollaUD";
|
||||
public static final String PROTOCOL_CALL_NAME="BANDO";
|
||||
public static final String PROTOCOL_DOC_URL="DOC_URL";
|
||||
public static final String PROTOCOL_COMPANY_NAME_VAT_NUMBER="OGGETTO_PG";
|
||||
public static final String PROTOCOL_DOC_HASH="URL_CONTENT_HASH";
|
||||
public static final String PROTOCOL_TIPO_PROTOCOLLAZIONE="TIPO_PROTOCOLLAZIONE";
|
||||
public static final String PROTOCOL_TIPO_CORRISPONDENTE_COMPANY="tipoCorrispondente";
|
||||
public static final String PROTOCOL_COMPANY_NAME="denominazione";
|
||||
public static final String PROTOCOL_MEZZO="mezzo";
|
||||
public static final String PROTOCOL_INDIRIZZO_PEC="indirizzoPec";
|
||||
public static final String PROTOCOL_COMPANY_VAT_NUMBER="identificativo";
|
||||
public static final String PROTOCOL_CODICE_UO="codiceUo";
|
||||
public static final String PROTOCOL_COMPETENTE="competente";
|
||||
public static final String PROTOCOL_TIPO_CORRISPONDENTE="tipoCorrispondente";
|
||||
public static final String PROTOCOL_MITTENTE="mittente";
|
||||
public static final String PROTOCOL_DESTINATARI="destinatari";
|
||||
public static final String PROTOCOL_EXTERNAL_YEAR="ANNO_PG";
|
||||
public static final String PROTOCOL_EXTERNAL_NUMBER="";
|
||||
public static final String PROTOCOL_EXTERNAL_DATE="";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -26,6 +27,7 @@ import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundExceptio
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -140,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 +309,15 @@ 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);
|
||||
List<EmailSendResponse> responses = List.of(emailSendResponse);
|
||||
if (!Boolean.TRUE.equals(emailSendResponse.getIsEmailSend())){
|
||||
saveEmailSendResponse(emailSendResponse, applicationAmendmentRequestEntity);
|
||||
applicationAmendmentRequestResponse.setEmailSendResponse(responses);
|
||||
}
|
||||
else{
|
||||
applicationAmendmentRequestResponse.setEmailSendResponse(Collections.emptyList());
|
||||
}
|
||||
}
|
||||
return applicationAmendmentRequestResponse;
|
||||
}
|
||||
@@ -361,6 +378,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(
|
||||
applicationEvaluationEntity.getAssignedApplicationsEntity().getApplication(), protocolNumber,
|
||||
userEntity.getHub().getId(),false);
|
||||
protocolDao.saveProtocolEntity(protocolEntity);
|
||||
applicationAmendmentRequestEntity.setProtocol(protocolEntity);
|
||||
ApplicationAmendmentRequestEntity applicationAmendment = saveApplicationAmendmentRequestEntity(applicationAmendmentRequestEntity, null, VersionActionTypeEnum.INSERT);
|
||||
log.info("Amendment request saved with ID={}", applicationAmendment.getId());
|
||||
@@ -510,6 +528,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
Long hubId = applicationEntity.getHubId();
|
||||
HubEntity hubEntity = hubService.valdateHub(hubId);
|
||||
|
||||
response.setEmailSendResponse(entity.getEmailSendResponse());
|
||||
response.setId(entity.getId());
|
||||
response.setApplicationId(entity.getApplicationId());
|
||||
response.setApplicationEvaluationId(entity.getApplicationEvaluationEntity().getId());
|
||||
@@ -651,9 +670,9 @@ public class ApplicationAmendmentRequestDao {
|
||||
public ApplicationAmendmentRequestResponse 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 response = convertEntityToResponse(applicationAmendmentRequestEntity,true);
|
||||
response.setEmailSendResponse(applicationAmendmentRequestEntity.getEmailSendResponse());
|
||||
return response;
|
||||
}
|
||||
|
||||
public List<GetAllAmendmentResponseBean> getAllApplicationAmendmentRequest(HttpServletRequest request, Long userId) {
|
||||
@@ -1043,7 +1062,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
public ApplicationAmendmentRequestResponse closeAmendmentRequest(Long id, CloseAmendmentRequest closeAmendmentRequest) {
|
||||
|
||||
log.info("Closing application amendement with ID: {}", id);
|
||||
ApplicationAmendmentRequestEntity existingApplicationAmendment = validateApplicationAmendmentRequest(id);
|
||||
ApplicationAmendmentRequestEntity existingApplicationAmendment = validatApplicationAmendmentRequestByListStatus(id,List.of(ApplicationAmendmentRequestEnum.AWAITING.getValue(),ApplicationAmendmentRequestEnum.RESPONSE_RECEIVED.getValue()));
|
||||
//cloned entity for old data and versioning
|
||||
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(existingApplicationAmendment);
|
||||
List<ApplicationAmendmentRequestEntity> amendmentRequestList = applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(
|
||||
@@ -1055,17 +1074,18 @@ public class ApplicationAmendmentRequestDao {
|
||||
// Check if this is the last amendment being closed
|
||||
boolean isLastRemaining = amendmentRequestList.stream()
|
||||
.filter(amendment -> !amendment.getId().equals(id)) // Exclude the current amendment
|
||||
.allMatch(amendment -> amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()));
|
||||
.allMatch(amendment -> amendment.getStatus().equals(ApplicationAmendmentRequestEnum.CLOSE.getValue()) || amendment.getStatus().equals(ApplicationAmendmentRequestEnum.EXPIRED.getValue()));
|
||||
|
||||
|
||||
if (isLastRemaining) {
|
||||
log.info("The current amendment is the last remaining one to be closed.");
|
||||
applicationAmendmentRequestDao.calculateEndDateAndSuspensionDays(existingApplicationAmendment.getApplicationEvaluationEntity());
|
||||
}
|
||||
setIfUpdated(existingApplicationAmendment::getInternalNote, existingApplicationAmendment::setInternalNote, closeAmendmentRequest.getInternalNote());
|
||||
setIfUpdated(existingApplicationAmendment::getStatus, existingApplicationAmendment::setStatus, ApplicationAmendmentRequestEnum.CLOSE.getValue());
|
||||
existingApplicationAmendment.setClosingDate(LocalDateTime.now());
|
||||
ApplicationAmendmentRequestEntity updatedApplicationAmendment = saveApplicationAmendmentRequestEntity(existingApplicationAmendment, oldApplicationAmendmentEntity,
|
||||
VersionActionTypeEnum.UPDATE);
|
||||
if (isLastRemaining) {
|
||||
log.info("The current amendment is the last remaining one to be closed.");
|
||||
applicationAmendmentRequestDao.calculateEndDateAndSuspensionDaysOnExpirationOrClosing(existingApplicationAmendment.getApplicationEvaluationEntity());
|
||||
}
|
||||
ApplicationAmendmentRequestResponse response = convertEntityToResponse(updatedApplicationAmendment,false);
|
||||
|
||||
log.info("Updated amendment status to CLOSE for amendment ID: {}", id);
|
||||
@@ -1095,6 +1115,8 @@ public class ApplicationAmendmentRequestDao {
|
||||
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getId());
|
||||
|
||||
AssignedApplicationsEntity oldAssignedApplicationData = Utils.getClonedEntityForData(assignedApplicationsEntity);
|
||||
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().setStatus(AssignedApplicationEnum.OPEN.getValue());
|
||||
|
||||
assignedApplicationsEntity = assignedApplicationsRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity());
|
||||
log.info("Updated AssignedApplication status to OPEN for ID: {}", assignedApplicationsEntity.getId());
|
||||
|
||||
@@ -1121,16 +1143,18 @@ public class ApplicationAmendmentRequestDao {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public ApplicationAmendmentRequestResponse extendResponseDays(Long id, Long newResponseDays) {
|
||||
log.info("Extending response days for Application Amendment ID: {}, Additional Days: {}", id, newResponseDays);
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = validateApplicationAmendmentRequest(id);
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = validatApplicationAmendmentRequestByStatus(id,ApplicationAmendmentRequestEnum.EXPIRED.getValue());
|
||||
|
||||
if (newResponseDays != null && newResponseDays > 0) {
|
||||
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(applicationAmendmentRequestEntity);
|
||||
ApplicationAmendmentRequestEntity oldApplicationAmendmentEntity = Utils.getClonedEntityForData(applicationAmendmentRequestEntity);
|
||||
Long currentResponseDays = applicationAmendmentRequestEntity.getResponseDays() != null ? applicationAmendmentRequestEntity.getResponseDays() : 0L;
|
||||
applicationAmendmentRequestEntity.setResponseDays(currentResponseDays + newResponseDays);
|
||||
applicationAmendmentRequestEntity.setEndDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now().plusDays(applicationAmendmentRequestEntity.getResponseDays())));
|
||||
applicationAmendmentRequestEntity.setEndDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now().plusDays(newResponseDays)));
|
||||
applicationAmendmentRequestEntity.setStatus(ApplicationAmendmentRequestEnum.AWAITING.getValue());
|
||||
applicationAmendmentRequestEntity.getApplicationEvaluationEntity().setStatus(ApplicationEvaluationStatusTypeEnum.SOCCORSO.getValue());
|
||||
applicationAmendmentRequestEntity.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getApplication().setStatus(ApplicationStatusTypeEnum.SOCCORSO.getValue());
|
||||
applicationAmendmentRequestRepository.save(applicationAmendmentRequestEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "Update Application Amendment" operation. **/
|
||||
@@ -1187,7 +1211,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void sendReminderEmail(Long amendmentId) {
|
||||
public EmailReminderResponse sendReminderEmail(Long amendmentId) {
|
||||
log.info("Initiating reminder email process for Amendment ID: {}", amendmentId);
|
||||
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(amendmentId)
|
||||
.orElseThrow(() -> { log.error("Amendment not found with ID: {}", amendmentId);
|
||||
@@ -1195,6 +1219,7 @@ public class ApplicationAmendmentRequestDao {
|
||||
});
|
||||
|
||||
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());
|
||||
@@ -1208,12 +1233,22 @@ 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);
|
||||
List<EmailSendResponse> responses = List.of(emailSendResponse);
|
||||
if (!Boolean.TRUE.equals(emailSendResponse.getIsEmailSend())){
|
||||
emailReminderResponse.setEmailSendResponse(responses);
|
||||
saveEmailSendResponse(emailSendResponse, amendment);
|
||||
}
|
||||
else{
|
||||
emailReminderResponse.setEmailSendResponse(Collections.emptyList());
|
||||
}
|
||||
log.info("Reminder email sent successfully for Amendment ID: {}", amendmentId);
|
||||
} else {
|
||||
log.warn("Beneficiary email not found or isEmail flag is false for Amendment ID: {}", amendmentId);
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.BENEFICIARY_EMAIL_NOT_FOUND_MSG));
|
||||
}
|
||||
}
|
||||
return emailReminderResponse;
|
||||
}
|
||||
|
||||
private String prepareSubject(SystemEmailTemplateResponse template, ApplicationAmendmentRequestEntity amendment, UserEntity beneficiary) {
|
||||
@@ -1243,29 +1278,26 @@ public class ApplicationAmendmentRequestDao {
|
||||
return Utils.replacePlaceholders(template.getHtmlContent(), bodyPlaceholders);
|
||||
}
|
||||
|
||||
public ApplicationEvaluationEntity calculateEndDateAndSuspensionDays(ApplicationEvaluationEntity applicationEvaluationEntity){
|
||||
log.info("Calculating end date and suspension days for Application Evaluation ID: {}", applicationEvaluationEntity.getId());
|
||||
LocalDateTime currentDate=DateTimeUtil.DateServerToUTC(LocalDateTime.now());
|
||||
LocalDateTime endDate=currentDate.plusDays(applicationEvaluationEntity.getRemainingDays());
|
||||
Long suspendedDays = ChronoUnit.DAYS.between(applicationEvaluationEntity.getStopDateTime(), currentDate);
|
||||
|
||||
ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(applicationEvaluationEntity);
|
||||
applicationEvaluationEntity.setEndDate(endDate);
|
||||
if(applicationEvaluationEntity.getSuspendedDays() == null) {
|
||||
applicationEvaluationEntity.setSuspendedDays(0L);
|
||||
}
|
||||
applicationEvaluationEntity.setSuspendedDays(applicationEvaluationEntity.getSuspendedDays()+suspendedDays);
|
||||
log.debug("Updated suspended days: {}", applicationEvaluationEntity.getSuspendedDays());
|
||||
ApplicationEvaluationEntity applicationEvaluation = applicationEvaluationRepository.save(applicationEvaluationEntity);
|
||||
|
||||
log.info("Application Evaluation updated successfully. ID: {}", applicationEvaluation.getId());
|
||||
/** This code is responsible for adding a version history log for the "Update Application Amendment" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluationEntity).newData(applicationEvaluation).build());
|
||||
|
||||
return applicationEvaluation;
|
||||
|
||||
|
||||
}
|
||||
// public ApplicationEvaluationEntity calculateEndDateAndSuspensionDays(ApplicationEvaluationEntity applicationEvaluationEntity){
|
||||
// LocalDateTime currentDate=DateTimeUtil.DateServerToUTC(LocalDateTime.now());
|
||||
// LocalDateTime endDate=currentDate.plusDays(applicationEvaluationEntity.getRemainingDays());
|
||||
// Long suspendedDays = ChronoUnit.DAYS.between(applicationEvaluationEntity.getStopDateTime(), currentDate);
|
||||
//
|
||||
// ApplicationEvaluationEntity oldApplicationEvaluationEntity = Utils.getClonedEntityForData(applicationEvaluationEntity);
|
||||
// applicationEvaluationEntity.setEndDate(endDate);
|
||||
// if(applicationEvaluationEntity.getSuspendedDays() == null) {
|
||||
// applicationEvaluationEntity.setSuspendedDays(0L);
|
||||
// }
|
||||
// applicationEvaluationEntity.setSuspendedDays(applicationEvaluationEntity.getSuspendedDays()+suspendedDays);
|
||||
// ApplicationEvaluationEntity applicationEvaluation = applicationEvaluationRepository.save(applicationEvaluationEntity);
|
||||
//
|
||||
// /** This code is responsible for adding a version history log for the "Update Application Amendment" operation. **/
|
||||
// loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEvaluationEntity).newData(applicationEvaluation).build());
|
||||
//
|
||||
// return applicationEvaluation;
|
||||
//
|
||||
//
|
||||
// }
|
||||
|
||||
private GetAllAmendmentResponseBean initializeGetAllBasicResponse(ApplicationAmendmentRequestEntity entity) {
|
||||
GetAllAmendmentResponseBean response = new GetAllAmendmentResponseBean();
|
||||
@@ -1572,8 +1604,111 @@ public class ApplicationAmendmentRequestDao {
|
||||
applicationAmendmentRequestViewResponse.setExpirationDate(applicationAmendmentRequestView.getExpirationDate());
|
||||
applicationAmendmentRequestViewResponse.setAssigendUserName(applicationAmendmentRequestView.getAssigendUserName());
|
||||
applicationAmendmentRequestViewResponse.setStatus(applicationAmendmentRequestView.getStatus());
|
||||
applicationAmendmentRequestViewResponse.setEmailSendResponse(applicationAmendmentRequestView.getEmailSendResponse());
|
||||
return applicationAmendmentRequestViewResponse;
|
||||
}
|
||||
|
||||
public ApplicationEvaluationEntity calculateEndDateAndSuspensionDaysOnExpirationOrClosing
|
||||
(ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||
|
||||
|
||||
// Fetch all linked amendments
|
||||
List<ApplicationAmendmentRequestEntity> amendments =
|
||||
applicationAmendmentRequestRepository.findAllByApplicationEvaluationIdAndIsDeletedFalse(applicationEvaluationEntity.getId());
|
||||
|
||||
// Recalculate suspension
|
||||
long suspendedDays = calculateSuspendedDays(amendments);
|
||||
|
||||
// Update end date and save
|
||||
|
||||
ApplicationEvaluationEntity oldEntity = Utils.getClonedEntityForData(applicationEvaluationEntity);
|
||||
HubEntity hub = hubService.valdateHub(applicationEvaluationEntity.getAssignedApplicationsEntity().getApplication().getHubId());
|
||||
Long initialDays = (hub != null) ? hub.getEvaluationExpirationDays() : 30L;
|
||||
LocalDateTime endDate = applicationEvaluationEntity.getStartDate().plusDays(suspendedDays+initialDays);
|
||||
applicationEvaluationEntity.setEndDate(endDate);
|
||||
applicationEvaluationEntity.setSuspendedDays(suspendedDays);
|
||||
ApplicationEvaluationEntity updated = applicationEvaluationRepository.save(applicationEvaluationEntity);
|
||||
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder()
|
||||
.request(request)
|
||||
.actionType(VersionActionTypeEnum.UPDATE)
|
||||
.oldData(oldEntity)
|
||||
.newData(updated)
|
||||
.build());
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
public long calculateSuspendedDays(List<ApplicationAmendmentRequestEntity> amendments) {
|
||||
List<Pair<LocalDateTime, LocalDateTime>> periods = amendments.stream()
|
||||
.filter(amendmentRequest -> amendmentRequest.getStartDate() != null)
|
||||
.map(amendmentRequest -> {
|
||||
LocalDateTime start = amendmentRequest.getStartDate();
|
||||
LocalDateTime end;
|
||||
|
||||
String status = amendmentRequest.getStatus();
|
||||
if (Boolean.TRUE.equals(ApplicationAmendmentRequestEnum.CLOSE.getValue().equals(status)) && amendmentRequest.getClosingDate() != null) {
|
||||
end = amendmentRequest.getClosingDate();
|
||||
} else if (Boolean.TRUE.equals(ApplicationAmendmentRequestEnum.EXPIRED.getValue().equals(status)) && amendmentRequest.getEndDate() != null) {
|
||||
end = amendmentRequest.getStartDate().plusDays(amendmentRequest.getResponseDays());
|
||||
}else {
|
||||
end= amendmentRequest.getEndDate();
|
||||
}
|
||||
|
||||
return Pair.of(start, end);
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.sorted(Comparator.comparing(Pair::getLeft))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
long totalDays = 0;
|
||||
LocalDateTime currentStart = null;
|
||||
LocalDateTime currentEnd = null;
|
||||
|
||||
for (Pair<LocalDateTime, LocalDateTime> period : periods) {
|
||||
if (currentStart == null) {
|
||||
currentStart = period.getLeft();
|
||||
currentEnd = period.getRight();
|
||||
} else if (!period.getLeft().isAfter(currentEnd)) {
|
||||
// Merge overlapping/touching periods
|
||||
currentEnd = currentEnd.isAfter(period.getRight()) ? currentEnd : period.getRight();
|
||||
} else {
|
||||
// Non-overlapping: count previous period
|
||||
totalDays += ChronoUnit.DAYS.between(currentStart.toLocalDate(), currentEnd.toLocalDate());
|
||||
currentStart = period.getLeft();
|
||||
currentEnd = period.getRight();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentStart != null && currentEnd != null) {
|
||||
totalDays += ChronoUnit.DAYS.between(currentStart.toLocalDate(), currentEnd.toLocalDate());
|
||||
}
|
||||
|
||||
return totalDays;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
return applicationAmendmentRequestEntity;
|
||||
}
|
||||
private void saveEmailSendResponse(EmailSendResponse newResponses, ApplicationAmendmentRequestEntity amendment) {
|
||||
List<EmailSendResponse> mergedResponses = Utils.mergeEmailSendResponses(amendment.getEmailSendResponse(), newResponses);
|
||||
|
||||
amendment.setEmailSendResponse(mergedResponses);
|
||||
applicationAmendmentRequestRepository.save(amendment);
|
||||
}
|
||||
public ApplicationAmendmentRequestEntity validatApplicationAmendmentRequestByListStatus(Long id,List<String> status) {
|
||||
ApplicationAmendmentRequestEntity applicationAmendmentRequestEntity = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalseAndStatusIn(id, status);
|
||||
if (applicationAmendmentRequestEntity == null) {
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG));
|
||||
}
|
||||
return applicationAmendmentRequestEntity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.itextpdf.text.BaseColor;
|
||||
import com.itextpdf.text.Font;
|
||||
import com.itextpdf.text.FontFactory;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.persistence.criteria.*;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
@@ -23,15 +28,14 @@ import net.gepafin.tendermanagement.service.FormService;
|
||||
import net.gepafin.tendermanagement.service.HubService;
|
||||
import net.gepafin.tendermanagement.service.SystemEmailTemplatesService;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.FieldValidator;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.util.*;
|
||||
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.apache.commons.csv.CSVFormat;
|
||||
import org.apache.commons.csv.CSVPrinter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.h2.util.IOUtils;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
@@ -49,17 +53,17 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -69,7 +73,6 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
import static org.hibernate.validator.internal.engine.messageinterpolation.el.RootResolver.FORMATTER;
|
||||
|
||||
@Component
|
||||
public class ApplicationDao {
|
||||
@@ -133,6 +136,9 @@ public class ApplicationDao {
|
||||
@Value("${call.id}")
|
||||
private String callId;
|
||||
|
||||
@Value("${sviluppumbriaUuid}")
|
||||
private String sviluppumbriaUuid;
|
||||
|
||||
@Autowired
|
||||
private AmazonS3Service amazonS3Service;
|
||||
|
||||
@@ -196,6 +202,16 @@ public class ApplicationDao {
|
||||
@Autowired
|
||||
private ApplicationViewRepository applicationViewRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationFormViewRepository applicationFormViewRepository;
|
||||
|
||||
@Autowired
|
||||
private FormRepository formRepository;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEvaluationDao applicationEvaluationDao;
|
||||
|
||||
public final Random random = new Random();
|
||||
|
||||
public ApplicationResponseBean createApplication(HttpServletRequest request, ApplicationRequestBean applicationRequestBean, Long formId, Long applicationId) {
|
||||
log.info("Starting createApplication: formId={}, applicationId={}", formId, applicationId);
|
||||
@@ -952,16 +968,20 @@ public class ApplicationDao {
|
||||
}
|
||||
}
|
||||
|
||||
public String generateRandomFiveDigitNumber() {
|
||||
int number = 10000 + random.nextInt(90000); // Generates a number from 10000 to 99999
|
||||
return String.valueOf(number);
|
||||
}
|
||||
|
||||
public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) {
|
||||
|
||||
log.info("Updating status for Application id : " + applicationId);
|
||||
ApplicationEntity applicationEntity = validateApplication(applicationId);
|
||||
checkCallEndDate(applicationEntity.getCall());
|
||||
|
||||
log.info("Call end date verified successfully | callId: {}", applicationEntity.getCall().getId());
|
||||
//cloned entity for old application data
|
||||
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity);
|
||||
|
||||
HubEntity hub=hubService.valdateHub(applicationEntity.getHubId());
|
||||
UserEntity userEntity = userService.validateUser(applicationEntity.getUserId());
|
||||
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
|
||||
if (ApplicationStatusTypeEnum.SUBMIT.getValue().equals(applicationEntity.getStatus())) {
|
||||
@@ -973,11 +993,25 @@ public class ApplicationDao {
|
||||
log.warn("Requested status is the same as current status | applicationId: {}, status: {}", applicationId, status);
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_ALREADY_IN_PREVIOUS_STATUS));
|
||||
}
|
||||
|
||||
if (status.equals(ApplicationStatusTypeEnum.APPOINTMENT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.NDG.getValue()))){
|
||||
String appointmentId = generateRandomFiveDigitNumber();
|
||||
applicationEntity.setAppointmentId(appointmentId);
|
||||
applicationEntity.setStatus(ApplicationStatusTypeEnum.APPOINTMENT.getValue());
|
||||
}
|
||||
|
||||
if (status.equals(ApplicationStatusTypeEnum.SUBMIT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.READY.getValue()))) {
|
||||
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
|
||||
// callService.validatePublishedCall(applicationEntity.getCall().getId(), userEntity.getHub().getId());
|
||||
checkCallEndDate(applicationEntity.getCall());
|
||||
Long protocolNumber = protocolDao.getProtocolNumber(userEntity.getHub());
|
||||
ProtocolEntity protocolEntity = protocolDao.createProtocolEntity(applicationEntity, protocolNumber, userEntity.getHub().getId(),true);
|
||||
protocolDao.saveProtocolEntity(protocolEntity);
|
||||
applicationEntity.setProtocol(protocolEntity);
|
||||
if(Boolean.TRUE.equals(hub.getUniqueUuid().equals(sviluppumbriaUuid))) {
|
||||
protocolEntity = protocolDao.createExternalProtocol(applicationEntity, company, protocolEntity);
|
||||
}
|
||||
applicationEntity.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue());
|
||||
applicationEntity.setSubmissionDate(protocolEntity.getCreatedDate());
|
||||
applicationEntity = applicationRepository.save(applicationEntity);
|
||||
@@ -988,16 +1022,18 @@ public class ApplicationDao {
|
||||
loggingUtil.addVersionHistory(
|
||||
VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.UPDATE).oldData(oldApplicationEntity).newData(applicationEntity).build());
|
||||
|
||||
sendMailToUserAndCompany(userEntity, applicationEntity);
|
||||
sendMailToUserAndCompany(userEntity, applicationEntity,company);
|
||||
sendMailTodefaultSystemAndGepafin(userEntity, applicationEntity);
|
||||
applicationEntity.setStatus(status.getValue());
|
||||
log.info("Status updated to SUBMIT for applicationId: " + applicationId);
|
||||
}
|
||||
if (status.equals(ApplicationStatusTypeEnum.DRAFT) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.AWAITING.getValue()))) {
|
||||
checkCallEndDate(applicationEntity.getCall());
|
||||
applicationEntity.setStatus(status.getValue());
|
||||
log.info("Status updated to DRAFT for applicationId: " + applicationId);
|
||||
}
|
||||
if (status.equals(ApplicationStatusTypeEnum.AWAITING) && Boolean.TRUE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.READY.getValue()))) {
|
||||
checkCallEndDate(applicationEntity.getCall());
|
||||
ApplicationSignedDocumentEntity applicationSignedDocument = applicationSignedDocumentRepository.findByApplicationIdAndStatus(applicationId,
|
||||
ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
deleteSignedDocumentFromS3(applicationSignedDocument);
|
||||
@@ -1099,10 +1135,9 @@ public class ApplicationDao {
|
||||
}
|
||||
}
|
||||
|
||||
private void sendMailToUserAndCompany(UserEntity userEntity, ApplicationEntity applicationEntity) {
|
||||
private void sendMailToUserAndCompany(UserEntity userEntity, ApplicationEntity applicationEntity,CompanyEntity company) {
|
||||
log.info("Preparing to send submission email | applicationId: {}, userId: {}", applicationEntity.getId(), userEntity.getId());
|
||||
CallEntity call =applicationEntity.getCall();
|
||||
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
|
||||
UserWithCompanyEntity userWithCompany=companyService.getUserWithCompany(userEntity.getId(),company.getId());
|
||||
ProtocolEntity protocol= applicationEntity.getProtocol();
|
||||
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
|
||||
@@ -1130,7 +1165,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<>();
|
||||
@@ -1179,24 +1214,6 @@ public class ApplicationDao {
|
||||
|
||||
EmailLogRequest emailLogRequest=emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(),RecipientTypeEnum.PROPERTIES,null,userEntity.getEmail(),userEntity.getId(),applicationEntity.getId(),null,applicationEntity.getCall().getId());
|
||||
|
||||
// mailUtil.sendByMailGun(subject, body, List.of(defaultSystemReceiverEmail), null);
|
||||
// mailUtil.sendByMailGun(subject, body, List.of(gepafinEmail), null);
|
||||
// mailUtil.sendByMailGun(subject, body, List.of(rinaldoEmail), null);
|
||||
// if(Boolean.TRUE.equals(hub.getUniqueUuid().equals(defaultHubUuid))) {
|
||||
// if (validator.isProductionProfileActivated()) {
|
||||
// emailLogRequest.setRecipientEmails(carloEmail);
|
||||
//// mailUtil.sendByMailGun(subject, body, List.of(carloEmail), null);
|
||||
// emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(carloEmail),emailLogRequest);
|
||||
// }
|
||||
// List<String> listDefaultSystemReceiverEmail = Arrays.stream(defaultSystemReceiverEmail.split(","))
|
||||
// .map(String::trim)
|
||||
// .filter(email -> !email.isEmpty())
|
||||
// .toList();
|
||||
//
|
||||
// emailLogRequest.setRecipientEmails(defaultSystemReceiverEmail);
|
||||
// emailNotificationDao.sendMail(hub.getId(), subject, body, listDefaultSystemReceiverEmail, emailLogRequest);
|
||||
// }
|
||||
|
||||
List<String> hubEmails = Arrays.stream(hub.getEmail().split(","))
|
||||
.map(String::trim)
|
||||
.filter(email -> !email.isEmpty())
|
||||
@@ -1225,6 +1242,12 @@ public class ApplicationDao {
|
||||
log.info("Existing active signed document found and will be deleted | applicationId: {}, fileName: {}", applicationId, applicationSignedDocument.getFileName());
|
||||
deleteSignedDocumentFromS3(applicationSignedDocument);
|
||||
}
|
||||
String hash ="";
|
||||
try {
|
||||
hash = FileHashUtil.calculateSHA256(file.getInputStream());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
UploadFileOnAmazonS3Response uploadFileOnAmazonS3 = uploadFileOnAmazonS3ForUserSignedDocument(file, applicationEntity.getCall().getId(), applicationId);
|
||||
log.info("File uploaded to S3 successfully | applicationId: {}", applicationId);
|
||||
applicationSignedDocument = new ApplicationSignedDocumentEntity();
|
||||
@@ -1232,6 +1255,7 @@ public class ApplicationDao {
|
||||
applicationSignedDocument.setFileName(uploadFileOnAmazonS3.getFileName());
|
||||
applicationSignedDocument.setFilePath(uploadFileOnAmazonS3.getFilePath());
|
||||
applicationSignedDocument.setStatus(ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
applicationSignedDocument.setFileHash(hash);
|
||||
applicationSignedDocument = applicationSignedDocumentRepository.save(applicationSignedDocument);
|
||||
|
||||
/** This code is responsible for adding a version history log for the "assign application document" operation. **/
|
||||
@@ -1307,6 +1331,7 @@ public class ApplicationDao {
|
||||
.setStatus(ApplicationSignedDocumentStatusEnum.valueOf(applicationSignedDocument.getStatus()));
|
||||
applicationSignedDocumentResponse.setCreatedDate(applicationSignedDocument.getCreatedDate());
|
||||
applicationSignedDocumentResponse.setUpdatedDate(applicationSignedDocument.getUpdatedDate());
|
||||
applicationSignedDocumentResponse.setFileHash(applicationSignedDocument.getFileHash());
|
||||
return applicationSignedDocumentResponse;
|
||||
}
|
||||
|
||||
@@ -1885,4 +1910,429 @@ public class ApplicationDao {
|
||||
responseBean.setDateRejected(applicationView.getDateRejected());
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
public List<ApplicationFormView> getApplicationFormData(Long callId) {
|
||||
List<ApplicationFormView> applicationFormViews=new ArrayList<>();
|
||||
|
||||
applicationFormViews= applicationFormViewRepository.findByCallId(callId);
|
||||
|
||||
return applicationFormViews;
|
||||
}
|
||||
|
||||
private List<Method> getStaticGetterMethods() {
|
||||
List<String> excluded = Arrays.asList(
|
||||
GepafinConstant.GET_FIELD_TYPE,GepafinConstant.GET_APPLICATION_FORM_ID,GepafinConstant.GET_ID,GepafinConstant.GET_CLASS,GepafinConstant.GET_FORM_ID,GepafinConstant.GET_FIELD_ID,GepafinConstant.GET_FIELD_LABEL,GepafinConstant.GET_FIELD_VALUE,GepafinConstant.GET_REPORT_HEADER,GepafinConstant.GET_REPORT_ENABLE
|
||||
);
|
||||
|
||||
Method applicationIdMethod = null;
|
||||
|
||||
List<Method> methods = new ArrayList<>();
|
||||
|
||||
for (Method m : ApplicationFormView.class.getMethods()) {
|
||||
if (m.getName().equals(GepafinConstant.GET_APPLICATION_ID)) {
|
||||
applicationIdMethod = m;
|
||||
} else if (m.getName().startsWith(GepafinConstant.GET) && m.getParameterCount() == 0 && !excluded.contains(m.getName())) {
|
||||
methods.add(m);
|
||||
}
|
||||
}
|
||||
|
||||
methods.sort(Comparator.comparing(Method::getName)); // Sort remaining
|
||||
|
||||
if (applicationIdMethod != null) {
|
||||
methods.add(0, applicationIdMethod); // Add it to the beginning
|
||||
}
|
||||
|
||||
return methods;
|
||||
|
||||
}
|
||||
|
||||
private String methodToHeader(Method method) {
|
||||
String name = method.getName().substring(3); // strip "get"
|
||||
return Arrays.stream(name.split("(?=[A-Z])"))
|
||||
.map(String::toLowerCase)
|
||||
.map(word -> Character.toUpperCase(word.charAt(0)) + word.substring(1))
|
||||
.collect(Collectors.joining(" "));
|
||||
}
|
||||
|
||||
private String invokeGetter(ApplicationFormView view, Method method) {
|
||||
try {
|
||||
Object value = method.invoke(view);
|
||||
if (value == null) return "";
|
||||
|
||||
String stringValue;
|
||||
|
||||
if (value instanceof LocalDate) {
|
||||
stringValue = ((LocalDate) value).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
} else if (value instanceof LocalDateTime) {
|
||||
stringValue = ((LocalDateTime) value).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
} else if (value instanceof Date) {
|
||||
stringValue = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) value);
|
||||
} else {
|
||||
stringValue = value.toString();
|
||||
}
|
||||
|
||||
// Wrap it in ="..." to make Excel treat it as a literal string
|
||||
return "=\"" + stringValue.replace("\"", "\"\"") + "\"";
|
||||
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public byte[] exportCsv(Long callId) {
|
||||
|
||||
List<ApplicationFormView> results = getApplicationFormData(callId);
|
||||
|
||||
|
||||
Map<Long, ApplicationFormView> appInfo = new HashMap<>();
|
||||
Map<Long, Map<String, String>> appFieldValues = new LinkedHashMap<>();
|
||||
Set<String> tableFieldIds = new HashSet<>();
|
||||
Map<String, String> fieldIdToLabel = new LinkedHashMap<>();
|
||||
|
||||
for (ApplicationFormView row : results) {
|
||||
appInfo.putIfAbsent(row.getApplicationId(), row);
|
||||
String label=row.getReportHeader();
|
||||
if(Boolean.TRUE.equals(StringUtils.isEmpty(label))){
|
||||
label=row.getFieldLabel();
|
||||
}
|
||||
fieldIdToLabel.putIfAbsent(row.getFieldId(), label);
|
||||
|
||||
if (GepafinConstant.TABLE.equalsIgnoreCase(row.getFieldType())) {
|
||||
tableFieldIds.add(row.getFieldId());
|
||||
continue;
|
||||
}
|
||||
|
||||
String value = Optional.ofNullable(row.getFieldValue())
|
||||
.map(v -> v.startsWith("\"") && v.endsWith("\"") ? v.substring(1, v.length() - 1) : v)
|
||||
.orElse("");
|
||||
|
||||
appFieldValues
|
||||
.computeIfAbsent(row.getApplicationId(), k -> new LinkedHashMap<>())
|
||||
.merge(row.getFieldId(), value, (v1, v2) -> v1.equals(v2) ? v1 : String.join(", ", v1, v2));
|
||||
}
|
||||
|
||||
Map<String, List<String>> tableHeadersByFieldId = new LinkedHashMap<>();
|
||||
Map<Long, Map<String, String>> tableDataByApp = new HashMap<>();
|
||||
prepareTableFieldData(results, tableFieldIds, tableHeadersByFieldId, tableDataByApp);
|
||||
|
||||
// Final header construction
|
||||
List<Method> staticMethods = getStaticGetterMethods();
|
||||
List<String> staticHeaders = staticMethods.stream().map(this::methodToHeader).toList();
|
||||
|
||||
List<String> dynamicHeaders = new ArrayList<>();
|
||||
for (String fieldId : fieldIdToLabel.keySet()) {
|
||||
if (tableHeadersByFieldId.containsKey(fieldId)) {
|
||||
dynamicHeaders.addAll(tableHeadersByFieldId.get(fieldId));
|
||||
} else {
|
||||
dynamicHeaders.add(fieldIdToLabel.get(fieldId));
|
||||
}
|
||||
}
|
||||
|
||||
List<String> allHeaders = new ArrayList<>(staticHeaders);
|
||||
allHeaders.addAll(dynamicHeaders);
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
try (CSVPrinter printer = new CSVPrinter(new OutputStreamWriter(out), CSVFormat.DEFAULT.withHeader(allHeaders.toArray(new String[0])))) {
|
||||
for (Long appId : appFieldValues.keySet()) {
|
||||
ApplicationFormView appRow = appInfo.get(appId);
|
||||
Map<String, String> flatFieldVals = appFieldValues.get(appId);
|
||||
Map<String, String> tableVals = tableDataByApp.getOrDefault(appId, Collections.emptyMap());
|
||||
|
||||
List<String> row = new ArrayList<>();
|
||||
for (Method method : staticMethods) {
|
||||
row.add(invokeGetter(appRow, method));
|
||||
}
|
||||
|
||||
for (String fieldId : fieldIdToLabel.keySet()) {
|
||||
if (tableHeadersByFieldId.containsKey(fieldId)) {
|
||||
for (String header : tableHeadersByFieldId.get(fieldId)) {
|
||||
row.add(tableVals.getOrDefault(header, ""));
|
||||
}
|
||||
} else {
|
||||
row.add(flatFieldVals.getOrDefault(fieldId, ""));
|
||||
}
|
||||
}
|
||||
|
||||
printer.printRecord(row);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("CSV generation failed", e);
|
||||
}
|
||||
|
||||
return out.toByteArray();
|
||||
}
|
||||
private Map<String, String> extractTableData(String fieldType,
|
||||
ContentResponseBean content, String fieldValue) {
|
||||
|
||||
if (content == null) return Map.of();
|
||||
|
||||
Map<String, String> result = new LinkedHashMap<>();
|
||||
|
||||
List<Map<String, Object>> rows = null;
|
||||
try {
|
||||
rows = GepafinConstant.CRITERIA_TABLE_COLUMNS.equals(fieldType)
|
||||
? Utils.convertJsonToListMap(String.valueOf(PdfUtils.extractRows(fieldValue)))
|
||||
: Utils.convertJsonToListMap(fieldValue);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Map<String, String> fieldLabelMap = new LinkedHashMap<>();
|
||||
Set<String> predefinedIds = new LinkedHashSet<>();
|
||||
Set<String> dynamicIds = new LinkedHashSet<>();
|
||||
Set<String> numericFormulaIds = new LinkedHashSet<>();
|
||||
|
||||
for (SettingResponseBean setting : content.getSettings()) {
|
||||
String settingName = setting.getName();
|
||||
if(settingName.equals(GepafinConstant.REPORT_ENABLE)){
|
||||
Boolean enable= (Boolean) setting.getValue();
|
||||
if(Boolean.FALSE.equals(enable)){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(GepafinConstant.TABLE_COLUMNS.equals(settingName)) || Boolean.TRUE.equals(GepafinConstant.CRITERIA_TABLE_COLUMNS.equals(settingName))) {
|
||||
Map<String, Object> valueMap = (Map<String, Object>) setting.getValue();
|
||||
if (valueMap == null) continue;
|
||||
|
||||
List<Map<String, Object>> columns = (List<Map<String, Object>>) valueMap.get(GepafinConstant.STATE_FIELD_DATA);
|
||||
if (columns != null) {
|
||||
for (Map<String, Object> col : columns) {
|
||||
String id = String.valueOf(col.get(GepafinConstant.NAME));
|
||||
if (Boolean.FALSE.equals(col.get(GepafinConstant.PREDEFINED))) {
|
||||
if (GepafinConstant.NUMERIC.equals(col.get(GepafinConstant.FIELD_TYPE)) && Boolean.TRUE.equals(col.get(GepafinConstant.ENABLE_FORMULA))) {
|
||||
numericFormulaIds.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Boolean.TRUE.equals(GepafinConstant.REPORT_COLUMNS.equals(settingName))) {
|
||||
List<Map<String, Object>> reportColumns = (List<Map<String, Object>>) setting.getValue();
|
||||
if (reportColumns != null) {
|
||||
for (Map<String, Object> col : reportColumns) {
|
||||
Boolean enableCsv = (Boolean) col.get(GepafinConstant.EBABLE_CSV);
|
||||
if (Boolean.TRUE.equals(enableCsv)) {
|
||||
String id = String.valueOf(col.get(GepafinConstant.NAME));
|
||||
|
||||
String fieldCsvLabel = col.get(GepafinConstant.LABEL_CSV) != null
|
||||
? String.valueOf(col.get(GepafinConstant.LABEL_CSV))
|
||||
: String.valueOf(col.get(GepafinConstant.LABEL));
|
||||
|
||||
fieldLabelMap.put(id, fieldCsvLabel);
|
||||
|
||||
if (Boolean.TRUE.equals(col.get(GepafinConstant.PREDEFINED))) {
|
||||
predefinedIds.add(id);
|
||||
} else {
|
||||
dynamicIds.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (predefinedIds.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
for (Map<String, Object> row : rows) {
|
||||
String prefix = predefinedIds.stream()
|
||||
.map(id -> String.valueOf(row.getOrDefault(id, "")))
|
||||
.filter(s -> !s.isBlank())
|
||||
.findFirst().orElse("");
|
||||
|
||||
|
||||
for (String dynId : dynamicIds) {
|
||||
String dynLabel = fieldLabelMap.get(dynId);
|
||||
for (String preId : predefinedIds.isEmpty() ? List.of("") : predefinedIds) {
|
||||
String preLabel = fieldLabelMap.get(preId);
|
||||
String key = dynLabel + " " + (preLabel != null ? preLabel + " " : "") + prefix;
|
||||
result.put(key, String.valueOf(row.getOrDefault(dynId, "")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add totals for numeric formula-enabled columns
|
||||
for (String dynId : numericFormulaIds) {
|
||||
double sum = rows.stream()
|
||||
.mapToDouble(r -> {
|
||||
try {
|
||||
return Double.parseDouble(String.valueOf(r.getOrDefault(dynId, "0")));
|
||||
} catch (NumberFormatException e) {
|
||||
return 0.0;
|
||||
}
|
||||
}).sum();
|
||||
String dynLabel = fieldLabelMap.get(dynId);
|
||||
result.put("TOTAL " + dynLabel, String.valueOf(sum));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
private void prepareTableFieldData(
|
||||
List<ApplicationFormView> results,
|
||||
Set<String> tableFieldIds,
|
||||
Map<String, List<String>> tableHeadersByFieldId,
|
||||
Map<Long, Map<String, String>> tableDataByApp) {
|
||||
|
||||
if (tableFieldIds.isEmpty()) return;
|
||||
|
||||
Map<Long, List<ApplicationFormView>> groupedByApp = results.stream()
|
||||
.filter(r -> tableFieldIds.contains(r.getFieldId()))
|
||||
.collect(Collectors.groupingBy(ApplicationFormView::getApplicationId));
|
||||
|
||||
for (Map.Entry<Long, List<ApplicationFormView>> entry : groupedByApp.entrySet()) {
|
||||
Long appId = entry.getKey();
|
||||
Map<String, String> flattenedAll = new LinkedHashMap<>();
|
||||
|
||||
for (ApplicationFormView row : entry.getValue()) {
|
||||
formRepository.findById(row.getFormId()).ifPresent(form -> {
|
||||
List<ContentResponseBean> contentList = Utils.convertJsonStringToList(form.getContent(), ContentResponseBean.class);
|
||||
ContentResponseBean content = contentList.stream()
|
||||
.filter(c -> c.getId().equals(row.getFieldId()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
if (content == null) return;
|
||||
|
||||
content.getSettings().stream()
|
||||
.filter(setting -> GepafinConstant.TABLE_COLUMNS.equals(setting.getName())
|
||||
|| GepafinConstant.CRITERIA_TABLE_COLUMNS.equals(setting.getName()))
|
||||
.findFirst()
|
||||
.ifPresent(setting -> {
|
||||
Map<String, String> flattened = extractTableData(
|
||||
row.getFieldType(),
|
||||
content,
|
||||
row.getFieldValue()
|
||||
);
|
||||
if (flattened != null) {
|
||||
tableHeadersByFieldId.putIfAbsent(row.getFieldId(), new ArrayList<>(flattened.keySet()));
|
||||
flattenedAll.putAll(flattened);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
tableDataByApp.put(appId, flattenedAll);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -704,7 +706,11 @@ public class ApplicationEvaluationDao {
|
||||
/** This code is responsible for adding a version history log for the "Update Application" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(actionType).oldData(oldApplication).newData(application).build());
|
||||
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_CREATION);
|
||||
// Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_CREATION);
|
||||
|
||||
Map<String, String> placeHolders = new HashMap<>();
|
||||
placeHolders.put("{{call_name}}", application.getCall().getName());
|
||||
placeHolders.put("{{protocol_number}}", String.valueOf(application.getProtocol().getProtocolNumber()));
|
||||
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.EVALUATION_CREATION);
|
||||
notificationDao.sendNotificationToInstructor(placeHolders,entity,NotificationTypeEnum.EVALUATION_CREATION);
|
||||
|
||||
@@ -1136,10 +1142,14 @@ 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 applicationEvaluationResponse = convertToResponse(entity);
|
||||
applicationEvaluationResponse.setEmailSendResponse(entity.getEmailSendResponse());
|
||||
return applicationEvaluationResponse;
|
||||
}
|
||||
private List<EvaluationDocumentRequest> prepareEvaluationDocumentBeanList(ApplicationEvaluationEntity entity) {
|
||||
List<EvaluationDocumentRequest> docRequest = new ArrayList<>();
|
||||
@@ -1683,7 +1693,7 @@ public class ApplicationEvaluationDao {
|
||||
});
|
||||
}
|
||||
|
||||
private String getLabelFromSettings(ContentResponseBean contentResponseBean) {
|
||||
public String getLabelFromSettings(ContentResponseBean contentResponseBean) {
|
||||
String label = contentResponseBean.getLabel();
|
||||
if (contentResponseBean.getSettings() != null) {
|
||||
for (SettingResponseBean setting : contentResponseBean.getSettings()) {
|
||||
@@ -1897,7 +1907,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());
|
||||
@@ -1905,10 +1915,16 @@ public class ApplicationEvaluationDao {
|
||||
ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(application);
|
||||
|
||||
|
||||
List<EmailSendResponse> responses = new ArrayList<>();
|
||||
if(newStatus.equals(ApplicationStatusForEvaluation.ADMISSIBLE) && Boolean.TRUE.equals(application.getStatus().equals(ApplicationStatusTypeEnum.APPOINTMENT.getValue()))){
|
||||
application.setStatus(newStatus.getValue());
|
||||
log.info("Status updated to ADMISSIBLE for applicationId: " + application.getId());
|
||||
emailNotificationDao.sendAdmissibilityNotificationEmailForAdmissibleApplication(application);
|
||||
emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
responses = List.of(emailSendResponse);
|
||||
if (!Boolean.TRUE.equals(emailSendResponse.getIsEmailSend())) {
|
||||
saveEmailSendResponseToEvaluation(emailSendResponse, existingEntity);
|
||||
}
|
||||
}
|
||||
|
||||
if(newStatus.equals(ApplicationStatusForEvaluation.TECHNICAL_EVALUATION) && Boolean.TRUE.equals(application.getStatus().equals(ApplicationStatusTypeEnum.ADMISSIBLE.getValue()))){
|
||||
@@ -1960,27 +1976,48 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
|
||||
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.APPROVED.getValue())))) {
|
||||
application.setDateAccepted(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
application.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
application.setDateAccepted(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
application.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
application = applicationRepository.save(application);
|
||||
// emailNotificationDao.sendAdmissibilityNotificationEmailForApprovedApplication(application);
|
||||
notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_RESULT);
|
||||
}
|
||||
if (Boolean.TRUE.equals(statusType.equals((ApplicationStatusTypeEnum.REJECTED.getValue())))) {
|
||||
application.setDateRejected(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
application.setUpdatedDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||
application = applicationRepository.save(application);
|
||||
emailNotificationDao.sendInadmissibilityEmailForRejectedApplication(application,existingEntity);
|
||||
emailSendResponse = emailDao.buildEmailSendResponseFromRequest(request);
|
||||
responses = List.of(emailSendResponse);
|
||||
if (!Boolean.TRUE.equals(emailSendResponse.getIsEmailSend())) {
|
||||
saveEmailSendResponseToEvaluation(emailSendResponse, existingEntity);
|
||||
}
|
||||
notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_RESULT);
|
||||
}
|
||||
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_RESULT);
|
||||
Map<String, String> placeHolders = new HashMap<>();
|
||||
placeHolders.put("{{call_name}}", application.getCall().getName());
|
||||
placeHolders.put("{{protocol_number}}", String.valueOf(application.getProtocol().getProtocolNumber()));
|
||||
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.EVALUATION_RESULT);
|
||||
notificationDao.sendNotificationToInstructor(placeHolders,existingEntity,NotificationTypeEnum.EVALUATION_RESULT);
|
||||
|
||||
return convertToResponse(entity);
|
||||
ApplicationEvaluationResponse response = convertToResponse(entity);
|
||||
if (!Boolean.TRUE.equals(emailSendResponse.getIsEmailSend())) {
|
||||
response.setEmailSendResponse(responses);
|
||||
}
|
||||
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) {
|
||||
log.info("Validating ApplicationEvaluation for applicationId: {}", applicationId);
|
||||
return applicationEvaluationRepository
|
||||
@@ -2040,6 +2077,7 @@ public class ApplicationEvaluationDao {
|
||||
|
||||
ApplicationEvaluationEntity entity = applicationEvaluationService.validateApplicationEvaluation(evaluationResponse.getId());
|
||||
|
||||
|
||||
//Handling Application Evaluation form
|
||||
EvaluationFormEntity evaluationFormEntity = evaluationFormService.validateEvaluationForm(evaluationFormId);
|
||||
validateFormFields(applicationEvaluationFormRequestBean,evaluationFormEntity);
|
||||
@@ -2048,7 +2086,9 @@ public class ApplicationEvaluationDao {
|
||||
validateFormFieldCustom(applicationEvaluationFormRequestBean.getFormFields(),entity,evaluationFormEntity);
|
||||
ApplicationEvaluationFormEntity applicationEvaluationFormEntity = getApplicationEvaluationFormOrCreate(evaluationFormEntity,entity);
|
||||
createOrUpdateMultipleFormFields(applicationEvaluationFormRequestBean.getFormFields(), applicationEvaluationFormEntity, evaluationFormEntity);
|
||||
return processEvaluationForm(entity);
|
||||
ApplicationEvaluationFormResponse response = processEvaluationForm(entity);
|
||||
response.setEmailSendResponse(evaluationResponse.getEmailSendResponse());
|
||||
return response;
|
||||
}
|
||||
|
||||
private ApplicationEvaluationFormEntity getApplicationEvaluationFormOrCreate(EvaluationFormEntity evaluationFormEntity, ApplicationEvaluationEntity applicationEvaluationEntity) {
|
||||
@@ -2300,6 +2340,7 @@ public class ApplicationEvaluationDao {
|
||||
}
|
||||
response.setCompanyVatNumber(company.getVatNumber());
|
||||
response.setCompanyCodiceAteco(company.getCodiceAteco());
|
||||
response.setEmailSendResponse(evaluationEntity.getEmailSendResponse());
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -37,6 +38,7 @@ import net.gepafin.tendermanagement.repositories.CompanyRepository;
|
||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||
import net.gepafin.tendermanagement.repositories.HubRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.service.feignClient.AppointmentApiService;
|
||||
@@ -60,12 +62,7 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
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;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -141,6 +138,18 @@ public class AppointmentDao {
|
||||
@Autowired
|
||||
private ApplicationEvaluationServiceImpl applicationEvaluationService;
|
||||
|
||||
@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<>();
|
||||
@@ -174,10 +183,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) {
|
||||
log.info("Starting login to Odessa. HubId: {}, ApplicationId: {}", hub.getId(), application.getId());
|
||||
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 +370,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());
|
||||
@@ -202,55 +382,53 @@ 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) {
|
||||
log.warn("Received 403 Forbidden from Odessa. Attempting to parse error response.");
|
||||
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);
|
||||
log.warn("Detected PASSWORD_EXPIRED error during Odessa login. ApplicationId: {}", application.getId());
|
||||
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);
|
||||
}
|
||||
log.warn("Detected PASSWORD_EXPIRED error during Odessa login. ApplicationId: {}", application.getId());
|
||||
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("Unexpected exception during Odessa login. HubId: {}, Error: {}", hub.getId(), e.getMessage(), e);
|
||||
throw new RuntimeException("Authentication failed on Odessa. try again", e);
|
||||
}
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
log.error("Unexpected exception during Odessa login.Error: {}",e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void startAsyncNdgProcessing(Long applicationId) {
|
||||
@@ -300,7 +478,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);
|
||||
@@ -349,9 +527,13 @@ public class AppointmentDao {
|
||||
applicationRepository.save(application);
|
||||
companyRepository.save(company);
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(application.getApplicationEvaluationId());
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.NDG_GENERATION);
|
||||
// Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.NDG_GENERATION);
|
||||
|
||||
Map<String, String> placeHolders = new HashMap<>();
|
||||
placeHolders.put("{{call_name}}", application.getCall().getName());
|
||||
placeHolders.put("{{protocol_number}}", String.valueOf(application.getProtocol().getProtocolNumber()));
|
||||
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;
|
||||
}
|
||||
@@ -399,9 +581,12 @@ public class AppointmentDao {
|
||||
companyRepository.save(company);
|
||||
applicationRepository.save(application);
|
||||
ApplicationEvaluationEntity applicationEvaluationEntity = applicationEvaluationService.validateApplicationEvaluation(application.getApplicationEvaluationId());
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.NDG_GENERATION);
|
||||
// Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.NDG_GENERATION);
|
||||
Map<String, String> placeHolders = new HashMap<>();
|
||||
placeHolders.put("{{call_name}}", application.getCall().getName());
|
||||
placeHolders.put("{{protocol_number}}", String.valueOf(application.getProtocol().getProtocolNumber()));
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -420,7 +605,7 @@ public class AppointmentDao {
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
log.warn("403 Forbidden while fetching Visura list. Attempting token regeneration | ApplicationId: {}, HubId: {}", application.getId(), hub.getId());
|
||||
// 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("Error while fetching Visura list | ApplicationId: {}, HubId: {}, Error: {}", application.getId(), hub.getId(), e.getMessage(), e);
|
||||
@@ -428,86 +613,6 @@ public class AppointmentDao {
|
||||
}
|
||||
}
|
||||
|
||||
private HubEntity authenticateAndSaveToken(HubEntity hub) {
|
||||
|
||||
try {
|
||||
log.info("Starting authentication to Odessa | HubId: {}", hub.getId());
|
||||
//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 {
|
||||
log.error("Login response missing tokenId | HubId: {}", hub.getId());
|
||||
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("403 Forbidden during Odessa login | HubId: {}", hub.getId());
|
||||
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())) {
|
||||
log.warn("Odessa password expired detected in login response | HubId: {}", hub.getId());
|
||||
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 forbidden JSON response | HubId: {}, Error: {}", hub.getId(), e.getMessage(), e);
|
||||
}
|
||||
|
||||
// Regenerate the token and retry
|
||||
regenerateTokenAndSave(hub);
|
||||
} catch (Exception e) {
|
||||
log.error("Unexpected error during Odessa authentication | HubId: {}, Error: {}", hub.getId(), 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 {
|
||||
@@ -523,7 +628,7 @@ public class AppointmentDao {
|
||||
log.error("403 Forbidden during NDG retrieval | ApplicationId: {}, HubId: {}", application.getId(), hub.getId());
|
||||
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("Error during NDG retrieval | ApplicationId: {}, HubId: {}, Message: {}", application.getId(), hub.getId(), e.getMessage(), e);
|
||||
@@ -531,9 +636,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) {
|
||||
@@ -546,7 +652,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());
|
||||
@@ -719,9 +825,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) {
|
||||
log.error("Missing appointment template ID for applicationId: {}", applicationId);
|
||||
@@ -741,9 +846,11 @@ public class AppointmentDao {
|
||||
// Build the appointment request body
|
||||
AppointmentCreationRequest appointmentCreationRequest = buildAppointmentCreationRequest(applicationId, createAppointmentRequest, appointmentTemplateId,
|
||||
templateRichiestaData);
|
||||
log.info("AppointmentCreationRequest : {}", appointmentCreationRequest);
|
||||
String appointmentRequestBody = Utils.convertObjectToJson(appointmentCreationRequest);
|
||||
|
||||
// Make API call to create the appointment
|
||||
log.info("Context:{}, Authorization Token : {}, RequestBody : {}", context, authorizationToken, appointmentRequestBody);
|
||||
ResponseEntity<Object> appointmentResponse = appointmentApiService.createAppointment(authorizationToken, context, appointmentRequestBody);
|
||||
String appointmentId = extractAppointmentIdFromResponse(appointmentResponse);
|
||||
|
||||
@@ -764,8 +871,8 @@ public class AppointmentDao {
|
||||
return appointmentCreationResponse;
|
||||
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
log.error("403 Forbidden received while retrieving template. Attempting to regenerate token and retry. Application ID: {}", applicationId);
|
||||
regenerateTokenAndSave(hub);
|
||||
log.error("403 Forbidden received while retrieving template. Attempting to regenerate token and retry. Application ID: {}", applicationId);
|
||||
regenerateTokenAndSave(hub, application);
|
||||
return createAppointment(applicationId, createAppointmentRequest);
|
||||
}
|
||||
}
|
||||
@@ -773,12 +880,32 @@ public class AppointmentDao {
|
||||
private String extractAppointmentIdFromResponse(ResponseEntity<Object> appointmentResponse) {
|
||||
|
||||
if (appointmentResponse.getBody() != null) {
|
||||
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();
|
||||
log.info("Appointment API Response : {}", appointmentResponse.getBody());
|
||||
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;
|
||||
@@ -808,20 +935,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);
|
||||
@@ -883,13 +1010,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();
|
||||
@@ -909,11 +1063,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 {
|
||||
@@ -929,8 +1084,8 @@ public class AppointmentDao {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void uploadDocumentToExternalSystemSync(Long documentId, UploadDocToExternalSystemRequest docToExternalSystemRequest) {
|
||||
log.info("Starting sync document upload for documentId: {}", documentId);
|
||||
private void uploadDocumentToExternalSystemSync(Long documentId, UploadDocToExternalSystemRequest docToExternalSystemRequest, ApplicationEntity application) {
|
||||
log.info("Starting sync document upload for documentId: {}", documentId);
|
||||
// Synchronous upload logic
|
||||
DocumentEntity systemDoc = documentDao.validateDocument(documentId);
|
||||
|
||||
@@ -971,9 +1126,9 @@ public class AppointmentDao {
|
||||
|
||||
log.info("Document uploaded successfully to external system: {}", parsedResponse);
|
||||
} catch (FeignException.Forbidden forbiddenException) {
|
||||
log.error("403 Forbidden from external system during upload for documentId: {}. Retrying with new token...", documentId);
|
||||
regenerateTokenAndSave(hub);
|
||||
uploadDocumentToExternalSystemSync(documentId, docToExternalSystemRequest);
|
||||
log.error("403 Forbidden from external system during upload for documentId: {}. Retrying with new token...", documentId);
|
||||
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));
|
||||
@@ -1004,12 +1159,12 @@ public class AppointmentDao {
|
||||
|
||||
private File downloadFileFromS3(String fileUrl) throws Exception {
|
||||
|
||||
String key = extractS3KeyFromUrl(fileUrl);
|
||||
File localFile = new File(GepafinConstant.TEMP_FILE_PATH + extractFileName(key));
|
||||
String key = amazonS3Service.extractS3KeyFromUrl(fileUrl);
|
||||
String fileName = extractFileName(key);
|
||||
String folderPath = key.substring(0, key.lastIndexOf("/"));
|
||||
File localFile = new File(GepafinConstant.TEMP_FILE_PATH + fileName);
|
||||
|
||||
GetObjectRequest getObjectRequest = new GetObjectRequest(OLD_BUCKET, key);
|
||||
|
||||
try (InputStream s3Stream = s3Client.getObject(getObjectRequest).getObjectContent(); FileOutputStream outputStream = new FileOutputStream(localFile)) {
|
||||
try (InputStream s3Stream = amazonS3Service.getFile(folderPath, key); FileOutputStream outputStream = new FileOutputStream(localFile)) {
|
||||
s3Stream.transferTo(outputStream);
|
||||
}
|
||||
|
||||
@@ -1017,11 +1172,6 @@ public class AppointmentDao {
|
||||
return localFile;
|
||||
}
|
||||
|
||||
private String extractS3KeyFromUrl(String url) {
|
||||
|
||||
return url.replace(s3Url, "");
|
||||
}
|
||||
|
||||
private String extractFileName(String filePath) {
|
||||
|
||||
String[] parts = filePath.split("/");
|
||||
|
||||
@@ -332,7 +332,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
|
||||
|
||||
@@ -350,10 +351,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
|
||||
@@ -394,7 +395,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;
|
||||
@@ -465,6 +466,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;
|
||||
@@ -487,6 +490,7 @@ public class AssignedApplicationsDao {
|
||||
response.setCompanyName(view.getCompanyName());
|
||||
response.setCreatedDate(view.getCreatedDate());
|
||||
response.setUpdatedDate(view.getUpdatedDate());
|
||||
response.setEmailSendResponse(view.getEmailSendResponse());
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -1039,7 +1039,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) {
|
||||
log.info("Fetching paginated calls for userId={}, companyId={}, onlyPreferredCall={}", user.getId(), companyId, onlyPreferredCall);
|
||||
Integer pageNo = null;
|
||||
Integer pageLimit = null;
|
||||
@@ -1060,7 +1060,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)) {
|
||||
log.debug("Filtering calls for preferred by userId={} and companyId={}", user.getId(), companyId);
|
||||
@@ -1111,10 +1111,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
|
||||
@@ -1138,7 +1138,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<>();
|
||||
@@ -1192,7 +1192,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()) {
|
||||
|
||||
|
||||
@@ -498,12 +498,19 @@ public class CompanyDao {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Object pecEmailObj = dettaglio.get("pec");
|
||||
if (pecEmailObj instanceof String pec && !pec.isEmpty()) {
|
||||
company.setPec(pec); // Only set if valid string
|
||||
} else {
|
||||
log.warn("Company ID {}: 'pec' is missing, empty, or not a string.", company.getId());
|
||||
}
|
||||
|
||||
Object codiceAtecoObj = dettaglio.get("codice_ateco");
|
||||
if (!(codiceAtecoObj instanceof String codiceAteco) || codiceAteco.isEmpty()) {
|
||||
log.warn("Company ID {}: 'codice_ateco' is missing, empty, or not a string.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
company.setCodiceAteco(codiceAteco);
|
||||
logCodiceAtecoUpdate(company, codiceAteco);
|
||||
}
|
||||
@@ -532,6 +539,13 @@ public class CompanyDao {
|
||||
// if data is a single object
|
||||
updateCodiceAtecoField(company);
|
||||
} else {
|
||||
|
||||
Object pecEmail = Utils.extractMap(dataMap, "pec");
|
||||
if (pecEmail == null) {
|
||||
log.warn("Company ID {}: 'pec' section is missing or invalid.", company.getId());
|
||||
company.setPec((String) pecEmail);
|
||||
}
|
||||
|
||||
// Extract 'atecoClassification' section
|
||||
Map<String, Object> atecoClassificationMap = Utils.extractMap(dataMap, "atecoClassification");
|
||||
if (atecoClassificationMap == null) {
|
||||
@@ -561,4 +575,51 @@ public class CompanyDao {
|
||||
|
||||
log.info("Company ID {}: codiceAteco updated to {}", company.getId(), atecoCode);
|
||||
}
|
||||
|
||||
public void getCompanyEntity() {
|
||||
List<CompanyEntity> companyEntities=companyRepository.findAll();
|
||||
for (CompanyEntity company:companyEntities){
|
||||
if(company.getJson()!=null){
|
||||
if (company == null || company.getJson() == null || company.getJson().isEmpty()) {
|
||||
log.warn("Company is null or JSON data is empty.");
|
||||
return;
|
||||
}
|
||||
Map<String, Object> vatCheckResponse = Utils.convertJsonStringToMap(company.getJson());
|
||||
|
||||
if (vatCheckResponse == null) {
|
||||
log.warn("Company ID {}: Invalid JSON response.", company.getId());
|
||||
return;
|
||||
}
|
||||
Map<String, Object> companyDataMap = Utils.convertJsonStringToMap(company.getJson());
|
||||
if (companyDataMap == null) {
|
||||
log.warn("Company ID {}: Failed to parse JSON data.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
Object dataObj = vatCheckResponse.get("data");
|
||||
if (!(dataObj instanceof Map<?, ?> dataMap)) {
|
||||
log.warn("Company ID {}: 'data' is missing or not a valid object.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dataMap.containsKey("dettaglio")) {
|
||||
log.warn("Company ID {}: 'dettaglio' not present inside 'data'. Skipping codiceAteco update.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
Object dettaglioObj = dataMap.get("dettaglio");
|
||||
if (!(dettaglioObj instanceof Map<?, ?> dettaglio)) {
|
||||
log.warn("Company ID {}: 'dettaglio' is not a valid object.", company.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
Object pecEmailObj = dettaglio.get("pec");
|
||||
if (pecEmailObj instanceof String pec && !pec.isEmpty()) {
|
||||
company.setPec(pec); // Only set if valid string
|
||||
} else {
|
||||
log.warn("Company ID {}: 'pec' is missing, empty, or not a string.", company.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
212
src/main/java/net/gepafin/tendermanagement/dao/EmailDao.java
Normal file
212
src/main/java/net/gepafin/tendermanagement/dao/EmailDao.java
Normal file
@@ -0,0 +1,212 @@
|
||||
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 (Iterator<EmailSendResponse> iterator = responses.iterator(); iterator.hasNext(); ) {
|
||||
EmailSendResponse response = iterator.next();
|
||||
if (scenario.equals(response.getEmailScenario().getValue())) {
|
||||
iterator.remove(); // remove only the first match
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.EmailServiceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.RecipientTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||
@@ -15,6 +16,7 @@ import net.gepafin.tendermanagement.service.*;
|
||||
import net.gepafin.tendermanagement.service.impl.EmailService;
|
||||
import net.gepafin.tendermanagement.service.impl.EmailServiceFactory;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.service.impl.SystemEmailService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -137,10 +139,12 @@ 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());
|
||||
sendMail(applicationEntity.getHubId(), subject, body, List.of(rinaldoEmail), emailLogRequest);
|
||||
|
||||
//SMTP
|
||||
sendMail(null, subject, body, List.of(rinaldoEmail), emailLogRequest);
|
||||
}
|
||||
if (applicationEvaluationEntity.isPresent()) {
|
||||
Long preInstructorId = applicationEvaluationEntity.get().getUserId(); // Assuming UserEntity has an email field
|
||||
@@ -275,10 +279,16 @@ public class EmailNotificationDao {
|
||||
|
||||
public void sendMail(Long hubId, String subject, String body, List<String> recipientEmails, EmailLogRequest emailLogRequest) {
|
||||
|
||||
EmailConfig emailConfig = retrieveEmailConfig(hubId);
|
||||
EmailService emailService = emailServiceFactory.getEmailService(emailConfig.getEmailServiceType());
|
||||
emailService.sendEmail(subject, body, recipientEmails, emailConfig,emailLogRequest);
|
||||
// emailService.sendEmail(subject, body, recipientEmails, emailConfig);
|
||||
EmailConfig emailConfig = new EmailConfig();
|
||||
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);
|
||||
} else {
|
||||
emailConfig = retrieveEmailConfig(hubId);
|
||||
EmailService emailService = emailServiceFactory.getEmailService(emailConfig.getEmailServiceType());
|
||||
emailService.sendEmail(subject, body, recipientEmails, emailConfig, emailLogRequest);
|
||||
}
|
||||
}
|
||||
|
||||
public EmailConfig retrieveEmailConfig(Long hubId) {
|
||||
|
||||
@@ -420,7 +420,8 @@ public class FormDao {
|
||||
.matchesPattern(value, fieldValidatorBean.getPattern(), fieldLabel) // Only applies if pattern is present
|
||||
.validateCustom(value, fieldValidatorBean.getCustom(), fieldLabel,contentResponseBean); // Add the custom validation here
|
||||
if (fieldValidatorBean.getCustom() != null && fieldValidatorBean.getCustom().equals(GepafinConstant.IS_PIVA)) {
|
||||
String error = validateVatNumber(value, fieldValidatorBean.getCustom(), fieldLabel);
|
||||
Long hubId = applicationEntity.getHubId();
|
||||
String error = validateVatNumber(value, fieldLabel,hubId);
|
||||
if(error != null) {
|
||||
validator.addError(error);
|
||||
}
|
||||
@@ -504,14 +505,14 @@ public class FormDao {
|
||||
}).filter(value -> !value.isEmpty()).findFirst().orElse(contentResponseBean.getId());
|
||||
}
|
||||
|
||||
public String validateVatNumber(String value,String customRule,String fieldId){
|
||||
public String validateVatNumber(String value,String fieldId, Long hubId){
|
||||
String error=null;
|
||||
|
||||
if (value!=null && value.matches("^\\d{1,11}$")) {
|
||||
// Map<String, Object> customData=null;
|
||||
try {
|
||||
// Map<String, Object> vatCheckResponse = vatCheckDao.checkVatNumberApi(value);
|
||||
vatCheckDao.checkVatNumber(value);
|
||||
vatCheckDao.checkVatNumber(value, hubId);
|
||||
// if (Boolean.FALSE.equals(CollectionUtils.isEmpty(vatCheckResponse))) {
|
||||
// customData = vatCheckResponse;
|
||||
// }
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.persistence.criteria.Root;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
@@ -12,7 +10,6 @@ import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.GlobalFilters;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.response.NotificationResponse;
|
||||
@@ -28,22 +25,19 @@ import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.opensaml.xmlsec.signature.G;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
@@ -92,7 +86,7 @@ public class NotificationDao {
|
||||
log.info("Sending notification to user {} with content: {}", userId, notificationReq.getMessage());
|
||||
List<Long> companyIds = notificationReq.getCompanyIds();
|
||||
|
||||
if (companyIds == null || companyIds.isEmpty()) {
|
||||
if (companyIds == null || companyIds.isEmpty() || companyIds.stream().allMatch(Objects::isNull)) {
|
||||
sendToUser(userId, notificationEntity);
|
||||
} else {
|
||||
sendToCompanies(userId, companyIds, notificationEntity);
|
||||
@@ -154,7 +148,7 @@ public class NotificationDao {
|
||||
notificationEntity.setUserId(notificationReq.getUserId());
|
||||
notificationEntity.setStatus(NotificationEnum.UNREAD.getValue());
|
||||
notificationEntity.setIsDeleted(Boolean.FALSE);
|
||||
notificationEntity.setUserWithCompany(notificationReq.getUserWithCompanyEntity() != null ? notificationReq.getUserWithCompanyEntity() : null);
|
||||
notificationEntity.setUserWithCompany(notificationReq.getUserWithCompanyEntity());
|
||||
notificationEntity.setMessage(message);
|
||||
notificationEntity.setTitle(notificationReq.getTitle());
|
||||
return notificationEntity;
|
||||
|
||||
@@ -1,20 +1,36 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import feign.FeignException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationSignedDocumentStatusEnum;
|
||||
import net.gepafin.tendermanagement.enums.ProtocolTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.VersionActionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.VersionHistoryRequest;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationSignedDocumentRepository;
|
||||
import net.gepafin.tendermanagement.service.feignClient.ProtocolService;
|
||||
import net.gepafin.tendermanagement.util.LoggingUtil;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.HubEntity;
|
||||
import net.gepafin.tendermanagement.entities.ProtocolEntity;
|
||||
import net.gepafin.tendermanagement.repositories.ProtocolRepository;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
|
||||
@@ -34,6 +50,50 @@ public class ProtocolDao {
|
||||
@Autowired
|
||||
private HttpServletRequest request;
|
||||
|
||||
@Autowired
|
||||
private ProtocolService protocolService;
|
||||
|
||||
@Value("${codAoo}")
|
||||
private String codAoo;
|
||||
|
||||
@Value("${sviluppumbria.username}")
|
||||
private String username;
|
||||
|
||||
@Value("${password}")
|
||||
private String password;
|
||||
|
||||
@Value("${CLASSIFICA}")
|
||||
private String classifica;
|
||||
|
||||
@Value("${TIPO_PROTOCOLLAZIONE}")
|
||||
private String TIPO_PROTOCOLLAZIONE;
|
||||
|
||||
@Value("${tipoCorrispondenteCompany}")
|
||||
private String tipoCorrispondenteCompany;
|
||||
|
||||
@Value("${tipoCorrispondenteWithoutCompany}")
|
||||
private String tipoCorrispondenteWithoutCompany;
|
||||
|
||||
@Value("${mezzo}")
|
||||
private String mezzo;
|
||||
|
||||
@Value("${indirizzoPec}")
|
||||
private String indirizzoPec;
|
||||
|
||||
@Value("${codiceUo}")
|
||||
private String codiceUo;
|
||||
|
||||
@Value("${competente}")
|
||||
private Boolean competente;
|
||||
|
||||
@Value("${tipoCorrispondente}")
|
||||
private String tipoCorrispondente;
|
||||
|
||||
@Autowired
|
||||
private ApplicationSignedDocumentRepository applicationSignedDocumentRepository;
|
||||
|
||||
public final Logger log = LoggerFactory.getLogger(ProtocolDao.class);
|
||||
|
||||
public Long getProtocolNumber(HubEntity hubEntity) {
|
||||
Long maxProtocolNumber = protocolRepository.findMaxProtocolNumberAndHubId(hubEntity.getId());
|
||||
Long startNumber = 10000001L;
|
||||
@@ -58,11 +118,159 @@ public class ProtocolDao {
|
||||
}else {
|
||||
protocolEntity.setType(ProtocolTypeEnum.OUTPUT.getValue());
|
||||
}
|
||||
|
||||
return protocolEntity;
|
||||
}
|
||||
|
||||
public void saveProtocolEntity(ProtocolEntity protocolEntity) {
|
||||
protocolRepository.save(protocolEntity);
|
||||
|
||||
/** This code is responsible for adding a version history log for "create protocol" operation. **/
|
||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(protocolEntity).build());
|
||||
|
||||
return protocolEntity;
|
||||
}
|
||||
|
||||
public String getBearerToken(String codAoo, String username, String password) {
|
||||
log.info("Requesting bearer token for user: {} and codAoo: {}", username, codAoo);
|
||||
|
||||
HttpHeaders httpHeaders = Utils.getHeaders();
|
||||
URI url = URI.create(GepafinConstant.PROTOCOL_SERVICE_BEARER_TOKEN);
|
||||
|
||||
try {
|
||||
ResponseEntity<String> response = protocolService.getBearerToken(httpHeaders, codAoo,username,password);
|
||||
|
||||
if (response != null && response.getStatusCode().is2xxSuccessful()) {
|
||||
log.debug("Bearer token successfully retrieved. HTTP Status: {}", response.getStatusCode());
|
||||
return response.getBody().toString(); // Use getBody() instead of toString()
|
||||
} else {
|
||||
log.warn("Bearer token request failed or returned unexpected status. Response: {}", response);
|
||||
}
|
||||
} catch (FeignException ex) {
|
||||
log.error("FeignException while retrieving bearer token for user {}: {}", username, ex.getMessage(), ex);
|
||||
Utils.callException(ex.status(), ex);
|
||||
} catch (Exception ex) {
|
||||
log.error("Unexpected exception while retrieving bearer token: {}", ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
log.warn("Returning null bearer token for user: {}", username);
|
||||
return null;
|
||||
}
|
||||
|
||||
public ProtocolEntity createExternalProtocol(ApplicationEntity application, CompanyEntity company, ProtocolEntity protocol) {
|
||||
log.info("Starting createExternalProtocol for application ID: {}", application.getId());
|
||||
|
||||
log.debug("Successfully retrieved bearer token");
|
||||
ApplicationSignedDocumentEntity applicationSignedDocumentEntity=applicationSignedDocumentRepository.findByApplicationIdAndStatus(application.getId(), ApplicationSignedDocumentStatusEnum.ACTIVE.getValue());
|
||||
|
||||
String year = String.valueOf(LocalDateTime.now().getYear());
|
||||
String applicationId = String.valueOf(application.getId());
|
||||
String mittenteValue="";
|
||||
String vatNumber ="";
|
||||
if(company!=null) {
|
||||
mittenteValue= tipoCorrispondenteCompany;
|
||||
vatNumber=company.getVatNumber();
|
||||
}else {
|
||||
mittenteValue = tipoCorrispondenteWithoutCompany;
|
||||
vatNumber = company.getCodiceFiscale();
|
||||
}
|
||||
String companyName = company.getCompanyName() + " " + vatNumber;
|
||||
String callName = application.getCall().getName()+" "+ application.getCall().getId();
|
||||
String callId = GepafinConstant.PROTOCOL_CALL_NAME+ String.valueOf(application.getCall().getId());
|
||||
String pecEmail=company.getPec();
|
||||
String docUrl=applicationSignedDocumentEntity.getFilePath();
|
||||
|
||||
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put(GepafinConstant.PROTOCOL_DOC_URL,docUrl);
|
||||
requestBody.put(GepafinConstant.PROTOCOL_COMPANY_NAME,companyName);
|
||||
requestBody.put(GepafinConstant.PROTOCOL_DOC_HASH,applicationSignedDocumentEntity.getFileHash());
|
||||
requestBody.put(GepafinConstant.PROTOCOL_TIPO_PROTOCOLLAZIONE,TIPO_PROTOCOLLAZIONE);
|
||||
Map<String, Object> mittente = new HashMap<>();
|
||||
mittente.put(GepafinConstant.PROTOCOL_TIPO_CORRISPONDENTE_COMPANY, mittenteValue);
|
||||
mittente.put(GepafinConstant.PROTOCOL_COMPANY_NAME_VAT_NUMBER,company.getCompanyName());
|
||||
mittente.put(GepafinConstant.PROTOCOL_MEZZO,mezzo);
|
||||
mittente.put(GepafinConstant.PROTOCOL_INDIRIZZO_PEC,pecEmail);
|
||||
mittente.put(GepafinConstant.PROTOCOL_COMPANY_VAT_NUMBER,vatNumber);
|
||||
List<Map<String,Object>> destinatariObject=new ArrayList<>();
|
||||
Map<String, Object> destinatari = new HashMap<>();
|
||||
destinatari.put(GepafinConstant.PROTOCOL_CODICE_UO,codiceUo);
|
||||
destinatari.put(GepafinConstant.PROTOCOL_COMPETENTE,competente);
|
||||
destinatari.put(GepafinConstant.PROTOCOL_TIPO_CORRISPONDENTE,tipoCorrispondente);
|
||||
requestBody.put(GepafinConstant.PROTOCOL_MITTENTE,mittente);
|
||||
destinatariObject.add(destinatari);
|
||||
requestBody.put(GepafinConstant.PROTOCOL_DESTINATARI,destinatariObject);
|
||||
List<Map<String,Object>> listObject=new ArrayList<>();
|
||||
listObject.add(requestBody);
|
||||
|
||||
log.info("Preparing to create protocol with data: year={}, applicationId={}, companyName={}, callName={}, callId={}",
|
||||
year, applicationId, companyName, callName, callId);
|
||||
ResponseEntity<Object> response=null;
|
||||
try {
|
||||
|
||||
String bearerToken = getBearerToken(codAoo, username, password);
|
||||
if (bearerToken == null) {
|
||||
log.error("Bearer token retrieval failed for user: {}", username);
|
||||
return protocol;
|
||||
}
|
||||
HttpHeaders httpHeaders = Utils.getHeaders();
|
||||
httpHeaders.set(GepafinConstant.AUTHORIZATION, "Bearer " + bearerToken);
|
||||
URI url = URI.create(GepafinConstant.PROTOCOL_SERVICE_CREATE_PROTOCOL);
|
||||
|
||||
response = protocolService.createProtocol(httpHeaders, classifica, year, applicationId, companyName, callName, callId,listObject
|
||||
);
|
||||
|
||||
log.info("Protocol creation response: status={}, body={}", response.getStatusCode(), response.getBody());
|
||||
|
||||
} catch (FeignException ex) {
|
||||
log.error("FeignException during protocol creation for application ID {}: {}", applicationId, ex.getMessage(), ex);
|
||||
// Utils.callException(ex.status(), ex);
|
||||
} catch (Exception ex) {
|
||||
log.error("Unexpected exception during protocol creation for application ID {}: {}", applicationId, ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
log.info("Finished createExternalProtocol for application ID: {}", application.getId());
|
||||
if(response!=null && response.getBody()!=null) {
|
||||
protocol = extractDetailForProtocol((List<Map<String, Object>>) response.getBody(), protocol);
|
||||
}
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public ProtocolEntity extractDetailForProtocol(List<Map<String,Object>> responseObject, ProtocolEntity protocol) {
|
||||
Map<String,Object> responseField= responseObject.get(0);
|
||||
Object yearObj = responseField.get(GepafinConstant.PROTOCOL_EXTERNAL_YEAR);
|
||||
Integer externalProtocolYear = null;
|
||||
if (yearObj instanceof Integer) {
|
||||
externalProtocolYear = (Integer) yearObj;
|
||||
} else if (yearObj instanceof String) {
|
||||
try {
|
||||
externalProtocolYear = Integer.parseInt((String) yearObj);
|
||||
} catch (NumberFormatException e) {
|
||||
// handle invalid format gracefully
|
||||
externalProtocolYear = null;
|
||||
}
|
||||
}
|
||||
|
||||
Object dateObj = responseField.get(GepafinConstant.PROTOCOL_EXTERNAL_DATE);
|
||||
LocalDateTime externalProtocolDate = null;
|
||||
|
||||
if (dateObj instanceof LocalDateTime) {
|
||||
externalProtocolDate = (LocalDateTime) dateObj;
|
||||
} else if (dateObj instanceof String) {
|
||||
externalProtocolDate = DateTimeUtil.parseStringToLocalDateTime((String) dateObj);
|
||||
}
|
||||
if(externalProtocolDate!=null){
|
||||
protocol.setExternalProtocolDate(externalProtocolDate);
|
||||
}
|
||||
if (externalProtocolYear!=null){
|
||||
protocol.setExternalProtocolYear(externalProtocolYear);
|
||||
|
||||
}
|
||||
|
||||
String externalProtocolNumber = (String) responseField.get(GepafinConstant.PROTOCOL_EXTERNAL_NUMBER);
|
||||
if (Boolean.FALSE.equals(StringUtils.isEmpty(externalProtocolNumber))) {
|
||||
protocol.setExternalProtocolNumber(externalProtocolNumber);
|
||||
}
|
||||
protocolRepository.save(protocol);
|
||||
return protocol;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,40 @@ 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());
|
||||
|
||||
List<EmailSendResponse> responses = new ArrayList<>();
|
||||
if(Boolean.FALSE.equals(roleEntity.getRoleType().equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue()))){
|
||||
sendEmailToOnboardingUser(userEntity, userReq );
|
||||
boolean isEmailSendSuccess = isEmailSentSuccessfully(userEntity.getId());
|
||||
EmailSendResponse emailSendResponse = new EmailSendResponse();
|
||||
if (Boolean.FALSE.equals(isEmailSendSuccess)){
|
||||
emailSendResponse.setIsEmailSend(false);
|
||||
Long userActionId =(Long)request.getAttribute(GepafinConstant.USER_ACTION_ID);
|
||||
emailSendResponse.setUserActionId(userActionId);
|
||||
emailSendResponse.setEmailScenario(EmailScenarioTypeEnum.USER_CREATION);
|
||||
|
||||
saveEmailSendResponseToUser(emailSendResponse,userEntity);
|
||||
responses = List.of(emailSendResponse);
|
||||
}
|
||||
else{
|
||||
responses = Collections.emptyList();
|
||||
}
|
||||
}
|
||||
JWTToken token = authService.getJWTTokenBean(userEntity, Boolean.TRUE, loginAttemptEntity.getId(),responses);
|
||||
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 +417,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 +495,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 +514,28 @@ 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);
|
||||
List<EmailSendResponse> responses = List.of(emailSendResponse);
|
||||
if (!Boolean.TRUE.equals(emailSendResponse.getIsEmailSend())){
|
||||
initiatePasswordResetResponse.setEmailSendResponse(responses);
|
||||
saveEmailSendResponseToUser(emailSendResponse,user);
|
||||
}
|
||||
else{
|
||||
initiatePasswordResetResponse.setEmailSendResponse(Collections.emptyList());
|
||||
}
|
||||
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(
|
||||
|
||||
@@ -3,12 +3,17 @@ package net.gepafin.tendermanagement.dao;
|
||||
import feign.FeignException;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.VatCheckVersionTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.response.VatCheckResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.CompanyRepository;
|
||||
import net.gepafin.tendermanagement.repositories.GlobalConfigRepository;
|
||||
import net.gepafin.tendermanagement.service.feignClient.VatCheckV1Service;
|
||||
import net.gepafin.tendermanagement.service.feignClient.VatCheckV2Service;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -48,6 +53,9 @@ public class VatCheckDao {
|
||||
@Autowired
|
||||
private GlobalConfigRepository globalConfigRepository;
|
||||
|
||||
@Autowired
|
||||
private CompanyRepository companyRepository;
|
||||
|
||||
public final Logger log = LoggerFactory.getLogger(VatCheckDao.class);
|
||||
|
||||
public VatCheckResponseBean checkVatNumberV1(String vatNumber) {
|
||||
@@ -56,6 +64,7 @@ public class VatCheckDao {
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
if (Boolean.TRUE.equals(Boolean.parseBoolean(isVatCheckGloballyDisabled))) {
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
vatCheckResponseBean.setVersion(VatCheckVersionTypeEnum.V1);
|
||||
return vatCheckResponseBean;
|
||||
}
|
||||
try {
|
||||
@@ -96,6 +105,7 @@ public class VatCheckDao {
|
||||
|
||||
public static void processValidResponseV1(Map<String, Object> responseMap, VatCheckResponseBean vatCheckResponseBean) {
|
||||
Object dataObj = responseMap.get("data");
|
||||
vatCheckResponseBean.setVersion(VatCheckVersionTypeEnum.V1);
|
||||
if (dataObj instanceof Map<?, ?> rawDataMap) {
|
||||
Map<String, Object> responseBody = new LinkedHashMap<>();
|
||||
rawDataMap.forEach((k, v) -> {
|
||||
@@ -118,9 +128,20 @@ public class VatCheckDao {
|
||||
|
||||
}
|
||||
|
||||
public VatCheckResponseBean checkVatNumber(String vatNumber) {
|
||||
public VatCheckResponseBean checkVatNumber(String vatNumber, Long hubId) {
|
||||
|
||||
try {
|
||||
CompanyEntity company = companyRepository.findByVatNumberAndHubId(vatNumber, hubId);
|
||||
|
||||
if (company != null && Boolean.FALSE.equals(StringUtils.isEmpty(company.getJson()))) {
|
||||
Map<String, Object> responseMap = Utils.convertJsonStringToMap(company.getJson());
|
||||
|
||||
VatCheckResponseBean jsonResponse = validateJsonFromDb(responseMap);
|
||||
if (jsonResponse != null) {
|
||||
return jsonResponse;
|
||||
}
|
||||
}
|
||||
|
||||
String vatApiVersion = getVatCheckVersion();
|
||||
if(!isVatCheckApiV2(vatApiVersion)){
|
||||
return checkVatNumberV1(vatNumber);
|
||||
@@ -134,6 +155,26 @@ public class VatCheckDao {
|
||||
return vatCheckResponseBean;
|
||||
}
|
||||
}
|
||||
private VatCheckResponseBean validateJsonFromDb(Map<String, Object> responseMap) {
|
||||
if (responseMap == null || !responseMap.containsKey("data")) return null;
|
||||
|
||||
Object data = responseMap.get("data");
|
||||
|
||||
if (data instanceof Map<?, ?> dataMap && !dataMap.isEmpty()) {
|
||||
VatCheckResponseBean response = new VatCheckResponseBean();
|
||||
processValidResponseV1(responseMap, response);
|
||||
return response;
|
||||
}
|
||||
|
||||
if (data instanceof List<?> dataList && !dataList.isEmpty()) {
|
||||
VatCheckResponseBean response = new VatCheckResponseBean();
|
||||
processValidResponse(responseMap, response);
|
||||
return response;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public VatCheckResponseBean checkVatNumberV2(String vatNumber) {
|
||||
|
||||
@@ -142,6 +183,7 @@ public class VatCheckDao {
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
if (Boolean.TRUE.equals(Boolean.parseBoolean(isVatCheckGloballyDisabled))) {
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
vatCheckResponseBean.setVersion(VatCheckVersionTypeEnum.V2);
|
||||
return vatCheckResponseBean;
|
||||
}
|
||||
try {
|
||||
@@ -175,6 +217,7 @@ public class VatCheckDao {
|
||||
|
||||
public static void processValidResponse(Map<String, Object> responseMap, VatCheckResponseBean vatCheckResponseBean) {
|
||||
|
||||
vatCheckResponseBean.setVersion(VatCheckVersionTypeEnum.V2);
|
||||
if (responseMap == null || !responseMap.containsKey("data")) {
|
||||
vatCheckResponseBean.setMessage(Translator.toLocale(GepafinConstant.INVALID_VATNUMBER));
|
||||
return;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.Immutable;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
@Entity
|
||||
@Immutable
|
||||
@Table(name = "application_form_view")
|
||||
@Getter
|
||||
@Setter
|
||||
@IdClass(ApplicationFormViewId.class)
|
||||
public class ApplicationFormView {
|
||||
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "application_id")
|
||||
private Long applicationId;
|
||||
|
||||
@Column(name = "call_id")
|
||||
private Long callId;
|
||||
|
||||
@Column(name = "form_id")
|
||||
private Long formId;
|
||||
|
||||
@Column(name = "application_form_id")
|
||||
private Long applicationFormId;
|
||||
|
||||
@Column(name = "field_id")
|
||||
private String fieldId;
|
||||
|
||||
@Column(name = "field_label")
|
||||
private String fieldLabel;
|
||||
|
||||
@Column(name = "field_type")
|
||||
private String fieldType;
|
||||
|
||||
@Column(name = "field_value")
|
||||
private String fieldValue;
|
||||
|
||||
@Column(name = "report_enable")
|
||||
private Boolean reportEnable;
|
||||
|
||||
@Column(name = "report_header")
|
||||
private String reportHeader;
|
||||
|
||||
@Column(name = "status")
|
||||
private String status;
|
||||
|
||||
@Column(name = "amount_requested")
|
||||
private BigDecimal amountRequested;
|
||||
|
||||
@Column(name = "amount_accepted")
|
||||
private BigDecimal amountAccepted;
|
||||
|
||||
@Column(name = "is_deleted")
|
||||
private boolean isDeleted;
|
||||
|
||||
@Column(name = "hub_id")
|
||||
private Long hubId;
|
||||
|
||||
@Column(name = "user_id")
|
||||
private Long userId;
|
||||
|
||||
@Column(name = "evaluation_version")
|
||||
private String evaluationVersion;
|
||||
|
||||
@Column(name = "company_id")
|
||||
private Long companyId;
|
||||
|
||||
@Column(name = "company_name")
|
||||
private String companyName;
|
||||
|
||||
@Column(name = "company_vat_number")
|
||||
private String companyVatNumber;
|
||||
|
||||
@Column(name = "codice_ateco")
|
||||
private String codiceAteco;
|
||||
|
||||
@Column(name = "company_codice_fiscale")
|
||||
private String companyCodiceFiscale;
|
||||
|
||||
@Column(name = "protocol_number")
|
||||
private Long protocolNumber;
|
||||
|
||||
@Column(name = "user_codice_fiscale")
|
||||
private String userCodiceFiscale;
|
||||
|
||||
@Column(name = "user_name")
|
||||
private String userName;
|
||||
|
||||
@Column(name = "legal_representative")
|
||||
private Boolean legalRepresentative;
|
||||
|
||||
@Column(name = "call_title")
|
||||
private String callTitle;
|
||||
|
||||
@Column(name = "call_end_date")
|
||||
private LocalDate callEndDate;
|
||||
|
||||
@Column(name = "call_end_time")
|
||||
private LocalTime callEndTime;
|
||||
|
||||
@Column(name = "call_start_date")
|
||||
private LocalDate callStartDate;
|
||||
|
||||
@Column(name = "call_start_time")
|
||||
private LocalTime callStartTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
@Data
|
||||
public class ApplicationFormViewId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Long id;
|
||||
|
||||
public ApplicationFormViewId() {
|
||||
}
|
||||
|
||||
public ApplicationFormViewId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@@ -25,4 +25,6 @@ public class ApplicationSignedDocumentEntity extends BaseEntity {
|
||||
@Column(name="STATUS")
|
||||
private String status;
|
||||
|
||||
@Column(name="FILE_HASH")
|
||||
private String fileHash;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -51,9 +51,6 @@ public class CompanyEntity extends BaseEntity{
|
||||
@JoinColumn(name = "HUB_ID")
|
||||
private HubEntity hub;
|
||||
|
||||
// @Column(name = "JSON")
|
||||
// private String json;
|
||||
|
||||
@Column(name = "NDG")
|
||||
private String ndg;
|
||||
|
||||
@@ -62,4 +59,7 @@ public class CompanyEntity extends BaseEntity{
|
||||
|
||||
@Column(name = "JSON")
|
||||
private String json;
|
||||
|
||||
@Column(name = "PEC")
|
||||
private String pec;
|
||||
}
|
||||
|
||||
@@ -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,43 @@
|
||||
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 {
|
||||
if (attribute == null) {
|
||||
attribute = List.of();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.config.LocalTimeAttributeConverter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
||||
@Entity
|
||||
@@ -33,4 +34,14 @@ public class ProtocolEntity extends BaseEntity {
|
||||
@Column(name = "type")
|
||||
private String type;
|
||||
|
||||
@Column(name = "external_protocol_year")
|
||||
private Integer externalProtocolYear;
|
||||
|
||||
@Column(name = "external_protocol_date")
|
||||
private LocalDateTime externalProtocolDate;
|
||||
|
||||
@Column(name = "external_protocol_number")
|
||||
private String externalProtocolNumber;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ import com.fasterxml.jackson.annotation.JsonValue;
|
||||
public enum EmailServiceTypeEnum {
|
||||
|
||||
MAILGUN_SERVICE("MAILGUN_SERVICE"),
|
||||
PEC_SERVICE("PEC_SERVICE");
|
||||
PEC_SERVICE("PEC_SERVICE"),
|
||||
SYSTEM_EMAIL_SERVICE("SYSTEM_EMAIL_SERVICE");
|
||||
|
||||
private 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 List<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;
|
||||
}
|
||||
|
||||
@@ -48,5 +48,6 @@ public class ApplicationEvaluationFormResponse {
|
||||
private Long appointmentTemplateId;
|
||||
private String companyVatNumber;
|
||||
private String companyCodiceAteco;
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
|
||||
}
|
||||
|
||||
@@ -49,5 +49,6 @@ public class ApplicationEvaluationResponse {
|
||||
private EvaluationVersionEnum evaluationVersion;
|
||||
private String companyVatNumber;
|
||||
private String companyCodiceAteco;
|
||||
private List<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;
|
||||
}
|
||||
@@ -11,4 +11,5 @@ public class ApplicationSignedDocumentResponse extends BaseBean{
|
||||
private String fileName;
|
||||
private String filePath;
|
||||
private ApplicationSignedDocumentStatusEnum status;
|
||||
private String fileHash;
|
||||
}
|
||||
|
||||
@@ -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,18 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EmailReminderResponse {
|
||||
|
||||
@JsonProperty("emailSendResponse")
|
||||
private List<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,15 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class InitiatePasswordResetResponse {
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
@@ -48,4 +48,5 @@ public class UserResponseBean extends BaseBean {
|
||||
private Boolean thirdParty;
|
||||
|
||||
private String emailPec;
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.gepafin.tendermanagement.enums.VatCheckVersionTypeEnum;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@@ -9,4 +11,5 @@ public class VatCheckResponseBean {
|
||||
private Boolean valid;
|
||||
private Map<String, Object> vatCheckResponse;
|
||||
private String message;
|
||||
private VatCheckVersionTypeEnum version;
|
||||
}
|
||||
|
||||
@@ -3,8 +3,11 @@ 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* JWTToken
|
||||
*/
|
||||
@@ -15,10 +18,20 @@ public class JWTToken {
|
||||
|
||||
@JsonProperty("user")
|
||||
private LoginResponse loginResponse;
|
||||
|
||||
@JsonProperty("emailSendResponse")
|
||||
private List<EmailSendResponse> emailSendResponse;
|
||||
|
||||
public JWTToken(String token, LoginResponse loginResponse) {
|
||||
this.token = token;
|
||||
this.loginResponse = loginResponse;
|
||||
}
|
||||
|
||||
public JWTToken(String token, LoginResponse loginResponse, List<EmailSendResponse> emailSendResponse) {
|
||||
this.token = token;
|
||||
this.loginResponse = loginResponse;
|
||||
this.emailSendResponse = emailSendResponse;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -150,4 +150,8 @@ public interface ApplicationAmendmentRequestRepository extends JpaRepository<App
|
||||
|
||||
@Query("SELECT COUNT(a) FROM ApplicationAmendmentRequestEntity a WHERE a.applicationId IN :applicationIds AND a.status IN :statuses AND a.isDeleted = false")
|
||||
Long countAmendmentsByApplicationIds(@Param("applicationIds") List<Long> applicationIds, @Param("statuses") List<String> statuses);
|
||||
|
||||
ApplicationAmendmentRequestEntity findByIdAndIsDeletedFalseAndStatus(Long id,String status);
|
||||
|
||||
ApplicationAmendmentRequestEntity findByIdAndIsDeletedFalseAndStatusIn(Long id, List<String> statusList);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.ApplicationFormView;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface ApplicationFormViewRepository extends JpaRepository<ApplicationFormView,Long>, JpaSpecificationExecutor<ApplicationFormView> {
|
||||
|
||||
@Query("SELECT v FROM ApplicationFormView v WHERE v.callId = :callId AND v.reportEnable = true")
|
||||
List<ApplicationFormView> findByCallId(Long callId);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package net.gepafin.tendermanagement.repositories;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationView;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ApplicationViewRepository extends JpaRepository<ApplicationView,Long> , JpaSpecificationExecutor<ApplicationView> {
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ public class ApplicationAmendmentScheduler {
|
||||
.findEvaluationsWithoutActiveAmendmentsByIds(applicationEvaluationIds);
|
||||
evaluationsWithoutActiveAmendmentList.forEach(evaluation -> {
|
||||
try {
|
||||
applicationAmendmentRequestDao.calculateEndDateAndSuspensionDays(evaluation);
|
||||
applicationAmendmentRequestDao.calculateEndDateAndSuspensionDaysOnExpirationOrClosing(evaluation);
|
||||
|
||||
updateEvaluationStatus(evaluation);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -87,7 +88,10 @@ public class ApplicationEvaluationScheduler {
|
||||
evaluation.setStatus(ApplicationEvaluationStatusTypeEnum.EXPIRED.getValue());
|
||||
evaluation = applicationEvaluationRepository.save(evaluation);
|
||||
|
||||
Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_EXPIRED);
|
||||
// Map<String, String> placeHolders = notificationDao.sendNotificationToBeneficiary(application, NotificationTypeEnum.EVALUATION_EXPIRED);
|
||||
Map<String, String> placeHolders = new HashMap<>();
|
||||
placeHolders.put("{{call_name}}", application.getCall().getName());
|
||||
placeHolders.put("{{protocol_number}}", String.valueOf(application.getProtocol().getProtocolNumber()));
|
||||
notificationDao.sendNotificationToSuperUser(application,placeHolders,NotificationTypeEnum.EVALUATION_EXPIRED);
|
||||
notificationDao.sendNotificationToInstructor(placeHolders,evaluation,NotificationTypeEnum.EVALUATION_EXPIRED);
|
||||
notificationDao.sendNotificationToInstructorManager(placeHolders,evaluation,NotificationTypeEnum.EVALUATION_EXPIRED);
|
||||
|
||||
@@ -21,4 +21,5 @@ AmazonS3Service {
|
||||
|
||||
UploadFileOnAmazonS3Response copyFile(String fileName, String oldS3Path, String newS3Path);
|
||||
|
||||
String extractS3KeyFromUrl(String url);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationPageableRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||
@@ -46,4 +47,9 @@ public interface ApplicationService {
|
||||
PageableResponseBean<List<ApplicationResponse>> getAllApplicationByPagination(HttpServletRequest request, Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean);
|
||||
|
||||
public ApplicationEntity validateApplicationWithCompany(Long applicationId,Long companyId);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.gepafin.tendermanagement.service.feignClient;
|
||||
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(value = "protocol-service" ,url = GepafinConstant.PROTOCOL_SERVICE_URL)
|
||||
public interface ProtocolService {
|
||||
|
||||
@PostMapping(GepafinConstant.PROTOCOL_SERVICE_BEARER_TOKEN)
|
||||
ResponseEntity<String> getBearerToken(@RequestHeader HttpHeaders headers,@RequestParam("codAoo") String codAoo,@RequestParam("username") String username,@RequestParam("password") String password
|
||||
);
|
||||
|
||||
@PutMapping(GepafinConstant.PROTOCOL_SERVICE_CREATE_PROTOCOL)
|
||||
ResponseEntity<Object> createProtocol(@RequestHeader HttpHeaders headers, @RequestParam("CLASSIFICA") String classifica, @RequestParam("ANNO_FASCICOLO") String year, @RequestParam("PROGR_FASCICOLO") String applicationId,
|
||||
@RequestParam("DES_FASCICOLO") String companyName, @RequestParam("PARENT_DES_FASCICOLO") String callName, @RequestParam("PARENT_PROGR_FASCICOLO") String callId, @RequestBody List<Map<String,Object>> requestBody
|
||||
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
@@ -217,4 +217,9 @@ public class AmazonS3ServiceImpl implements AmazonS3Service {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String extractS3KeyFromUrl(String url) {
|
||||
|
||||
return url.replace(s3Url, "");
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.dao.ApplicationDao;
|
||||
import net.gepafin.tendermanagement.dao.FlowFormDao;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationPageableRequestBean;
|
||||
@@ -15,6 +17,7 @@ import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
import net.gepafin.tendermanagement.service.CallService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
@@ -39,6 +42,9 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private CallService callService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ApplicationResponseBean createApplication(HttpServletRequest request,
|
||||
@@ -154,4 +160,20 @@ public class ApplicationServiceImpl implements ApplicationService {
|
||||
public ApplicationEntity validateApplicationWithCompany(Long applicationId,Long companyId) {
|
||||
return applicationDao.validateApplicationWithCompany(applicationId,companyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] exportCsv(HttpServletRequest request, Long callId) {
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
CallEntity call=callService.validateCall(callId);
|
||||
validator.validateHubId(request,call.getHub().getId());
|
||||
byte[] csvBytes= applicationDao.exportCsv(callId);
|
||||
|
||||
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, List<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)
|
||||
|
||||
@@ -83,7 +83,9 @@ public class CompanyServiceImpl implements CompanyService {
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public VatCheckResponseBean checkVatNumber(HttpServletRequest request, String vatNumber) {
|
||||
return vatCheckDao.checkVatNumber(vatNumber);
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
Long hubId = userEntity.getHub().getId();
|
||||
return vatCheckDao.checkVatNumber(vatNumber, hubId);
|
||||
}
|
||||
@Override
|
||||
public CompanyEntity validateCompany(Long companyId) {
|
||||
|
||||
@@ -12,13 +12,15 @@ public class EmailServiceFactory {
|
||||
@Autowired
|
||||
private MailgunEmailService mailgunEmailService;
|
||||
|
||||
@Autowired
|
||||
private SystemEmailService systemEmailService;
|
||||
|
||||
public EmailService getEmailService(String serviceType) {
|
||||
if ("MAILGUN_SERVICE".equals(serviceType)) {
|
||||
return mailgunEmailService;
|
||||
} else if ("PEC_SERVICE".equals(serviceType)) {
|
||||
return pecEmailService;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Invalid email service type: " + serviceType);
|
||||
}
|
||||
|
||||
return switch (serviceType) {
|
||||
case "PEC_SERVICE" -> pecEmailService;
|
||||
case "SYSTEM_EMAIL_SERVICE" -> systemEmailService;
|
||||
default -> mailgunEmailService;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -37,6 +44,12 @@ public class PecEmailService implements EmailService {
|
||||
@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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import com.mailgun.api.v3.MailgunMessagesApi;
|
||||
import com.mailgun.client.MailgunClient;
|
||||
import com.mailgun.model.message.MessageResponse;
|
||||
import net.gepafin.tendermanagement.dao.EmailLogDao;
|
||||
import net.gepafin.tendermanagement.entities.EmailLogEntity;
|
||||
import net.gepafin.tendermanagement.enums.EmailServiceTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.StatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.EmailConfig;
|
||||
import net.gepafin.tendermanagement.model.request.EmailLogRequest;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class SystemEmailService implements EmailService {
|
||||
|
||||
@Value("${mailGun_user}")
|
||||
public String mailGunUser;
|
||||
|
||||
@Value("${mailGun_apiKey}")
|
||||
public String mailGunApiKey;
|
||||
|
||||
@Value("${mailGun_domainName}")
|
||||
public String mailGunDomainName;
|
||||
|
||||
@Value("${mailGun_base_url}")
|
||||
public String mailGunBaseUrl;
|
||||
|
||||
@Value("${isMailSendingEnabled}")
|
||||
private String isEmailSendingEnabled;
|
||||
|
||||
@Autowired
|
||||
private Validator validator;
|
||||
|
||||
@Autowired
|
||||
private EmailLogDao emailLogDao;
|
||||
|
||||
public final Logger log = LoggerFactory.getLogger(SystemEmailService.class);
|
||||
|
||||
public void sendEmail(String subject, String body, List<String> recipientEmails, EmailConfig emailConfig, EmailLogRequest emailLogRequest) {
|
||||
|
||||
if (Boolean.FALSE.equals(Boolean.parseBoolean(isEmailSendingEnabled))) {
|
||||
return;
|
||||
}
|
||||
|
||||
emailLogRequest.setEmailSubject(subject);
|
||||
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 {
|
||||
MailgunMessagesApi mailgunMessagesApi = MailgunClient.config(mailGunBaseUrl, mailGunApiKey).createApi(MailgunMessagesApi.class);
|
||||
|
||||
String mailFrom = mailGunUser;
|
||||
com.mailgun.model.message.Message message = com.mailgun.model.message.Message.builder().from(mailFrom).to(recipientEmails).subject(subject).html(body).build();
|
||||
|
||||
response = mailgunMessagesApi.sendMessage(mailGunDomainName, message);
|
||||
} catch (Exception e) {
|
||||
emailLogRequest.setSendStatus(StatusTypeEnum.FAILED.getValue());
|
||||
emailLogRequest.setEmailServiceType(EmailServiceTypeEnum.SYSTEM_EMAIL_SERVICE);
|
||||
emailLogRequest.setErrorMessage(e.getMessage());
|
||||
emailLogDao.createEmailLog(emailLogRequest);
|
||||
|
||||
throw new RuntimeException("Failed to send email via Mailgun: " + (response != null ? response.getMessage() : "No response from Mailgun"), e);
|
||||
}
|
||||
if(response != null) {
|
||||
emailLogRequest.setEmailServiceResponse(response.toString());
|
||||
}
|
||||
|
||||
emailLogDao.createEmailLog(emailLogRequest);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -98,11 +98,19 @@ public class DateTimeUtil {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
return LocalDateTime.parse(dateTimeStr, formatter);
|
||||
}
|
||||
public static LocalDateTime parseStringToLocalDateTime(String timestampStr) {
|
||||
// Use ISO_LOCAL_DATE_TIME to parse the input string
|
||||
return LocalDateTime.parse(timestampStr, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
||||
}
|
||||
public static LocalDateTime parseStringToLocalDateTime(String dateStr) {
|
||||
if (dateStr == null || dateStr.isEmpty()) return null;
|
||||
|
||||
try {
|
||||
return LocalDateTime.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
return LocalDateTime.parse(dateStr, DateTimeFormatter.ISO_DATE_TIME); // fallback
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static String parseLocalTimeToString(LocalTime time, String format) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
|
||||
return time.format(formatter);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package net.gepafin.tendermanagement.util;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
@Component
|
||||
public class FileHashUtil {
|
||||
|
||||
public static String calculateSHA256(InputStream inputStream) throws IOException {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
|
||||
try (DigestInputStream dis = new DigestInputStream(inputStream, md)) {
|
||||
byte[] buffer = new byte[8192];
|
||||
while (dis.read(buffer) != -1) {
|
||||
// reading to compute hash
|
||||
}
|
||||
}
|
||||
|
||||
byte[] digest = md.digest();
|
||||
return bytesToHex(digest);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not generate hash", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String bytesToHex(byte[] bytes) {
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte b : bytes) {
|
||||
String hex = Integer.toHexString(0xff & b);
|
||||
if (hex.length() == 1) hexString.append('0');
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
}
|
||||
}
|
||||
@@ -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,15 +37,18 @@ 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;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
@@ -57,6 +61,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
|
||||
import feign.FeignException;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
@@ -291,11 +296,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
|
||||
@@ -986,5 +994,63 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
}
|
||||
public static List<Map<String, Object>> convertJsonToListMap(String jsonString) {
|
||||
try {
|
||||
if (jsonString == null || jsonString.trim().isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String unescaped;
|
||||
|
||||
// First try: parse as if it's double-encoded (escaped string containing a JSON array)
|
||||
try {
|
||||
unescaped = objectMapper.readValue(jsonString, String.class);
|
||||
} catch (Exception e) {
|
||||
// If that fails, assume it's already a proper JSON array
|
||||
unescaped = jsonString;
|
||||
}
|
||||
|
||||
// Now parse the actual JSON array
|
||||
return objectMapper.readValue(unescaped, new TypeReference<List<Map<String, Object>>>() {});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
public static HttpHeaders getHeaders(){
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
headers.add(org.apache.http.HttpHeaders.USER_AGENT, "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0");
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -2,11 +2,12 @@ package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationPageableRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationRequestBean;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -18,10 +19,8 @@ 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.ApplicationRequest;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
|
||||
@@ -224,5 +223,35 @@ public interface ApplicationApi {
|
||||
ResponseEntity<Response<PageableResponseBean<List<ApplicationResponse>>>> getAllApplicationByPagination(HttpServletRequest request,@Parameter(description = "The call id", required = false) @RequestParam(value = "callId", required = false) Long callId,
|
||||
@Parameter(description = "The company id", required = false) @RequestParam(value = "companyId", required = false) Long companyId, @RequestBody ApplicationPageableRequestBean applicationPageableRequestBean);
|
||||
|
||||
@Operation(summary = "Api to download application data as a CSV file using the call ID",
|
||||
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)}))
|
||||
})
|
||||
@GetMapping(value = "/call/{callId}/csv")
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -176,15 +173,20 @@ 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);
|
||||
|
||||
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
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
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.ApplicationPageableRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequest;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.FormActionEnum;
|
||||
import net.gepafin.tendermanagement.model.request.ApplicationRequestBean;
|
||||
import net.gepafin.tendermanagement.model.request.UserActionRequest;
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.ApplicationService;
|
||||
@@ -236,5 +234,24 @@ public class ApplicationApiController implements ApplicationApi {
|
||||
.getAllApplicationByPagination(request, callId,companyId,applicationPageableRequestBean);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new Response<>(pageableResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<byte[]> exportCsv(HttpServletRequest request, Long callId) {
|
||||
byte[] csvBytes =applicationService.exportCsv(request,callId);
|
||||
return ResponseEntity.ok()
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=applications.csv")
|
||||
.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)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -26,7 +26,7 @@ default.hub.uuid=p4lk3bcx1RStqTaIVVbXs
|
||||
#Login to Odessa, Appointment Creation, Upload document Configuration
|
||||
appointment.base.url=https://prd.galileonetwork.it/gateway/rest
|
||||
appointment.portal.user=UtenzaAPIPortal@621
|
||||
appointment.portal.password=u13nzaAP1P0rtal!
|
||||
appointment.portal.password=Valeria2016!!
|
||||
appointment.portal.source=GEPAFINPORTAL
|
||||
appointment.portal.context=GEPAFINPORTAL
|
||||
|
||||
|
||||
@@ -56,7 +56,10 @@ active.profile.folder=dev
|
||||
|
||||
# MailGun API
|
||||
mailGun_base_url=https://api.eu.mailgun.net/
|
||||
|
||||
#Below credentials are only for sending mail to rinaldo
|
||||
mailGun_apiKey= 398e3dea1911fe941af261906ec99362-07e2c238-8094421f
|
||||
mailGun_user=comunicazione@paghiamoci.ai
|
||||
mailGun_domainName=paghiamoci.ai
|
||||
|
||||
api.pecUrl=https://ws.pecmassiva.com
|
||||
#senderEmail=mailer@bflows.net
|
||||
@@ -73,3 +76,18 @@ spring.rabbitmq.connection-timeout=120000
|
||||
|
||||
app.bandi.login.url.suffix=/loginadmin
|
||||
app.confidi.login.url.suffix=/confidi
|
||||
|
||||
#sviluppumbria protocol
|
||||
codAoo=SVILUMBRIA-01
|
||||
sviluppumbria.username=protocollatoresvilumbria
|
||||
password=8e85ea4265e49497d697168fd3d34916
|
||||
CLASSIFICA=06.004.3
|
||||
TIPO_PROTOCOLLAZIONE=E
|
||||
tipoCorrispondenteCompany=PersonaGiuridica
|
||||
tipoCorrispondenteWithoutCompany=Persona
|
||||
mezzo=Altro
|
||||
indirizzoPec=ufficio01@domain.com
|
||||
codiceUo=101_10
|
||||
competente=true
|
||||
tipoCorrispondente=Amministrazione
|
||||
sviluppumbriaUuid=t7jh5wfg9QXylNaTZkPoE
|
||||
|
||||
@@ -2653,6 +2653,8 @@
|
||||
<column name="file_path" value="https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/local/template/PROCURA_BANDI_TEMPLATE_CONFIDI.docx"></column>
|
||||
<column name="type" value="DOCUMENT"></column>
|
||||
<column name="source" value="DELEGATION_TEMPLATE_CONFIDI"></column>
|
||||
<column name="created_date" value="2025-05-21 03:00:00"/>
|
||||
<column name="updated_date" value="2025-05-21 03:00:00"/>
|
||||
</insert>
|
||||
</changeSet>
|
||||
|
||||
@@ -2666,14 +2668,27 @@
|
||||
<column name="file_path" value="https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/local/template/true.png"></column>
|
||||
<column name="type" value="IMAGE"></column>
|
||||
<column name="source" value="PDF_TRUE"></column>
|
||||
<column name="created_date" value="2025-05-21 03:00:00"/>
|
||||
<column name="updated_date" value="2025-05-21 03:00:00"/>
|
||||
</insert>
|
||||
<insert tableName="document">
|
||||
<column name="file_name" value="GEPAFIN_PDF_FALSE.PNG"></column>
|
||||
<column name="file_path" value="https://mementoresources.s3.eu-west-1.amazonaws.com/gepafin/local/template/false.png"></column>
|
||||
<column name="type" value="IMAGE"></column>
|
||||
<column name="source" value="PDF_FALSE"></column>
|
||||
<column name="created_date" value="2025-05-21 03:00:00"/>
|
||||
<column name="updated_date" value="2025-05-21 03:00:00"/>
|
||||
</insert>
|
||||
</changeSet>
|
||||
<changeSet id="14-04-2025_RK_161000" author="Rajesh Khore">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/update_form_field_data_14_04_2025.sql"/>
|
||||
</changeSet>
|
||||
<changeSet id="09-04-2025_NK_172550" author="Nisha Kashyap">
|
||||
<sqlFile
|
||||
dbms="postgresql"
|
||||
path="db/dump/create_application_form_view.sql"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="25-03-2025_NK_160730" author="Nisha Kashyap">
|
||||
<sqlFile dbms="postgresql"
|
||||
@@ -2727,8 +2742,91 @@
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/create_assigned_application_view.sql"/>
|
||||
</changeSet>
|
||||
<changeSet id="14-04-2025_RK_161000" author="Rajesh Khore">
|
||||
|
||||
<changeSet id="28-04-2025_PK_154315" author="Piyush Kag">
|
||||
<sqlFile dbms="postgresql"
|
||||
path="db/dump/update_form_field_data_14_04_2025.sql"/>
|
||||
path="db/dump/update_json_template_for_notification_28_04_2025.sql"/>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="28-04-2025_PK_163615" author="Piyush Kag">
|
||||
<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>
|
||||
|
||||
<changeSet id="26-05-2025_RK_184320" author="Rajesh Khore">
|
||||
<addColumn tableName="application_signed_document">
|
||||
<column name="file_hash" type="VARCHAR(255)"></column>
|
||||
</addColumn>
|
||||
|
||||
|
||||
<addColumn tableName="protocol">
|
||||
<column name="external_protocol_number" type="VARCHAR(255)"/>
|
||||
<column name="external_protocol_year" type="INTEGER"/>
|
||||
<column name="external_protocol_date" type="TIMESTAMP WITHOUT TIME ZONE"/>
|
||||
</addColumn>
|
||||
|
||||
<addColumn tableName="company">
|
||||
<column name="pec" type="VARCHAR(255)"></column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
||||
125
src/main/resources/db/dump/create_application_form_view.sql
Normal file
125
src/main/resources/db/dump/create_application_form_view.sql
Normal file
@@ -0,0 +1,125 @@
|
||||
CREATE OR REPLACE VIEW gepafin_schema.application_form_view AS
|
||||
SELECT app_data.id,
|
||||
app_data.call_id,
|
||||
app_data.application_form_id,
|
||||
app_data.form_id,
|
||||
app_data.application_id,
|
||||
field_data.value ->> 'id' AS field_id,
|
||||
COALESCE(
|
||||
(SELECT s.value ->> 'value'
|
||||
FROM jsonb_array_elements(field_data.value -> 'settings') s(value)
|
||||
WHERE s.value ->> 'name' = 'label'
|
||||
LIMIT 1),
|
||||
field_data.value ->> 'label'
|
||||
) AS field_label,
|
||||
(
|
||||
SELECT (s.value ->> 'value')::boolean
|
||||
FROM jsonb_array_elements(field_data.value -> 'settings') s(value)
|
||||
WHERE s.value ->> 'name' = 'reportEnable'
|
||||
LIMIT 1
|
||||
) AS report_enable,
|
||||
COALESCE( (SELECT s.value ->> 'value'
|
||||
FROM jsonb_array_elements(field_data.value -> 'settings') s(value)
|
||||
WHERE s.value ->> 'name' = 'reportHeader'
|
||||
LIMIT 1),
|
||||
field_data.value ->> 'reportHeader'
|
||||
) AS report_header,
|
||||
field_data.value ->> 'name' AS field_type,
|
||||
CASE
|
||||
WHEN field_data.value ->> 'name' = 'fileupload' THEN
|
||||
to_jsonb((
|
||||
SELECT string_agg(d.file_name, ', ')
|
||||
FROM unnest(string_to_array(app_data.field_value, ',')) file_ids(file_id)
|
||||
JOIN gepafin_schema.document d ON d.id::text = file_ids.file_id
|
||||
WHERE d.is_deleted = false
|
||||
))
|
||||
WHEN field_data.value ->> 'name' IN ('checkboxes', 'select', 'radio') THEN
|
||||
CASE
|
||||
WHEN app_data.field_value ~~ '[%' THEN
|
||||
to_jsonb((
|
||||
SELECT string_agg(opt.value ->> 'label', ', ')
|
||||
FROM jsonb_array_elements_text(app_data.field_value::jsonb) selected_id(value)
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT s.value
|
||||
FROM jsonb_array_elements(field_data.value -> 'settings') s(value)
|
||||
WHERE s.value ->> 'name' = 'options'
|
||||
) options_setting,
|
||||
LATERAL jsonb_array_elements(options_setting.value -> 'value') opt(value)
|
||||
WHERE opt.value ->> 'name' = selected_id.value
|
||||
))
|
||||
ELSE
|
||||
to_jsonb((
|
||||
SELECT opt.value ->> 'label'
|
||||
FROM (
|
||||
SELECT s.value
|
||||
FROM jsonb_array_elements(field_data.value -> 'settings') s(value)
|
||||
WHERE s.value ->> 'name' = 'options'
|
||||
) options_setting,
|
||||
LATERAL jsonb_array_elements(options_setting.value -> 'value') opt(value)
|
||||
WHERE opt.value ->> 'name' = app_data.field_value
|
||||
LIMIT 1
|
||||
))
|
||||
END
|
||||
ELSE
|
||||
to_jsonb(app_data.field_value)
|
||||
END AS field_value,
|
||||
app_data.status,
|
||||
app_data.amount_requested,
|
||||
app_data.amount_accepted,
|
||||
app_data.is_deleted,
|
||||
app_data.hub_id,
|
||||
app_data.user_id,
|
||||
app_data.evaluation_version,
|
||||
app_data.company_id,
|
||||
c.company_name,
|
||||
c.vat_number AS company_vat_number,
|
||||
c.codice_ateco,
|
||||
c.codice_fiscale AS company_codice_fiscale,
|
||||
p.protocol_number,
|
||||
b.codice_fiscale AS user_codice_fiscale,
|
||||
COALESCE(NULLIF(TRIM(BOTH FROM CONCAT(COALESCE(u.first_name, ''), ' ', COALESCE(u.last_name, ''))), ''), '') AS user_name,
|
||||
uwc.is_legal_representant AS legal_representative,
|
||||
cl.name AS call_title,
|
||||
cl.end_date AS call_end_date,
|
||||
cl.end_time AS call_end_time,
|
||||
cl.start_date AS call_start_date,
|
||||
cl.start_time AS call_start_time
|
||||
FROM (
|
||||
SELECT a.id AS application_id,
|
||||
a.call_id,
|
||||
a.protocol_number,
|
||||
af.id AS application_form_id,
|
||||
af.form_id AS form_id,
|
||||
aff.id AS id,
|
||||
aff.field_value,
|
||||
a.status,
|
||||
a.amount_requested,
|
||||
a.amount_accepted,
|
||||
a.is_deleted,
|
||||
a.hub_id,
|
||||
a.user_id,
|
||||
a.evaluation_version,
|
||||
a.created_date,
|
||||
a.company_id,
|
||||
aff.field_id,
|
||||
f.content
|
||||
FROM gepafin_schema.application a
|
||||
JOIN gepafin_schema.application_form af ON af.application_id = a.id
|
||||
JOIN gepafin_schema.application_form_field aff ON aff.application_form_id = af.id
|
||||
JOIN gepafin_schema.form f ON f.id = af.form_id
|
||||
WHERE a.is_deleted = false
|
||||
) app_data
|
||||
CROSS JOIN LATERAL (
|
||||
SELECT jsonb_array_elements.value
|
||||
FROM jsonb_array_elements(app_data.content::jsonb) jsonb_array_elements(value)
|
||||
WHERE jsonb_array_elements.value ->> 'id' = app_data.field_id::text
|
||||
) field_data(value)
|
||||
LEFT JOIN gepafin_schema.call cl ON app_data.call_id = cl.id
|
||||
LEFT JOIN gepafin_schema.company c ON app_data.company_id = c.id
|
||||
LEFT JOIN gepafin_schema.protocol p ON app_data.protocol_number = p.id
|
||||
LEFT JOIN gepafin_schema.gepafin_user u ON app_data.user_id = u.id
|
||||
LEFT JOIN gepafin_schema.user_with_company uwc ON app_data.user_id = uwc.user_id AND app_data.company_id = uwc.company_id AND uwc.is_deleted = false
|
||||
LEFT JOIN gepafin_schema.beneficiary b ON u.beneficiary_id = b.id
|
||||
WHERE app_data.id IS NOT NULL
|
||||
AND app_data.status NOT IN ('DRAFT', 'AWAITING', 'READY')
|
||||
ORDER BY app_data.id, field_data.value ->> 'id';
|
||||
@@ -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;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user