Merge pull request #326 from Kitzanos/call-end-date-fix-prod
Cherry-pick (Fixed call end date issue)
This commit is contained in:
@@ -575,6 +575,8 @@ public class GepafinConstant {
|
|||||||
public static final String NDG_NOT_FOUND="ndg.not.found";
|
public static final String NDG_NOT_FOUND="ndg.not.found";
|
||||||
public static final String EMAIL_PEC_REQUIRED="email.pec.cannot.null";
|
public static final String EMAIL_PEC_REQUIRED="email.pec.cannot.null";
|
||||||
public static final String USER_REQUEST_COMPLETED="user.request.completed";
|
public static final String USER_REQUEST_COMPLETED="user.request.completed";
|
||||||
|
public static final String END_DATE_GREATER_THAN_NOW="end.date.greater.than.now";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -628,19 +628,19 @@ public class CallDao {
|
|||||||
if (dates.size() > 0) {
|
if (dates.size() > 0) {
|
||||||
setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, dates.get(0));
|
setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, dates.get(0));
|
||||||
}
|
}
|
||||||
if (dates.size() > 1) {
|
// if (dates.size() > 1) {
|
||||||
LocalDate requestEndDate = dates.get(1).toLocalDate(); // Extract only the date
|
// LocalDate requestEndDate = dates.get(1).toLocalDate(); // Extract only the date
|
||||||
LocalDate storedEndDate = callEntity.getEndDate().toLocalDate(); // Extract only the date
|
// LocalDate storedEndDate = callEntity.getEndDate().toLocalDate(); // Extract only the date
|
||||||
|
//
|
||||||
if (!requestEndDate.equals(storedEndDate)) { // Check if dates are different
|
// if (!requestEndDate.equals(storedEndDate)) { // Check if dates are different
|
||||||
|
//
|
||||||
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
|
// setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
|
||||||
// callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
//// callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||||
// callRepository.save(callEntity);
|
//// callRepository.save(callEntity);
|
||||||
isEndDateUpdated = true;
|
// isEndDateUpdated = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (updateCallRequest.getEndTime() != null) {
|
if (updateCallRequest.getEndTime() != null) {
|
||||||
LocalTime requestEndTime = DateTimeUtil.parseTime(updateCallRequest.getEndTime());
|
LocalTime requestEndTime = DateTimeUtil.parseTime(updateCallRequest.getEndTime());
|
||||||
@@ -653,6 +653,29 @@ public class CallDao {
|
|||||||
isEndTimeUpdated = true;
|
isEndTimeUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (dates.size() > 1) {
|
||||||
|
LocalDate requestEndDate = dates.get(1).toLocalDate(); // Extract only the date
|
||||||
|
LocalDate storedEndDate = callEntity.getEndDate().toLocalDate(); // Extract only the date
|
||||||
|
|
||||||
|
if (!requestEndDate.equals(storedEndDate)) {
|
||||||
|
// Check if dates are different
|
||||||
|
|
||||||
|
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, dates.get(1));
|
||||||
|
if(callEntity.getStatus().equals(CallStatusEnum.EXPIRED.getValue())) {
|
||||||
|
LocalDateTime newEndDate = LocalDateTime.of(requestEndDate, callEntity.getEndTime());
|
||||||
|
if(newEndDate.isBefore(LocalDateTime.now())){
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.END_DATE_GREATER_THAN_NOW));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requestEndDate.isAfter(LocalDate.now()) || requestEndDate.isEqual(LocalDate.now())) {
|
||||||
|
callEntity.setStatus(CallStatusEnum.PUBLISH.getValue());
|
||||||
|
callRepository.save(callEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isEndDateUpdated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (isEndDateUpdated || isEndTimeUpdated) {
|
if (isEndDateUpdated || isEndTimeUpdated) {
|
||||||
callRepository.save(callEntity);
|
callRepository.save(callEntity);
|
||||||
loggingUtil.logUserAction(UserActionRequest.builder()
|
loggingUtil.logUserAction(UserActionRequest.builder()
|
||||||
|
|||||||
@@ -411,3 +411,5 @@ user.action.id.not.found = User Action id not found.
|
|||||||
ndg.not.found=NDG not found.
|
ndg.not.found=NDG not found.
|
||||||
email.pec.cannot.null=Email pec is required.
|
email.pec.cannot.null=Email pec is required.
|
||||||
user.request.completed=User request completed successfully.
|
user.request.completed=User request completed successfully.
|
||||||
|
end.date.greater.than.now=End date must be greater than the current date and time.
|
||||||
|
|
||||||
|
|||||||
@@ -402,3 +402,5 @@ user.action.id.not.found = ID azione utente non trovato.
|
|||||||
ndg.not.found=NDG non trovato.
|
ndg.not.found=NDG non trovato.
|
||||||
email.pec.cannot.null=L'indirizzo email pec è obbligatorio.
|
email.pec.cannot.null=L'indirizzo email pec è obbligatorio.
|
||||||
user.request.completed=Richiesta utente completata con successo.
|
user.request.completed=Richiesta utente completata con successo.
|
||||||
|
end.date.greater.than.now=La data di fine deve essere successiva alla data e all'ora correnti.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user