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 Details

  • Method Details

    • 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 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, 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 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, 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, 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, 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, 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 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(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 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, String strEmail, String strEmailConfirm, String strFirstName, 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, 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 List<ResponseRecapDTO> buildListResponse(AppointmentDTO appointment, javax.servlet.http.HttpServletRequest request, 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 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 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 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(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(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(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 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 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 in
      appointmentForm - 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 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, 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 String getFormattedDateAppointmentTaken(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