Class AppointmentUtilities


  • public final class AppointmentUtilities
    extends java.lang.Object
    Utility class for Appointment Mutualize methods between MVCApplication and MVCAdminJspBean
    Author:
    Laurent Payen
    • Field Detail

      • ERROR_MESSAGE_EMPTY_CONFIRM_EMAIL

        public static final java.lang.String ERROR_MESSAGE_EMPTY_CONFIRM_EMAIL
        See Also:
        Constant Field Values
      • ERROR_MESSAGE_CONFIRM_EMAIL

        public static final java.lang.String ERROR_MESSAGE_CONFIRM_EMAIL
        See Also:
        Constant Field Values
      • ERROR_MESSAGE_DATE_APPOINTMENT

        public static final java.lang.String ERROR_MESSAGE_DATE_APPOINTMENT
        See Also:
        Constant Field Values
      • ERROR_MESSAGE_EMPTY_EMAIL

        public static final java.lang.String ERROR_MESSAGE_EMPTY_EMAIL
        See Also:
        Constant Field Values
      • ERROR_MESSAGE_EMPTY_NB_BOOKED_SEAT

        public static final java.lang.String ERROR_MESSAGE_EMPTY_NB_BOOKED_SEAT
        See Also:
        Constant Field Values
      • ERROR_MESSAGE_FORMAT_NB_BOOKED_SEAT

        public static final java.lang.String ERROR_MESSAGE_FORMAT_NB_BOOKED_SEAT
        See Also:
        Constant Field Values
      • ERROR_MESSAGE_ERROR_NB_BOOKED_SEAT

        public static final java.lang.String ERROR_MESSAGE_ERROR_NB_BOOKED_SEAT
        See Also:
        Constant Field Values
      • MARK_PERMISSION_ADD_COMMENT

        public static final java.lang.String MARK_PERMISSION_ADD_COMMENT
        See Also:
        Constant Field Values
      • MARK_PERMISSION_MODERATE_COMMENT

        public static final java.lang.String MARK_PERMISSION_MODERATE_COMMENT
        See Also:
        Constant Field Values
      • MARK_PERMISSION_ACCESS_CODE

        public static final java.lang.String MARK_PERMISSION_ACCESS_CODE
        See Also:
        Constant Field Values
      • OLD_APPOINTMENT_DTO

        public static final java.lang.String OLD_APPOINTMENT_DTO
        See Also:
        Constant Field Values
      • SESSION_TASK_TIMER_SLOT

        public static final java.lang.String SESSION_TASK_TIMER_SLOT
        See Also:
        Constant Field Values
      • PROPERTY_DEFAULT_EXPIRED_TIME_EDIT_APPOINTMENT

        public static final java.lang.String PROPERTY_DEFAULT_EXPIRED_TIME_EDIT_APPOINTMENT
        See Also:
        Constant Field Values
      • CONSTANT_GENERIC_ATTRIBUTE_TYPE_PHONE_NAME

        public static final java.lang.String CONSTANT_GENERIC_ATTRIBUTE_TYPE_PHONE_NAME
        See Also:
        Constant Field Values
      • CONSTANT_PHONE_NUMBERS_SEPARATOR

        public static final java.lang.String CONSTANT_PHONE_NUMBERS_SEPARATOR
        See Also:
        Constant Field Values
    • Method Detail

      • checkEmail

        public static void checkEmail​(java.lang.String strEmail,
                                      java.lang.String strConfirmEmail,
                                      AppointmentFormDTO form,
                                      java.util.Locale locale,
                                      java.util.List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors)
        Check that the email is correct and matches the confirm email
        Parameters:
        strEmail - the email
        strConfirmEmail - the confirm email
        form - the form
        locale - the local
        listFormErrors - the list of errors that can be fill in with the errors found for the email
      • checkDateOfTheAppointmentIsNotBeforeNow

        public static void checkDateOfTheAppointmentIsNotBeforeNow​(AppointmentDTO appointmentDTO,
                                                                   java.util.Locale locale,
                                                                   java.util.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 appointment
        locale - the local
        listFormErrors - the list of errors that can be fill in with the error found with the date
      • checkNbDaysBetweenTwoAppointments

        public static boolean checkNbDaysBetweenTwoAppointments​(AppointmentDTO appointmentDTO,
                                                                java.lang.String strEmail,
                                                                AppointmentFormDTO form)
        Check that the delay between two appointments for the same use has been respected
        Parameters:
        appointmentDTO - the appointment
        strEmail - the email
        form - the form
        Returns:
        false if the delay is not respected
      • checkNbDaysBetweenTwoAppointmentsTaken

        public static boolean checkNbDaysBetweenTwoAppointmentsTaken​(AppointmentDTO appointmentDTO,
                                                                     java.lang.String strEmail,
                                                                     AppointmentFormDTO form)
        Check that the delay between two appointments for the same use has been respected
        Parameters:
        appointmentDTO - the appointment
        strEmail - the email
        form - the form
        Returns:
        false if the delay is not respected
      • checkNbMaxAppointmentsOnAGivenPeriod

        public static boolean checkNbMaxAppointmentsOnAGivenPeriod​(AppointmentDTO appointmentDTO,
                                                                   java.lang.String strEmail,
                                                                   AppointmentFormDTO form)
        Check that the number of appointments on a defined period is not above the maximum authorized
        Parameters:
        appointmentDTO - the appointment
        strEmail - the email of the user
        form - 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,
                                                                      java.lang.String strEmail,
                                                                      AppointmentFormDTO form,
                                                                      java.util.List<AppointmentDTO> listAppointments)
        Check that the number of appointments on a defined category is not above the maximum authorized
        Parameters:
        appointmentDTO - the appointment
        strEmail - the email of the user
        form - the form
        Returns:
        false if the number of appointments is above the maximum authorized on the defined category
      • checkAndReturnNbBookedSeats

        public static int checkAndReturnNbBookedSeats​(java.lang.String strNbBookedSeats,
                                                      AppointmentFormDTO form,
                                                      AppointmentDTO appointmentDTO,
                                                      java.util.Locale locale,
                                                      java.util.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 seats
        form - the form
        nbRemainingPlaces - the number of remaining places on the slot asked
        locale - the locale
        listFormErrors - 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,
                                              java.lang.String strEmail,
                                              java.lang.String strEmailConfirm,
                                              java.lang.String strFirstName,
                                              java.lang.String strLastName)
        Fill the appoinmentFront DTO with the given parameters
        Parameters:
        appointmentDTO - the appointmentFront DTO
        nbBookedSeats - the number of booked seats
        strEmail - the email of the user
        strFirstName - the first name of the user
        strLastName - the last name of the user
      • validateFormAndEntries

        public static void validateFormAndEntries​(AppointmentDTO appointmentDTO,
                                                  javax.servlet.http.HttpServletRequest request,
                                                  java.util.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 validate
        request - the request
        listFormErrors - 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 java.util.List<ResponseRecapDTO> buildListResponse​(AppointmentDTO appointment,
                                                                         javax.servlet.http.HttpServletRequest request,
                                                                         java.util.Locale locale)
        Build a list of response of the appointment
        Parameters:
        appointment - the appointment
        request - the request
        locale - 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 request
        idSlot - the id Slot
      • isEditSlotTaskExpiredTime

        public static boolean isEditSlotTaskExpiredTime​(javax.servlet.http.HttpServletRequest request,
                                                        int idSlot)
      • putTimerInSession

        public static java.util.concurrent.ScheduledFuture<Slot> putTimerInSession​(javax.servlet.http.HttpServletRequest request,
                                                                                   int nIdSlot,
                                                                                   AppointmentDTO appointmentDTO,
                                                                                   int maxPeoplePerAppointment)
        Create a timer on a slot
        Parameters:
        slot - the slot
        appointmentDTO - the appointment
        maxPeoplePerAppointment - the max people per appointment
        Returns:
        the ScheduledFuture
      • getPermissions

        public static java.lang.String[][] getPermissions​(java.util.List<AppointmentFormDTO> listForms,
                                                          fr.paris.lutece.portal.business.user.AdminUser user)
        Get Form Permissions
        Parameters:
        listForms -
        request -
        Returns:
      • getMinTimeToDisplay

        public static java.time.LocalTime getMinTimeToDisplay​(java.time.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 java.time.LocalTime getMaxTimeToDisplay​(java.time.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​(java.util.List<Appointment> listAppointment,
                                                          int nIdForm,
                                                          java.time.LocalDate dateOfModification,
                                                          AppointmentFormDTO appointmentForm)
        Check if there are appointments impacted by the new week definition
        Parameters:
        listAppointment - the list of appointments
        nIdForm - the form Id
        dateOfModification - 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​(java.util.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 appointments
        nIdForm - the form Id
        nIdreservationRule - the reservationRule id
        appointmentForm - the appointment form
        Returns:
        true if there are appointments impacted
      • checkNoAppointmentsImpacted

        public static boolean checkNoAppointmentsImpacted​(java.util.List<Slot> listSlotWithAppointment,
                                                          AppointmentFormDTO appointmentForm)
        Check if there are appointments impacted by the new week definition
        Parameters:
        listSlotsImpacted - the list of slot impacted
        appointmentForm - the appointment form
        Returns:
        true if there are appointments impacted
      • checkNoAppointmentsImpacted

        public static boolean checkNoAppointmentsImpacted​(java.util.List<Slot> listSlotsImpacted,
                                                          int idReservationRule)
        Check if there are appointments impacted by the new week definition
        Parameters:
        listSlotsImpacted - the list of slot impacted
        newReservationRule - 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 java.util.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 slot
        nIdForm - the form id
        nIdWeekDefinition - the week definition id
        bShiftSlot - the boolean value for the shift
        Returns:
        the list of slots impacted
      • getStartingDateTime

        public static java.time.LocalDateTime getStartingDateTime​(Appointment appointmentDTO)
      • getEndingDateTime

        public static java.time.LocalDateTime getEndingDateTime​(Appointment appointmentDTO)
      • isConsecutiveSlots

        public static boolean isConsecutiveSlots​(java.util.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 in
        appointmentForm - the appointmentForm DTO
      • weekIsOpenInFO

        public static boolean weekIsOpenInFO​(AppointmentFormDTO appointmentFormDTO,
                                             java.util.List<WeekDefinition> listWeek,
                                             java.util.Locale locale)
        check if one of the weeks in the list is open on the FO calendar
        Parameters:
        appointmentFormDTO - the appointment form
        listWeek - the list of weekDefinition
        locale - 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,
                                                              java.util.List<Slot> listSlots)
        Check if list of slot is builded correctly
        Parameters:
        nIdForm - the id form
        listSlots - 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:
      • getFormattedDateAppointmentTaken

        public static java.lang.String getFormattedDateAppointmentTaken​(java.time.LocalDateTime dateAppointmentTaken)
        Format the date of the appointment taken
      • 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
      • setAppointmentPhoneNumberValuesFromResponse

        public static void setAppointmentPhoneNumberValuesFromResponse​(AppointmentDTO appointment)
        Set the appointment's phone number values, if a user entered them in a Generic Attributes of type 'Phone Number'. These values are retrieved from the appointment's responses.
        Parameters:
        appointment - the appointment to process