Class AppointmentUtilities
java.lang.Object
fr.paris.lutece.plugins.appointment.service.AppointmentUtilities
Utility class for Appointment Mutualize methods between MVCApplication and MVCAdminJspBean
- Author:
- Laurent Payen
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic 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 booleanCheck 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 DTOfindSlotsImpactedByThisTimeSlot(TimeSlot timeSlot, int nIdForm, int nIdWeekDefinition, boolean bShiftSlot) Return the slots impacted by the modification of this time slotstatic LocalDateTimegetEndingDateTime(Appointment appointmentDTO) static StringgetFormattedDateAppointmentTaken(LocalDateTime dateAppointmentTaken) Format the date of the appointment takenstatic 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 voidSet the appointment's phone number values, if a user entered them in a Generic Attributes of type 'Phone Number'.static voidThe 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 Details
-
ERROR_MESSAGE_EMPTY_CONFIRM_EMAIL
- See Also:
-
ERROR_MESSAGE_CONFIRM_EMAIL
- See Also:
-
ERROR_MESSAGE_DATE_APPOINTMENT
- See Also:
-
ERROR_MESSAGE_EMPTY_EMAIL
- See Also:
-
ERROR_MESSAGE_EMPTY_NB_BOOKED_SEAT
- See Also:
-
ERROR_MESSAGE_FORMAT_NB_BOOKED_SEAT
- See Also:
-
ERROR_MESSAGE_ERROR_NB_BOOKED_SEAT
- See Also:
-
MARK_PERMISSION_ADD_COMMENT
- See Also:
-
MARK_PERMISSION_MODERATE_COMMENT
- See Also:
-
MARK_PERMISSION_ACCESS_CODE
- See Also:
-
OLD_APPOINTMENT_DTO
- See Also:
-
SESSION_TASK_TIMER_SLOT
- See Also:
-
PROPERTY_DEFAULT_EXPIRED_TIME_EDIT_APPOINTMENT
- See Also:
-
THIRTY_MINUTES
public static final int THIRTY_MINUTES- See Also:
-
CONSTANT_GENERIC_ATTRIBUTE_TYPE_PHONE_NAME
- See Also:
-
CONSTANT_PHONE_NUMBERS_SEPARATOR
- See Also:
-
-
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 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
-
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
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
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
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
-
getEndingDateTime
-
isConsecutiveSlots
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
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: -
getFormattedDateAppointmentTaken
Format the date of the appointment taken -
buildAppointmentDTO
Build an appointment dto from an appointment business object- Parameters:
appointment- the appointment business object- Returns:
- the appointment DTO
-
setAppointmentPhoneNumberValuesFromResponse
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
-