From 837bd63314eb926c0d189009338893a7ea0a48ab Mon Sep 17 00:00:00 2001 From: harish Date: Thu, 3 Oct 2024 19:39:33 +0530 Subject: [PATCH 1/4] Updated validation logic for start and end dates --- .../constants/GepafinConstant.java | 3 +++ .../gepafin/tendermanagement/dao/CallDao.java | 20 +++++++++++++++++++ src/main/resources/message_en.properties | 3 +++ src/main/resources/message_it.properties | 2 ++ 4 files changed, 28 insertions(+) diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index 3ebf7e5f..70e764f2 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -179,4 +179,7 @@ public class GepafinConstant { public static final String UNAUTHORIZED = "UNAUTHORIZED"; public static final String COMPANY_ID_MANDATORY = "company.id.mandatory"; public static final String USER_ALREADY_CONNECTED_TO_COMPANY = "user.already.connected.to.company"; + + public static final String CALL_NOT_STARTED_YET = "call.not.started.yet"; + public static final String CALL_ALREADY_ENDED = "call.already.ended"; } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java b/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java index e214e562..c6345d59 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/CallDao.java @@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.dao; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -673,6 +674,25 @@ public class CallDao { Status.NOT_FOUND, Translator.toLocale(GepafinConstant.CALL_NOT_PUBLISHED)); } + LocalDate currentDate = LocalDate.now(); + LocalTime currentTime = LocalTime.now(); + + if (currentDate.isBefore(callEntity.getStartDate().toLocalDate()) || + (currentDate.isEqual(callEntity.getStartDate().toLocalDate()) && currentTime.isBefore(callEntity.getStartTime()))) { + throw new CustomValidationException( + Status.BAD_REQUEST, + Translator.toLocale(GepafinConstant.CALL_NOT_STARTED_YET) + ); + } + + if (currentDate.isAfter(callEntity.getEndDate().toLocalDate()) || + (currentDate.isEqual(callEntity.getEndDate().toLocalDate()) && currentTime.isAfter(callEntity.getEndTime()))) { + throw new CustomValidationException( + Status.BAD_REQUEST, + Translator.toLocale(GepafinConstant.CALL_ALREADY_ENDED) + ); + } + return callEntity; } diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index d70c97f4..62de4214 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -206,3 +206,6 @@ vatnumber.already.exists=VatNumber already exists. invalid.email=Invalid email. company.id.mandatory=Company id is mandatory. user.already.connected.to.company=The user is already connected to this company. + +call.not.started.yet = The call has not started yet. Please wait until the specified start date and time. +call.already.ended = The call has already ended. You cannot submit the application after the deadline. diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index 00e8dcfc..aa29d36e 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -199,3 +199,5 @@ vatnumber.already.exists=Il numero di partita IVA esiste gi invalid.email=Email non valida. company.id.mandatory=L'ID dell'azienda è obbligatorio. user.already.connected.to.company=L'utente è già collegato a questa azienda. +call.not.started.yet = La chiamata non è ancora iniziata. Attendere fino alla data e all'ora di inizio specificate. +call.already.ended = La chiamata è già terminata. Non è possibile inviare l'applicazione dopo la scadenza. From 9477c8fe14efaf335ec8ac18190f74602e3fae02 Mon Sep 17 00:00:00 2001 From: harish Date: Mon, 7 Oct 2024 12:45:34 +0530 Subject: [PATCH 2/4] Updated application status api response --- .../gepafin/tendermanagement/constants/GepafinConstant.java | 2 ++ .../net/gepafin/tendermanagement/dao/ApplicationDao.java | 6 ++++-- .../tendermanagement/service/ApplicationService.java | 2 +- .../service/impl/ApplicationServiceImpl.java | 4 ++-- .../tendermanagement/web/rest/api/ApplicationApi.java | 2 +- .../web/rest/api/impl/ApplicationApiController.java | 6 +++--- src/main/resources/message_en.properties | 1 + src/main/resources/message_it.properties | 1 + 8 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index 3ebf7e5f..cffcc815 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -179,4 +179,6 @@ public class GepafinConstant { public static final String UNAUTHORIZED = "UNAUTHORIZED"; public static final String COMPANY_ID_MANDATORY = "company.id.mandatory"; public static final String USER_ALREADY_CONNECTED_TO_COMPANY = "user.already.connected.to.company"; + public static final String STATUS_UPDATED_SUCCESSFULLY = "status.updated.successfully"; + } diff --git a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java index a76b9de3..50ed07b1 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -492,7 +492,7 @@ public class ApplicationDao { } } - public void updateApplicationStatus(Long applicationId, ApplicationStatusTypeEnum status) { + public ApplicationResponse updateApplicationStatus(Long applicationId, ApplicationStatusTypeEnum status) { ApplicationEntity applicationEntity = validateApplication(applicationId); if (status.equals(ApplicationStatusTypeEnum.SUBMIT)) { @@ -518,7 +518,9 @@ public class ApplicationDao { } else { applicationEntity.setStatus(status.getValue()); } - saveApplicationEntity(applicationEntity); + applicationEntity = saveApplicationEntity(applicationEntity); + + return getApplicationResponse(applicationEntity); } public Integer calculateProgress(Long totalSteps, Long completedSteps) { diff --git a/src/main/java/net/gepafin/tendermanagement/service/ApplicationService.java b/src/main/java/net/gepafin/tendermanagement/service/ApplicationService.java index a8f6ad53..edb62c93 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/ApplicationService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/ApplicationService.java @@ -29,6 +29,6 @@ public interface ApplicationService { public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId, FormActionEnum action); - public void updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status); + public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status); } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java index c69354b2..142d4b01 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/ApplicationServiceImpl.java @@ -76,8 +76,8 @@ public class ApplicationServiceImpl implements ApplicationService { } @Override - public void updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) { - applicationDao.updateApplicationStatus(applicationId, status); + public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) { + return applicationDao.updateApplicationStatus(applicationId, status); } diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java index c56680ef..1869655c 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/ApplicationApi.java @@ -127,7 +127,7 @@ public interface ApplicationApi { @ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = { @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @PutMapping(value = "/{applicationId}/status", produces = { "application/json" }) - ResponseEntity> updateApplicationStatus(HttpServletRequest request, + ResponseEntity> updateApplicationStatus(HttpServletRequest request, @Parameter(description = "The application id", required = true) @PathVariable("applicationId") Long applicationId, @Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) ApplicationStatusTypeEnum status); diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java index 69f28492..6de3f812 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java @@ -83,10 +83,10 @@ public class ApplicationApiController implements ApplicationApi { } @Override - public ResponseEntity> updateApplicationStatus(HttpServletRequest request, Long applicationId, + public ResponseEntity> updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status) { - applicationService.updateApplicationStatus(request, applicationId, status); + ApplicationResponse applicationResponse = applicationService.updateApplicationStatus(request, applicationId, status); return ResponseEntity.status(HttpStatus.OK) - .body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG))); + .body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.STATUS_UPDATED_SUCCESSFULLY))); } } diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index d70c97f4..b921d880 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -206,3 +206,4 @@ vatnumber.already.exists=VatNumber already exists. invalid.email=Invalid email. company.id.mandatory=Company id is mandatory. user.already.connected.to.company=The user is already connected to this company. +status.updated.successfully=Status updated successfully. diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index 00e8dcfc..c81ee2df 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -199,3 +199,4 @@ vatnumber.already.exists=Il numero di partita IVA esiste gi invalid.email=Email non valida. company.id.mandatory=L'ID dell'azienda è obbligatorio. user.already.connected.to.company=L'utente è già collegato a questa azienda. +status.updated.successfully=Stato aggiornato con successo. From 32f075a03dd8163b183234ad88fa9404a90eada7 Mon Sep 17 00:00:00 2001 From: harish Date: Mon, 7 Oct 2024 15:09:16 +0530 Subject: [PATCH 3/4] Added DateOfBirth in UserSamlResponse --- .../tendermanagement/model/response/UserSamlResponse.java | 4 ++++ .../service/impl/AuthenticationService.java | 8 ++++++++ src/main/resources/application-production.properties | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/model/response/UserSamlResponse.java b/src/main/java/net/gepafin/tendermanagement/model/response/UserSamlResponse.java index da732bd4..8fdcbdea 100644 --- a/src/main/java/net/gepafin/tendermanagement/model/response/UserSamlResponse.java +++ b/src/main/java/net/gepafin/tendermanagement/model/response/UserSamlResponse.java @@ -2,6 +2,8 @@ package net.gepafin.tendermanagement.model.response; import lombok.Data; +import java.time.LocalDateTime; + @Data public class UserSamlResponse { @@ -10,4 +12,6 @@ public class UserSamlResponse { private String firstName; private String lastName; + + private LocalDateTime dateOfBirth; } diff --git a/src/main/java/net/gepafin/tendermanagement/service/impl/AuthenticationService.java b/src/main/java/net/gepafin/tendermanagement/service/impl/AuthenticationService.java index a84b325c..03ce8b1c 100644 --- a/src/main/java/net/gepafin/tendermanagement/service/impl/AuthenticationService.java +++ b/src/main/java/net/gepafin/tendermanagement/service/impl/AuthenticationService.java @@ -33,6 +33,7 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; import org.springframework.stereotype.Service; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; import java.util.Map; @@ -182,6 +183,13 @@ public class AuthenticationService { && !userAttributes.get("cognome").isEmpty()) { userSamlResponse.setLastName(userAttributes.get("cognome").get(0).toString()); } + if (userAttributes.containsKey("dataNascita") && userAttributes.get("dataNascita") != null + && !userAttributes.get("dataNascita").isEmpty()) { + String dateString =userAttributes.get("dataNascita").get(0).toString(); + LocalDate dateOfBirth = LocalDate.parse(dateString); + LocalDateTime dateOfBirthWithTime = dateOfBirth.atStartOfDay(); + userSamlResponse.setDateOfBirth(dateOfBirthWithTime); + } userSamlResponse.setCodiceFiscale(cf); return userSamlResponse; } diff --git a/src/main/resources/application-production.properties b/src/main/resources/application-production.properties index f4ea18fa..968d5ac5 100644 --- a/src/main/resources/application-production.properties +++ b/src/main/resources/application-production.properties @@ -9,8 +9,8 @@ spring.h2.console.enabled=true base-url=http://bandi-api.gepafin.it isVatCheckGloballyDisabled = false -fe.base.url=http://gepafin-production-fe.s3-website.eu-central-1.amazonaws.com - +#fe.base.url=http://gepafin-production-fe.s3-website.eu-central-1.amazonaws.com +fe.base.url=http://bandi.gepafin.it #SPID configuration spid.ipd.base.url=https://login.regione.umbria.it active.profile.folder=production \ No newline at end of file From 65169e54c3d07b7d89e703da06289b256258cd77 Mon Sep 17 00:00:00 2001 From: harish Date: Mon, 7 Oct 2024 15:17:03 +0530 Subject: [PATCH 4/4] Updated message for application status api response --- .../net/gepafin/tendermanagement/constants/GepafinConstant.java | 2 +- .../web/rest/api/impl/ApplicationApiController.java | 2 +- src/main/resources/message_en.properties | 1 + src/main/resources/message_it.properties | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index cffcc815..89c1e475 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -179,6 +179,6 @@ public class GepafinConstant { public static final String UNAUTHORIZED = "UNAUTHORIZED"; public static final String COMPANY_ID_MANDATORY = "company.id.mandatory"; public static final String USER_ALREADY_CONNECTED_TO_COMPANY = "user.already.connected.to.company"; - public static final String STATUS_UPDATED_SUCCESSFULLY = "status.updated.successfully"; + public static final String APPLICATION_STATUS_UPDATED_SUCCESSFULLY = "application.status.updated.successfully"; } diff --git a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java index 6de3f812..bcbf8e80 100644 --- a/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java +++ b/src/main/java/net/gepafin/tendermanagement/web/rest/api/impl/ApplicationApiController.java @@ -87,6 +87,6 @@ public class ApplicationApiController implements ApplicationApi { ApplicationStatusTypeEnum status) { ApplicationResponse applicationResponse = applicationService.updateApplicationStatus(request, applicationId, status); return ResponseEntity.status(HttpStatus.OK) - .body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.STATUS_UPDATED_SUCCESSFULLY))); + .body(new Response<>(applicationResponse, Status.SUCCESS, Translator.toLocale(GepafinConstant.APPLICATION_STATUS_UPDATED_SUCCESSFULLY))); } } diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index b921d880..3b11067b 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -207,3 +207,4 @@ invalid.email=Invalid email. company.id.mandatory=Company id is mandatory. user.already.connected.to.company=The user is already connected to this company. status.updated.successfully=Status updated successfully. +application.status.updated.successfully = Application status updated successfully. diff --git a/src/main/resources/message_it.properties b/src/main/resources/message_it.properties index c81ee2df..27ebd36d 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -200,3 +200,4 @@ invalid.email=Email non valida. company.id.mandatory=L'ID dell'azienda è obbligatorio. user.already.connected.to.company=L'utente è già collegato a questa azienda. status.updated.successfully=Stato aggiornato con successo. +application.status.updated.successfully = Stato dell'applicazione aggiornato con successo.