Merge pull request #285 from Kitzanos/feature/GEPAFINBE-217

GEPAFINBE-217 (Created an API to Re-admit Application )
This commit is contained in:
Rinaldo
2025-05-14 08:47:09 +02:00
committed by GitHub
13 changed files with 139 additions and 7 deletions

View File

@@ -541,6 +541,8 @@ public class GepafinConstant {
public static final String RESEND_EMAIL_SENT_FAILED_MSG = "resend.email.sent.failed.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 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 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 USER_ACTION_ID_NOT_FOUND = "user.action.id.not.found";

View File

@@ -1089,12 +1089,12 @@ public class ApplicationAmendmentRequestDao {
application.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue()); application.setStatus(ApplicationStatusTypeEnum.EVALUATION.getValue());
applicationRepository.save(application); applicationRepository.save(application);
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().setStatus(AssignedApplicationEnum.OPEN.getValue());
AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsDao.validateAssignedApplication( AssignedApplicationsEntity assignedApplicationsEntity = assignedApplicationsDao.validateAssignedApplication(
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getId()); existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().getId());
AssignedApplicationsEntity oldAssignedApplicationData = Utils.getClonedEntityForData(assignedApplicationsEntity); AssignedApplicationsEntity oldAssignedApplicationData = Utils.getClonedEntityForData(assignedApplicationsEntity);
existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity().setStatus(AssignedApplicationEnum.OPEN.getValue());
assignedApplicationsEntity = assignedApplicationsRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity()); assignedApplicationsEntity = assignedApplicationsRepository.save(existingApplicationAmendment.getApplicationEvaluationEntity().getAssignedApplicationsEntity());

View File

@@ -2170,6 +2170,88 @@ public class ApplicationDao {
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(GepafinConstant.RINALDO_EMAIL),emailLogRequest); emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(GepafinConstant.RINALDO_EMAIL),emailLogRequest);
} }
public ApplicationResponse readmitApplication(HttpServletRequest request, Long applicationId) {
log.info("Re-admiting the Application with id : {}", applicationId);
ApplicationEntity applicationEntity = fetchRejectedApplication(applicationId);
if(applicationEntity == null){
throw new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_NOT_FOUND_MSG));
}
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
validateCallEndDate(applicationEntity);
assignedApplicationsRepository.findByApplicationIdAndStatusAndIsDeletedFalse(applicationEntity.getId(), AssignedApplicationEnum.CLOSE.getValue())
.ifPresent(assignedApp -> processAssignedAppAndEvaluation(request, applicationEntity, assignedApp));
return getApplicationResponse(applicationEntity);
}
private ApplicationEntity fetchRejectedApplication(Long applicationId) {
return applicationRepository.findByIdAndStatusAndIsDeletedFalse(applicationId, ApplicationStatusTypeEnum.REJECTED.getValue());
}
private void validateCallEndDate(ApplicationEntity applicationEntity) {
checkCallEndDate(applicationEntity.getCall());
log.info("Call end date verified successfully | callId: {}", applicationEntity.getCall().getId());
}
private void processAssignedAppAndEvaluation(HttpServletRequest request, ApplicationEntity applicationEntity, AssignedApplicationsEntity assignedApp) {
applicationEvaluationRepository.findByAssignedApplicationsEntity_IdAndStatusAndIsDeletedFalse(assignedApp.getId(), ApplicationEvaluationStatusTypeEnum.CLOSE.getValue())
.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);
}
} }

View File

@@ -46,6 +46,7 @@ public enum UserActionContextEnum {
GET_SIGNED_DOCUMENT("GET_SIGNED_DOCUMENT"), GET_SIGNED_DOCUMENT("GET_SIGNED_DOCUMENT"),
GET_NEXT_PREVIOUS_FORM("GET_NEXT_PREVIOUS_FORM"), GET_NEXT_PREVIOUS_FORM("GET_NEXT_PREVIOUS_FORM"),
DOWNLOAD_APPLICATION_DOC_ZIP("DOWNLOAD_APPLICATION_DOC_ZIP"), DOWNLOAD_APPLICATION_DOC_ZIP("DOWNLOAD_APPLICATION_DOC_ZIP"),
READMIT_APPLICATION("READMIT_APPLICATION"),
/** FAQ action context **/ /** FAQ action context **/
CREATE_FAQ("CREATE_FAQ"), CREATE_FAQ("CREATE_FAQ"),

View File

@@ -76,6 +76,10 @@ public interface ApplicationEvaluationRepository extends JpaRepository<Applicati
@Param("assignedApplicationId") Long assignedApplicationId @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") @Query("SELECT ae FROM ApplicationEvaluationEntity ae WHERE ae.applicationId = :applicationId AND ae.isDeleted = false")
ApplicationEvaluationEntity findByApplicationId(@Param("applicationId") Long applicationId); ApplicationEvaluationEntity findByApplicationId(@Param("applicationId") Long applicationId);

View File

@@ -178,4 +178,7 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
void resetNdgStatusForInProgress(@Param("status") String status); void resetNdgStatusForInProgress(@Param("status") String status);
boolean existsByCallId(Long callId); boolean existsByCallId(Long callId);
ApplicationEntity findByIdAndStatusAndIsDeletedFalse( Long id, String status);
} }

