diff --git a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java index 3ebf7e5f..1a2bd78c 100644 --- a/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java +++ b/src/main/java/net/gepafin/tendermanagement/constants/GepafinConstant.java @@ -179,4 +179,9 @@ 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"; + public static final String APPLICATION_STATUS_UPDATED_SUCCESSFULLY = "application.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 3d1f7de7..19a999ca 100644 --- a/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java +++ b/src/main/java/net/gepafin/tendermanagement/dao/ApplicationDao.java @@ -503,7 +503,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)) { @@ -529,7 +529,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/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/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/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/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/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..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 @@ -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.APPLICATION_STATUS_UPDATED_SUCCESSFULLY))); } } 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 diff --git a/src/main/resources/message_en.properties b/src/main/resources/message_en.properties index d70c97f4..83d51d11 100644 --- a/src/main/resources/message_en.properties +++ b/src/main/resources/message_en.properties @@ -206,3 +206,8 @@ 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. +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 00e8dcfc..42453b8a 100644 --- a/src/main/resources/message_it.properties +++ b/src/main/resources/message_it.properties @@ -9,7 +9,7 @@ get_user_success_msg=Utente recuperato con successo. get_user_error_msg=Si � verificato un errore durante il recupero dell'utente. user.not.active=Utente non attivo. Si prega di contattare il supporto. user.already.exist.msg=L'utente esiste gi� per questo codice fiscale. -validate.email=L'email è obbligatoria e deve essere nel formato corretto. Si prega di verificare e riprovare. +validate.email=L'email � obbligatoria e deve essere nel formato corretto. Si prega di verificare e riprovare. validate.password=La password e confPassword sono obbligatorie. Verifica e riprova. # Role-related messages role.created.success=Ruolo creato con successo. @@ -20,7 +20,7 @@ create.role.error=Errore durante la creazione del ruolo. update.role.error=Errore durante l'aggiornamento del ruolo. role.fetch.success=Ruolo recuperato con successo. delete.role.error=Errore durante l'eliminazione del ruolo. -role.id.mandatory=L'ID del ruolo è obbligatorio. +role.id.mandatory=L'ID del ruolo � obbligatorio. # Region-related messages region.created.success=Regione creata con successo. @@ -194,8 +194,12 @@ company.get.success=Azienda recuperata con successo. company.not.found=Azienda non trovata. check.vatnumber.success=Numero di partita IVA verificato con successo. invalid.vatnumber=Numero di partita IVA non valido. -vatnumber.mandatory=Il numero di partita IVA è obbligatorio. -vatnumber.already.exists=Il numero di partita IVA esiste già. +vatnumber.mandatory=Il numero di partita IVA � obbligatorio. +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. +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. +status.updated.successfully=Stato aggiornato con successo. +application.status.updated.successfully = Stato dell'applicazione aggiornato con successo.