diff --git a/src/main/java/net/gepafin/tendermanagement/config/SamlFailureHandler.java b/src/main/java/net/gepafin/tendermanagement/config/SamlFailureHandler.java index 52b30dbd..bdbd0801 100644 --- a/src/main/java/net/gepafin/tendermanagement/config/SamlFailureHandler.java +++ b/src/main/java/net/gepafin/tendermanagement/config/SamlFailureHandler.java @@ -58,14 +58,16 @@ public class SamlFailureHandler implements AuthenticationFailureHandler { feBaseUrl = hub.getDomainName(); } } - response.sendRedirect(feBaseUrl + "/login"); + String redirectUrl = feBaseUrl + "/login"; + response.sendRedirect(redirectUrl); + logger.info("SAML redirect Url: " + redirectUrl); } catch (Exception e) { logger.error("Error processing SAML failure handler", e); } } public static String extractInResponseTo(String message) { - String regex = "InResponseTo attribute \\[([a-zA-Z0-9\\-]+)\\]"; + String regex = "InResponseTo attribute \\[([a-zA-Z0-9\\-_]+)\\]"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(message); diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index e2dcda8e..34a05ca6 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -381,11 +381,11 @@ public class GepafinConstant { public static final String NUMERIC="numeric"; public static final String AMOUNT_ACCEPTED_REQUIRED_WHILE_APPROVING_APPLICATION="amount.accepted.required"; public static final String CALL_NAME="callName"; - public static final String NUMBER_OF_APPLICATIONS="numberOfApplications"; + public static final String NUMBER_OF_APPLICATIONS="numberOfSubmitedApplications"; + public static final String NUMBER_OF_DRAFT_APPLICATIONS="numberOfDraftApplications"; public static final String COUNT="count"; public static final String APPLICATION_PER_CALL="applicationPerCall"; public static final String APPLICATION_PER_STATUS="applicationPerStatus"; - - + public static final String CALL_EXPIRED="call.expired"; } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index b7602621..ba847ca3 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -49,7 +49,9 @@ import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; import java.text.MessageFormat; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.*; import java.util.stream.Collectors; import java.util.zip.ZipEntry; @@ -186,6 +188,7 @@ public class ApplicationDao { // callService.validatePublishedCall(formEntity.getCall().getId()); validateFormFields(applicationRequestBean,formEntity); ApplicationEntity applicationEntity = validateApplication(applicationId); + checkCallEndDate(applicationEntity.getCall()); validator.validateUserWithCompany(request, applicationEntity.getCompanyId()); if(Boolean.FALSE.equals(applicationEntity.getStatus().equals(ApplicationStatusTypeEnum.DRAFT.getValue()))) { throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.APPLICATION_NOT_IN_DRAFT_STATUS)); @@ -405,6 +408,7 @@ public class ApplicationDao { responseBean.setProgress(progress); responseBean.setCallTitle(applicationEntity.getCall().getName()); responseBean.setCallEndDate(applicationEntity.getCall().getEndDate()); + responseBean.setCallEndTime(applicationEntity.getCall().getEndTime()); responseBean.setModifiedDate(applicationEntity.getCall().getUpdatedDate()); responseBean.setCallId(applicationEntity.getCall().getId()); responseBean.setSubmissionDate(applicationEntity.getSubmissionDate()); @@ -872,7 +876,7 @@ public class ApplicationDao { ApplicationRequest applicationRequest, Long callId, UserEntity userEntity) { CallEntity call = callService.validateCall(callId); UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(userEntity.getId(),companyEntity.getId()); - + checkCallEndDate(call); // call = callService.validatePublishedCall(call.getId()); // checkIfApplicationExists(call, userWithCompanyEntity, userEntity); ApplicationEntity applicationEntity = createApplicationEntity(userEntity, call, userWithCompanyEntity); @@ -890,7 +894,7 @@ public class ApplicationDao { public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) { ApplicationEntity applicationEntity = validateApplication(applicationId); - + checkCallEndDate(applicationEntity.getCall()); //cloned entity for old application data ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity); @@ -1119,7 +1123,7 @@ public class ApplicationDao { public ApplicationSignedDocumentResponse uploadSignedDocument(HttpServletRequest request, Long applicationId, MultipartFile file) { ApplicationEntity applicationEntity = validateApplication(applicationId); - + checkCallEndDate(applicationEntity.getCall()); //cloned entity for old data ApplicationEntity oldApplicationData = Utils.getClonedEntityForData(applicationEntity); @@ -1252,7 +1256,8 @@ public class ApplicationDao { ApplicationEntity applicationEntity = validateApplication(applicationId); ApplicationEntity oldApplicationEntity = Utils.getClonedEntityForData(applicationEntity); - + checkCallEndDate(applicationEntity.getCall()); + UserEntity userEntity = userService.validateUser(applicationEntity.getUserId()); validator.validateUserWithCompany(request, applicationEntity.getCompanyId()); if (Boolean.FALSE.equals(ApplicationStatusTypeEnum.DRAFT.getValue().equals(applicationEntity.getStatus()))) { @@ -1516,4 +1521,21 @@ public class ApplicationDao { return predicates; } + public void checkCallEndDate(CallEntity call) { + LocalDateTime now = DateTimeUtil.DateServerToUTC(LocalDateTime.now()); + + LocalDateTime callEndDateTime = LocalDateTime.of( + call.getEndDate().toLocalDate(), + call.getEndTime() + ); + + if (now.isAfter(callEndDateTime)) { + throw new CustomValidationException( + Status.BAD_REQUEST, + Translator.toLocale(GepafinConstant.CALL_EXPIRED) + ); + } + } + + } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java index 8c89b510..48573e4f 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationEvaluationDao.java @@ -113,12 +113,21 @@ public class ApplicationEvaluationDao { @Autowired private ApplicationAmendmentRequestDao applicationAmendmentRequestDao; + @Autowired + private HubService hubService; + private ApplicationEvaluationEntity convertToEntity(UserEntity user, ApplicationEvaluationRequest req, Long assignedApplciationId) { ApplicationEvaluationEntity entity = new ApplicationEvaluationEntity(); AssignedApplicationsEntity assignedApplications = assignedApplicationsService.validateAssignedApplication(assignedApplciationId); ApplicationEntity application = applicationService.validateApplication(assignedApplications.getApplication().getId()); + + Long hubId = application.getHubId(); + HubEntity hub = hubService.valdateHub(hubId); + + Long initialDays = (hub != null) ? hub.getEvaluationExpirationDays() : 0L; + entity.setApplicationId(application.getId()); entity.setAssignedApplicationsEntity(assignedApplications); entity.setUserId(user.getId()); @@ -128,7 +137,7 @@ public class ApplicationEvaluationDao { entity.setNote(req.getNote()); entity.setMotivation(req.getMotivation()); entity.setIsDeleted(false); - entity.setInitialDays(30L); + entity.setInitialDays(initialDays); entity.setRemainingDays(30L); entity.setSuspendedDays(0L); entity.setStartDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now())); diff --git a/src/main/java/net/gepafin/tendermanagement/dao/DashboardDao.java b/src/main/java/net/gepafin/tendermanagement/dao/DashboardDao.java index 53309e9d..1f17ef3e 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/DashboardDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/DashboardDao.java @@ -187,7 +187,8 @@ public class DashboardDao { stats.put(GepafinConstant.APPLICATION_PER_CALL, applicationsPerCall.stream().map(result -> { Map callData = new HashMap<>(); callData.put(GepafinConstant.CALL_NAME, result[0]); // Call name - callData.put(GepafinConstant.NUMBER_OF_APPLICATIONS, result[1]); // Application count + callData.put(GepafinConstant.NUMBER_OF_APPLICATIONS, result[1]);// Application count + callData.put(GepafinConstant.NUMBER_OF_DRAFT_APPLICATIONS, result[2]);// Application count return callData; }).toList()); diff --git a/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java b/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java index faec3489..bf68f3b9 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/FlowFormDao.java @@ -296,6 +296,8 @@ public class FlowFormDao { applicationDao.processForm(formEntity, applicationEntity)); nextOrPreviousFormResponse.setCallId(applicationEntity.getCall().getId()); nextOrPreviousFormResponse.setCallTitle(applicationEntity.getCall().getName()); + nextOrPreviousFormResponse.setCallEndDate(applicationEntity.getCall().getEndDate()); + nextOrPreviousFormResponse.setCallEndTime(applicationEntity.getCall().getEndTime()); nextOrPreviousFormResponse.setCompanyId(applicationEntity.getCompanyId()); nextOrPreviousFormResponse.setCompanyName(company.getCompanyName()); diff --git a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java index 28be65b9..ec7b53da 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/PdfDao.java @@ -264,8 +264,10 @@ public class PdfDao { Map formulaEnabledMap = new HashMap<>(); Map formulaTypeMap = new HashMap<>(); Map fieldTypeMap = new HashMap<>(); + Font lightGrayFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new BaseColor(110, 110, 110)); // Light gray - contentResponseBean.getSettings().stream() + + contentResponseBean.getSettings().stream() .filter(setting -> "table_columns".equals(setting.getName())) // Check for "table_columns" .map(SettingResponseBean::getValue) .filter(Objects::nonNull) // Ensure value is not null @@ -375,9 +377,17 @@ public class PdfDao { if (columnSums.containsKey(key)) { double total = columnSums.getOrDefault(key, 0.0); // Get the total for the column - PdfPCell sumCell = PdfUtils.htmlToPdfPCell(Utils.convertToItalianFormat(String.valueOf(total)), textFont); +// PdfPCell sumCell = PdfUtils.htmlToPdfPCell(Utils.convertToItalianFormat(String.valueOf(total)), textFont); + // Convert total to Italian format, defaulting to "0" if null + String formattedTotal = Utils.convertToItalianFormat(String.valueOf(total)); + + // Create a table cell with the formatted value + PdfPCell sumCell = new PdfPCell(new Phrase(formattedTotal,lightGrayFont)); + + sumCell.setBackgroundColor(new BaseColor(239, 243, 248)); // Light blue for totals sumCell.setHorizontalAlignment(Element.ALIGN_CENTER); + sumCell.setPaddingTop(8f); sumCell.setMinimumHeight(30f); table.addCell(sumCell); // Add total for the column } else { diff --git a/src/main/java/net/gepafin/tendermanagement/entities/HubEntity.java b/src/main/java/net/gepafin/tendermanagement/entities/HubEntity.java index 52aa6cc2..ccd6c325 100644 --- a/src/main/java/net/gepafin/tendermanagement/entities/HubEntity.java +++ b/src/main/java/net/gepafin/tendermanagement/entities/HubEntity.java @@ -63,4 +63,7 @@ public class HubEntity extends BaseEntity{ @Column(name = "AREA_CODE") private String areaCode; + + @Column(name = "EVALUATION_EXPIRATION_DAYS") + private Long evaluationExpirationDays; } diff --git a/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationResponse.java b/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationResponse.java index 1aae69e2..2c659838 100644 --- a/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationResponse.java +++ b/src/main/java/net/gepafin/tendermanagement/model/response/ApplicationResponse.java @@ -5,6 +5,7 @@ import net.gepafin.tendermanagement.model.response.ApplicationFormFieldResponseB import java.math.BigDecimal; import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.List; @Data @@ -18,6 +19,8 @@ public class ApplicationResponse{ private LocalDateTime callEndDate; + private LocalTime callEndTime; + private LocalDateTime modifiedDate; private Integer progress; diff --git a/src/main/java/net/gepafin/tendermanagement/model/response/NextOrPreviousFormResponse.java b/src/main/java/net/gepafin/tendermanagement/model/response/NextOrPreviousFormResponse.java index bea417a1..6bed05fc 100644 --- a/src/main/java/net/gepafin/tendermanagement/model/response/NextOrPreviousFormResponse.java +++ b/src/main/java/net/gepafin/tendermanagement/model/response/NextOrPreviousFormResponse.java @@ -5,6 +5,7 @@ import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.time.LocalTime; @Data public class NextOrPreviousFormResponse { @@ -20,6 +21,10 @@ public class NextOrPreviousFormResponse { private Long completedSteps; private Long currentStep; + + private LocalDateTime callEndDate; + + private LocalTime callEndTime; private Long companyId; diff --git a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java index c46c52c7..086b0807 100644 --- a/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java +++ b/src/main/java/net/gepafin/tendermanagement/repositories/ApplicationRepository.java @@ -45,9 +45,25 @@ public interface ApplicationRepository extends JpaRepository findApplicationsPerCallWithName(@Param("hubId") Long hubId); + + @Query(value = "SELECT c.name AS callName, " + + "SUM(CASE WHEN a.status IN ('DISCARD', 'SOCCORSO', 'APPROVED', 'REJECTED', 'EVALUATION', 'APPOINTMENT', 'NDG', 'ADMISSIBLE', 'SUBMIT') THEN 1 ELSE 0 END) AS totalApplications, " + + "SUM(CASE WHEN a.status IN ('DRAFT', 'AWAITING', 'READY') THEN 1 ELSE 0 END) AS draftApplications " + + "FROM ApplicationEntity a " + + "JOIN a.call c " + + "WHERE a.isDeleted = false AND c.hub.id = :hubId " + + "GROUP BY c.name") List findApplicationsPerCallWithName(@Param("hubId") Long hubId); + // Count Applications by Status by Hub ID @Query("SELECT a.status, COUNT(a.id) FROM ApplicationEntity a WHERE a.isDeleted = false AND a.call.hub.id = :hubId GROUP BY a.status") List findApplicationsByStatus(@Param("hubId") Long hubId); diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/AmazonS3ServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/AmazonS3ServiceImpl.java index 8221117a..9909f732 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/AmazonS3ServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/AmazonS3ServiceImpl.java @@ -153,11 +153,17 @@ public class AmazonS3ServiceImpl implements AmazonS3Service { } } + private String decodeS3Key(String key) { + return URLDecoder.decode(key, StandardCharsets.UTF_8); + } + @Override public UploadFileOnAmazonS3Response moveFile(String fileName, String oldPath, String newPath) { try { + log.info("Original Paths - oldPath: {}, newPath: {}", oldPath, newPath); + + oldPath = decodeS3Key(cleanOldPath(oldPath)); newPath = cleanNewPath(oldPath, newPath); - oldPath = cleanOldPath(oldPath); log.info("Moving file from {} to {} in bucket {}", oldPath, newPath, bucketName); CopyObjectRequest copyRequest = new CopyObjectRequest(bucketName, oldPath, bucketName, newPath); diff --git a/src/main/resources/db/changelog/db.changelog-1.0.0.xml b/src/main/resources/db/changelog/db.changelog-1.0.0.xml index bf3fd60b..59d3147a 100644 --- a/src/main/resources/db/changelog/db.changelog-1.0.0.xml +++ b/src/main/resources/db/changelog/db.changelog-1.0.0.xml @@ -2236,4 +2236,22 @@ + + + + + + + + + + unique_uuid = 't7jh5wfg9QXylNaTZkPoE' + + + + + unique_uuid = 'p4lk3bcx1RStqTaIVVbXs' + + + diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index a92a61ad..4559736c 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -350,3 +350,4 @@ user.with.company.not.found = User with company not found for user or company. user.action.fetched.successfully = User action details fetched successfully. action.context.labels.fetched.successfully = Action Context Labels Fetched Successfully. amount.accepted.required=Amount accepted is required while approving the application. +call.expired=Call has been expired. diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index e7dbc010..1ab08cbd 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -304,7 +304,6 @@ beneficiary.call.duplicate = Una chiamata preferita con questo ID di chiamata e user.must.be.associated.with.company.to.create.application=Devi essere associato a un'azienda per poter presentare domanda per questa applicazione. company.id.required.for.preferred.call=ID azienda obbligatorio quando si richiedono solo chiamate preferite. response.days.not.null=I giorni di risposta non devono essere nulli e maggiori di zero. -application.cannot.approved.or.rejected=La domanda non pu� essere approvata o rifiutata perch� l'emendamento � attivo. valid.vatnumber.message=Il numero di partita IVA � valido. application.cannot.approved.or.rejected=La domanda non pu? essere approvata o rifiutata perch? l'emendamento ? attivo. @@ -342,3 +341,4 @@ user.with.company.not.found = Utente con azienda non trovato per utente o aziend user.action.fetched.successfully = Dettagli sull'azione dell'utente recuperati correttamente. action.context.labels.fetched.successfully = Etichette del contesto dell'azione recuperate correttamente. amount.accepted.required=L'importo accettato � obbligatorio durante l'approvazione della domanda. +call.expired=La chiamata è scaduta. \ No newline at end of file