View File

@@ -110,4 +110,8 @@ public interface AssignedApplicationsRepository extends JpaRepository<AssignedAp
@Param("sevenDaysAgo") LocalDateTime sevenDaysAgo); @Param("sevenDaysAgo") LocalDateTime sevenDaysAgo);
Optional<AssignedApplicationsEntity> findByApplicationIdAndStatusAndIsDeletedFalse( Long applicationId, String status);
} }

View File

@@ -50,4 +50,6 @@ public interface ApplicationService {
public byte[] exportCsv(HttpServletRequest request, Long callId); public byte[] exportCsv(HttpServletRequest request, Long callId);
public ApplicationResponse readmitApplication(HttpServletRequest request, Long applicationId);
} }

View File

@@ -170,5 +170,10 @@ public class ApplicationServiceImpl implements ApplicationService {
return csvBytes; return csvBytes;
} }
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationResponse readmitApplication(HttpServletRequest request, Long applicationId) {
UserEntity userEntity = validator.validateUser(request);
return applicationDao.readmitApplication(request, applicationId);
}
} }

View File

@@ -238,6 +238,20 @@ public interface ApplicationApi {
public ResponseEntity<byte[]> exportCsv( public ResponseEntity<byte[]> exportCsv(
HttpServletRequest request, @Parameter(description = "The call id", required = true) @PathVariable(value = "callId", required = true) Long callId); 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);
} }

View File

@@ -242,5 +242,16 @@ public class ApplicationApiController implements ApplicationApi {
.contentType(MediaType.APPLICATION_OCTET_STREAM) .contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(csvBytes); .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)));
}
} }

View File

@@ -404,5 +404,7 @@ invalid.user=Invalid user.
reminder.email.sent.failed.msg = Failed to send reminder email reminder.email.sent.failed.msg = Failed to send reminder email
resend.email.sent.success.msg = Email resend successfully resend.email.sent.success.msg = Email resend successfully
resend.email.sent.failed.msg = Failed to resend the email. resend.email.sent.failed.msg = Failed to resend the email.
application.readmit.success=Application has been readmitted successfully.
no.email.log.msg = No failed emails found for given userActionId. no.email.log.msg = No failed emails found for given userActionId.
user.action.id.not.found = User Action id not found. user.action.id.not.found = User Action id not found.

View File

@@ -53,7 +53,7 @@ call.update.successfully=Chiamata aggiornata con successo.
call.fetch.success=Dettagli della chiamata recuperati con successo. call.fetch.success=Dettagli della chiamata recuperati con successo.
call.not.found=Chiamata non trovata. call.not.found=Chiamata non trovata.
score.not.null=Il punteggio non pu? essere nullo o zero. score.not.null=Il punteggio non pu? essere nullo o zero.
field.not.null={0} non può essere vuoto. field.not.null={0} non pu<EFBFBD> essere vuoto.
field.not.empty=la {0} non pu? essere vuota. field.not.empty=la {0} non pu? essere vuota.
update_call_status_success_msg=Lo stato della chiamata ? stato aggiornato con successo. update_call_status_success_msg=Lo stato della chiamata ? stato aggiornato con successo.
status.same.error=Lo stato ? gi? impostato. status.same.error=Lo stato ? gi? impostato.
@@ -389,11 +389,13 @@ error.invalid.limit=Il limite dovrebbe essere compreso tra 1 e 3000.
insufficient.score.msg = Punteggio non sufficiente per passaggio alla valutazione tecnica ed economico finanziaria insufficient.score.msg = Punteggio non sufficiente per passaggio alla valutazione tecnica ed economico finanziaria
validation.table.message=I dati per il campo {0} non sono presenti. validation.table.message=I dati per il campo {0} non sono presenti.
password.expired.for.login.to.odessa = La password di accesso a Odessa è scaduta password.expired.for.login.to.odessa = La password di accesso a Odessa <EFBFBD> scaduta
invalid.user=Utente non valido. invalid.user=Utente non valido.
reminder.email.sent.failed.msg = Impossibile inviare l'e-mail di promemoria reminder.email.sent.failed.msg = Impossibile inviare l'e-mail di promemoria
resend.email.sent.success.msg = Email reinviata con successo resend.email.sent.success.msg = Email reinviata con successo
resend.email.sent.failed.msg = Impossibile inviare nuovamente l'e-mail. resend.email.sent.failed.msg = Impossibile inviare nuovamente l'e-mail.
application.readmit.success=L'applicazione è stata riammessa con successo.
no.email.log.msg = Nessuna email trovata per userActionId specificato. no.email.log.msg = Nessuna email trovata per userActionId specificato.
user.action.id.not.found = ID azione utente non trovato. user.action.id.not.found = ID azione utente non trovato.