Class AppointmentUtilities
- java.lang.Object
-
- fr.paris.lutece.plugins.appointment.service.AppointmentUtilities
-
public final class AppointmentUtilities extends Object
Utility class for Appointment Mutualize methods between MVCApplication and MVCAdminJspBean- Author:
- Laurent Payen
-
-
Field Summary
Fields Modifier and Type Field Description static StringERROR_MESSAGE_CONFIRM_EMAILstatic StringERROR_MESSAGE_DATE_APPOINTMENTstatic StringERROR_MESSAGE_EMPTY_CONFIRM_EMAILstatic StringERROR_MESSAGE_EMPTY_EMAILstatic StringERROR_MESSAGE_EMPTY_NB_BOOKED_SEATstatic StringERROR_MESSAGE_ERROR_NB_BOOKED_SEATstatic StringERROR_MESSAGE_FORMAT_NB_BOOKED_SEATstatic StringMARK_PERMISSION_ACCESS_CODEstatic StringMARK_PERMISSION_ADD_COMMENTstatic StringMARK_PERMISSION_MODERATE_COMMENTstatic StringOLD_APPOINTMENT_DTOstatic StringPROPERTY_DEFAULT_EXPIRED_TIME_EDIT_APPOINTMENTstatic StringSESSION_TASK_TIMER_SLOTstatic intTHIRTY_MINUTES
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AppointmentDTObuildAppointmentDTO(Appointment appointment)Build an appointment dto from an appointment business objectstatic List<ResponseRecapDTO>buildListResponse(AppointmentDTO appointment, javax.servlet.http.HttpServletRequest request, Locale locale)Build a list of response of the appointmentstatic voidcancelTaskTimer(javax.servlet.http.HttpServletRequest request, int idSlot)Attempts to cancel execution of the task.static intcheckAndReturnNbBookedSeats(String strNbBookedSeats, AppointmentFormDTO form, AppointmentDTO appointmentDTO, Locale locale, List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors)Check and validate all the rules for the number of booked seats askedstatic voidcheckDateOfTheAppointmentIsNotBeforeNow(AppointmentDTO appointmentDTO, Locale locale, List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors)Check that the date of the appointment we try to take is not in the paststatic voidcheckEmail(String strEmail, String strConfirmEmail, AppointmentFormDTO form, Locale locale, List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors)Check that the email is correct and matches the confirm emailstatic booleancheckListSlotIsBuildedCorrectly(int nIdForm, List<Slot> listSlots)Check if list of slot is builded correctlystatic booleancheckNbDaysBetweenTwoAppointments(AppointmentDTO appointmentDTO, String strEmail, AppointmentFormDTO form)Check that the delay between two appointments for the same use has been respectedstatic booleancheckNbDaysBetweenTwoAppointmentsTaken(AppointmentDTO appointmentDTO, String strEmail, AppointmentFormDTO form)Check that the delay between two appointments for the same use has been respectedstatic booleancheckNbMaxAppointmentsDefinedOnCategory(AppointmentDTO appointmentDTO, String strEmail, AppointmentFormDTO form, List<AppointmentDTO> listAppointments)Check that the number of appointments on a defined category is not above the maximum authorizedstatic booleancheckNbMaxAppointmentsOnAGivenPeriod(AppointmentDTO appointmentDTO, String strEmail, AppointmentFormDTO form)Check that the number of appointments on a defined period is not above the maximum authorizedstatic booleancheckNoAppointmentsImpacted(List<Appointment> listAppointment, int nIdForm, int nIdreservationRule, AppointmentFormDTO appointmentForm)Check if there are appointments impacted by the new week definitionstatic booleancheckNoAppointmentsImpacted(List<Appointment> listAppointment, int nIdForm, LocalDate dateOfModification, AppointmentFormDTO appointmentForm)Check if there are appointments impacted by the new week definitionstatic booleancheckNoAppointmentsImpacted(List<Slot> listSlotsImpacted, int idReservationRule)Check if there are appointments impacted by the new week definitionstatic booleancheckNoAppointmentsImpacted(List<Slot> listSlotWithAppointment, AppointmentFormDTO appointmentForm)Check if there are appointments impacted by the new week definitionstatic booleancheckNoValidatedAppointmentsOnThisSlot(Slot slot)Check that there is no validated appointments on a slotstatic voidfillAppointmentDTO(AppointmentDTO appointmentDTO, int nbBookedSeats, String strEmail, String strEmailConfirm, String strFirstName, String strLastName)Fill the appoinmentFront DTO with the given parametersstatic voidfillInListResponseWithMapResponse(AppointmentDTO appointmentDTO)static voidfillInReservationRuleAdvancedParam(ReservationRuleDTO reservationRuleDTO, AppointmentFormDTO appointmentForm)Fill the reservation rule object with the corresponding values of an appointmentForm DTOstatic List<Slot>findSlotsImpactedByThisTimeSlot(TimeSlot timeSlot, int nIdForm, int nIdWeekDefinition, boolean bShiftSlot)Return the slots impacted by the modification of this time slotstatic LocalDateTimegetEndingDateTime(Appointment appointmentDTO)static LocalTimegetMaxTimeToDisplay(LocalTime maxEndingTime)Return the max ending time to displaystatic LocalTimegetMinTimeToDisplay(LocalTime minStartingTime)Return the min starting time to displaystatic String[][]getPermissions(List<AppointmentFormDTO> listForms, fr.paris.lutece.portal.business.user.AdminUser user)Get Form Permissionsstatic LocalDateTimegetStartingDateTime(Appointment appointmentDTO)static booleanisConsecutiveSlots(List<Slot> allSlots)return true if all slots are consecutivestatic booleanisEditSlotTaskExpiredTime(javax.servlet.http.HttpServletRequest request, int idSlot)static ScheduledFuture<Slot>putTimerInSession(javax.servlet.http.HttpServletRequest request, int nIdSlot, AppointmentDTO appointmentDTO, int maxPeoplePerAppointment)Create a timer on a slotstatic voidshutdownSecheduledExecutor()The following method shuts down the _executorService in two phases, first by calling shutdown to reject incoming tasks, and then calling shutdownNow, if necessary, to cancel any lingering tasks:static voidvalidateFormAndEntries(AppointmentDTO appointmentDTO, javax.servlet.http.HttpServletRequest request, List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors, boolean allEntries)Validate the form and the additional entries of the formstatic booleanweekIsOpenInFO(AppointmentFormDTO appointmentFormDTO, List<WeekDefinition> listWeek, Locale locale)check if one of the weeks in the list is open on the FO calendar
-
-
-
Field Detail
-
ERROR_MESSAGE_EMPTY_CONFIRM_EMAIL
public static final String ERROR_MESSAGE_EMPTY_CONFIRM_EMAIL
- See Also:
- Constant Field Values
-
ERROR_MESSAGE_CONFIRM_EMAIL
public static final String ERROR_MESSAGE_CONFIRM_EMAIL
- See Also:
- Constant Field Values
-
ERROR_MESSAGE_DATE_APPOINTMENT
public static final String ERROR_MESSAGE_DATE_APPOINTMENT
- See Also:
- Constant Field Values
-
ERROR_MESSAGE_EMPTY_EMAIL
public static final String ERROR_MESSAGE_EMPTY_EMAIL
- See Also:
- Constant Field Values
-
ERROR_MESSAGE_EMPTY_NB_BOOKED_SEAT
public static final String ERROR_MESSAGE_EMPTY_NB_BOOKED_SEAT
- See Also:
- Constant Field Values
-
ERROR_MESSAGE_FORMAT_NB_BOOKED_SEAT
public static final String ERROR_MESSAGE_FORMAT_NB_BOOKED_SEAT
- See Also:
- Constant Field Values
-
ERROR_MESSAGE_ERROR_NB_BOOKED_SEAT
public static final String ERROR_MESSAGE_ERROR_NB_BOOKED_SEAT
- See Also:
- Constant Field Values
-
MARK_PERMISSION_ADD_COMMENT
public static final String MARK_PERMISSION_ADD_COMMENT
- See Also:
- Constant Field Values
-
MARK_PERMISSION_MODERATE_COMMENT
public static final String MARK_PERMISSION_MODERATE_COMMENT
- See Also:
- Constant Field Values
-
MARK_PERMISSION_ACCESS_CODE
public static final String MARK_PERMISSION_ACCESS_CODE
- See Also:
- Constant Field Values
-
OLD_APPOINTMENT_DTO
public static final String OLD_APPOINTMENT_DTO
- See Also:
- Constant Field Values
-
SESSION_TASK_TIMER_SLOT
public static final String SESSION_TASK_TIMER_SLOT
- See Also:
- Constant Field Values
-
PROPERTY_DEFAULT_EXPIRED_TIME_EDIT_APPOINTMENT
public static final String PROPERTY_DEFAULT_EXPIRED_TIME_EDIT_APPOINTMENT
- See Also:
- Constant Field Values
-
THIRTY_MINUTES
public static final int THIRTY_MINUTES
- See Also:
- Constant Field Values
-
-
Method Detail
-
checkEmail
public static void checkEmail(String strEmail, String strConfirmEmail, AppointmentFormDTO form, Locale locale, List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors)
Check that the email is correct and matches the confirm email- Parameters:
strEmail- the emailstrConfirmEmail- the confirm emailform- the formlocale- the locallistFormErrors- the list of errors that can be fill in with the errors found for the email
-
checkDateOfTheAppointmentIsNotBeforeNow
public static void checkDateOfTheAppointmentIsNotBeforeNow(AppointmentDTO appointmentDTO, Locale locale, List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors)
Check that the date of the appointment we try to take is not in the past- Parameters:
appointmentDTO- the appointmentlocale- the locallistFormErrors- the list of errors that can be fill in with the error found with the date
-
checkNbDaysBetweenTwoAppointments
public static boolean checkNbDaysBetweenTwoAppointments(AppointmentDTO appointmentDTO, String strEmail, AppointmentFormDTO form)
Check that the delay between two appointments for the same use has been respected- Parameters:
appointmentDTO- the appointmentstrEmail- the emailform- the form- Returns:
- false if the delay is not respected
-
checkNbDaysBetweenTwoAppointmentsTaken
public static boolean checkNbDaysBetweenTwoAppointmentsTaken(AppointmentDTO appointmentDTO, String strEmail, AppointmentFormDTO form)
Check that the delay between two appointments for the same use has been respected- Parameters:
appointmentDTO- the appointmentstrEmail- the emailform- the form- Returns:
- false if the delay is not respected
-
checkNbMaxAppointmentsOnAGivenPeriod
public static boolean checkNbMaxAppointmentsOnAGivenPeriod(AppointmentDTO appointmentDTO, String strEmail, AppointmentFormDTO form)
Check that the number of appointments on a defined period is not above the maximum authorized- Parameters:
appointmentDTO- the appointmentstrEmail- the email of the userform- the form- Returns:
- false if the number of appointments is above the maximum authorized on the defined period
-
checkNbMaxAppointmentsDefinedOnCategory
public static boolean checkNbMaxAppointmentsDefinedOnCategory(AppointmentDTO appointmentDTO, String strEmail, AppointmentFormDTO form, List<AppointmentDTO> listAppointments)
Check that the number of appointments on a defined category is not above the maximum authorized- Parameters:
appointmentDTO- the appointmentstrEmail- the email of the userform- the form- Returns:
- false if the number of appointments is above the maximum authorized on the defined category
-
checkAndReturnNbBookedSeats
public static int checkAndReturnNbBookedSeats(String strNbBookedSeats, AppointmentFormDTO form, AppointmentDTO appointmentDTO, Locale locale, List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors)
Check and validate all the rules for the number of booked seats asked- Parameters:
strNbBookedSeats- the number of booked seatsform- the formnbRemainingPlaces- the number of remaining places on the slot askedlocale- the localelistFormErrors- the list of errors that can be fill in with the errors found for the number of booked seats- Returns:
-
fillAppointmentDTO
public static void fillAppointmentDTO(AppointmentDTO appointmentDTO, int nbBookedSeats, String strEmail, String strEmailConfirm, String strFirstName, String strLastName)
Fill the appoinmentFront DTO with the given parameters- Parameters:
appointmentDTO- the appointmentFront DTOnbBookedSeats- the number of booked seatsstrEmail- the email of the userstrFirstName- the first name of the userstrLastName- the last name of the user
-
validateFormAndEntries
public static void validateFormAndEntries(AppointmentDTO appointmentDTO, javax.servlet.http.HttpServletRequest request, List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors, boolean allEntries)
Validate the form and the additional entries of the form- Parameters:
appointmentDTO- the appointmentFron DTo to validaterequest- the requestlistFormErrors- the list of errors that can be fill with the errors found at the validation
-
fillInListResponseWithMapResponse
public static void fillInListResponseWithMapResponse(AppointmentDTO appointmentDTO)
-
buildListResponse
public static List<ResponseRecapDTO> buildListResponse(AppointmentDTO appointment, javax.servlet.http.HttpServletRequest request, Locale locale)
Build a list of response of the appointment- Parameters:
appointment- the appointmentrequest- the requestlocale- the local- Returns:
- a list of response
-
cancelTaskTimer
public static void cancelTaskTimer(javax.servlet.http.HttpServletRequest request, int idSlot)Attempts to cancel execution of the task.- Parameters:
request- the requestidSlot- the id Slot
-
isEditSlotTaskExpiredTime
public static boolean isEditSlotTaskExpiredTime(javax.servlet.http.HttpServletRequest request, int idSlot)
-
putTimerInSession
public static ScheduledFuture<Slot> putTimerInSession(javax.servlet.http.HttpServletRequest request, int nIdSlot, AppointmentDTO appointmentDTO, int maxPeoplePerAppointment)
Create a timer on a slot- Parameters:
slot- the slotappointmentDTO- the appointmentmaxPeoplePerAppointment- the max people per appointment- Returns:
- the ScheduledFuture
-
getPermissions
public static String[][] getPermissions(List<AppointmentFormDTO> listForms, fr.paris.lutece.portal.business.user.AdminUser user)
Get Form Permissions- Parameters:
listForms-request-- Returns:
-
getMinTimeToDisplay
public static LocalTime getMinTimeToDisplay(LocalTime minStartingTime)
Return the min starting time to display- Parameters:
minStartingTime- the min starting time- Returns:
- 00 if the minstarting time is under 30, 30 otherwise
-
getMaxTimeToDisplay
public static LocalTime getMaxTimeToDisplay(LocalTime maxEndingTime)
Return the max ending time to display- Parameters:
maxEndingTime- the max ending time- Returns:
- 30 if the max ending time is under 30, otherwise the next hour
-
checkNoAppointmentsImpacted
public static boolean checkNoAppointmentsImpacted(List<Appointment> listAppointment, int nIdForm, LocalDate dateOfModification, AppointmentFormDTO appointmentForm)
Check if there are appointments impacted by the new week definition- Parameters:
listAppointment- the list of appointmentsnIdForm- the form IddateOfModification- the date of modification (date of apply of the new week definition)appointmentForm- the appointment form- Returns:
- true if there are appointments impacted
-
checkNoAppointmentsImpacted
public static boolean checkNoAppointmentsImpacted(List<Appointment> listAppointment, int nIdForm, int nIdreservationRule, AppointmentFormDTO appointmentForm)
Check if there are appointments impacted by the new week definition- Parameters:
listAppointment- the list of appointmentsnIdForm- the form IdnIdreservationRule- the reservationRule idappointmentForm- the appointment form- Returns:
- true if there are appointments impacted
-
checkNoAppointmentsImpacted
public static boolean checkNoAppointmentsImpacted(List<Slot> listSlotWithAppointment, AppointmentFormDTO appointmentForm)
Check if there are appointments impacted by the new week definition- Parameters:
listSlotsImpacted- the list of slot impactedappointmentForm- the appointment form- Returns:
- true if there are appointments impacted
-
checkNoAppointmentsImpacted
public static boolean checkNoAppointmentsImpacted(List<Slot> listSlotsImpacted, int idReservationRule)
Check if there are appointments impacted by the new week definition- Parameters:
listSlotsImpacted- the list of slot impactednewReservationRule- the reservation rule- Returns:
- true if there are no appointments impacted
-
checkNoValidatedAppointmentsOnThisSlot
public static boolean checkNoValidatedAppointmentsOnThisSlot(Slot slot)
Check that there is no validated appointments on a slot- Parameters:
slot- the slot- Returns:
- true if there are no validated appointments on this slot, false otherwise
-
findSlotsImpactedByThisTimeSlot
public static List<Slot> findSlotsImpactedByThisTimeSlot(TimeSlot timeSlot, int nIdForm, int nIdWeekDefinition, boolean bShiftSlot)
Return the slots impacted by the modification of this time slot- Parameters:
timeSlot- the time slotnIdForm- the form idnIdWeekDefinition- the week definition idbShiftSlot- the boolean value for the shift- Returns:
- the list of slots impacted
-
getStartingDateTime
public static LocalDateTime getStartingDateTime(Appointment appointmentDTO)
-
getEndingDateTime
public static LocalDateTime getEndingDateTime(Appointment appointmentDTO)
-
isConsecutiveSlots
public static boolean isConsecutiveSlots(List<Slot> allSlots)
return true if all slots are consecutive- Parameters:
allSlots- the list of slots- Returns:
- true if all slots are consecutive
-
fillInReservationRuleAdvancedParam
public static void fillInReservationRuleAdvancedParam(ReservationRuleDTO reservationRuleDTO, AppointmentFormDTO appointmentForm)
Fill the reservation rule object with the corresponding values of an appointmentForm DTO- Parameters:
reservationRuleDTO- the reservation rule object to fill inappointmentForm- the appointmentForm DTO
-
weekIsOpenInFO
public static boolean weekIsOpenInFO(AppointmentFormDTO appointmentFormDTO, List<WeekDefinition> listWeek, Locale locale)
check if one of the weeks in the list is open on the FO calendar- Parameters:
appointmentFormDTO- the appointment formlistWeek- the list of weekDefinitionlocale- the locale- Returns:
- true if one of the weeks in the list is open on the FO calendar
-
checkListSlotIsBuildedCorrectly
public static boolean checkListSlotIsBuildedCorrectly(int nIdForm, List<Slot> listSlots)Check if list of slot is builded correctly- Parameters:
nIdForm- the id formlistSlots- the list of slot to check- Returns:
- true if the listSlots is builded correctly
-
shutdownSecheduledExecutor
public static void shutdownSecheduledExecutor()
The following method shuts down the _executorService in two phases, first by calling shutdown to reject incoming tasks, and then calling shutdownNow, if necessary, to cancel any lingering tasks:
-
buildAppointmentDTO
public static AppointmentDTO buildAppointmentDTO(Appointment appointment)
Build an appointment dto from an appointment business object- Parameters:
appointment- the appointment business object- Returns:
- the appointment DTO
-
-