Class AppointmentUtilities
- java.lang.Object
-
- fr.paris.lutece.plugins.appointment.service.AppointmentUtilities
-
public final class AppointmentUtilities extends java.lang.ObjectUtility class for Appointment Mutualize methods between MVCApplication and MVCAdminJspBean- Author:
- Laurent Payen
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCONSTANT_GENERIC_ATTRIBUTE_TYPE_PHONE_NAMEstatic java.lang.StringCONSTANT_PHONE_NUMBERS_SEPARATORstatic java.lang.StringERROR_MESSAGE_CONFIRM_EMAILstatic java.lang.StringERROR_MESSAGE_DATE_APPOINTMENTstatic java.lang.StringERROR_MESSAGE_EMPTY_CONFIRM_EMAILstatic java.lang.StringERROR_MESSAGE_EMPTY_EMAILstatic java.lang.StringERROR_MESSAGE_EMPTY_NB_BOOKED_SEATstatic java.lang.StringERROR_MESSAGE_ERROR_NB_BOOKED_SEATstatic java.lang.StringERROR_MESSAGE_FORMAT_NB_BOOKED_SEATstatic java.lang.StringMARK_PERMISSION_ACCESS_CODEstatic java.lang.StringMARK_PERMISSION_ADD_COMMENTstatic java.lang.StringMARK_PERMISSION_MODERATE_COMMENTstatic java.lang.StringOLD_APPOINTMENT_DTOstatic java.lang.StringPROPERTY_DEFAULT_EXPIRED_TIME_EDIT_APPOINTMENTstatic java.lang.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 java.util.List<ResponseRecapDTO>buildListResponse(AppointmentDTO appointment, javax.servlet.http.HttpServletRequest request, java.util.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(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 askedstatic voidcheckDateOfTheAppointmentIsNotBeforeNow(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 paststatic voidcheckEmail(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 emailstatic booleancheckListSlotIsBuildedCorrectly(int nIdForm, java.util.List<Slot> listSlots)Check if list of slot is builded correctlystatic booleancheckNbDaysBetweenTwoAppointments(AppointmentDTO appointmentDTO, java.lang.String strEmail, AppointmentFormDTO form)Check that the delay between two appointments for the same use has been respectedstatic booleancheckNbDaysBetweenTwoAppointmentsTaken(AppointmentDTO appointmentDTO, java.lang.String strEmail, AppointmentFormDTO form)Check that the delay between two appointments for the same use has been respectedstatic booleancheckNbMaxAppointmentsDefinedOnCategory(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 authorizedstatic booleancheckNbMaxAppointmentsOnAGivenPeriod(AppointmentDTO appointmentDTO, java.lang.String strEmail, AppointmentFormDTO form)Check that the number of appointments on a defined period is not above the maximum authorizedstatic booleancheckNoAppointmentsImpacted(java.util.List<Appointment> listAppointment, int nIdForm, int nIdreservationRule, AppointmentFormDTO appointmentForm)Check if there are appointments impacted by the new week definitionstatic booleancheckNoAppointmentsImpacted(java.util.List<Appointment> listAppointment, int nIdForm, java.time.LocalDate dateOfModification, AppointmentFormDTO appointmentForm)Check if there are appointments impacted by the new week definitionstatic booleancheckNoAppointmentsImpacted(java.util.List<Slot> listSlotsImpacted, int idReservationRule)Check if there are appointments impacted by the new week definitionstatic booleancheckNoAppointmentsImpacted(java.util.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, java.lang.String strEmail, java.lang.String strEmailConfirm, java.lang.String strFirstName, java.lang.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 java.util.List<Slot>findSlotsImpactedByThisTimeSlot(TimeSlot timeSlot, int nIdForm, int nIdWeekDefinition, boolean bShiftSlot)Return the slots impacted by the modification of this time slotstatic java.time.LocalDateTimegetEndingDateTime(Appointment appointmentDTO)static java.lang.StringgetFormattedDateAppointmentTaken(java.time.LocalDateTime dateAppointmentTaken)Format the date of the appointment takenstatic java.time.LocalTimegetMaxTimeToDisplay(java.time.LocalTime maxEndingTime)Return the max ending time to displaystatic java.time.LocalTimegetMinTimeToDisplay(java.time.LocalTime minStartingTime)Return the min starting time to displaystatic java.lang.String[][]getPermissions(java.util.List<AppointmentFormDTO> listForms, fr.paris.lutece.portal.business.user.AdminUser user)Get Form Permissionsstatic java.time.LocalDateTimegetStartingDateTime(Appointment appointmentDTO)static booleanisConsecutiveSlots(java.util.List<Slot> allSlots)return true if all slots are consecutivestatic booleanisEditSlotTaskExpiredTime(javax.servlet.http.HttpServletRequest request, int idSlot)static java.util.concurrent.ScheduledFuture<Slot>putTimerInSession(javax.servlet.http.HttpServletRequest request, int nIdSlot, AppointmentDTO appointmentDTO, int maxPeoplePerAppointment)Create a timer on a slotstatic voidsetAppointmentPhoneNumberValuesFromResponse(AppointmentDTO appointment)Set the appointment's phone number values, if a user entered them in a Generic Attributes of type 'Phone Number'.static 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, java.util.List<fr.paris.lutece.plugins.genericattributes.business.GenericAttributeError> listFormErrors, boolean allEntries)Validate the form and the additional entries of the formstatic booleanweekIsOpenInFO(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
-
-
-
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
-
THIRTY_MINUTES
public static final int THIRTY_MINUTES
- 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 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, 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 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, java.lang.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, java.lang.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, 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 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, 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 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(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 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, 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 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, 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 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 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 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 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 slotappointmentDTO- the appointmentmaxPeoplePerAppointment- 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 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(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 appointmentsnIdForm- the form IdnIdreservationRule- the reservationRule idappointmentForm- 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 impactedappointmentForm- 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 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 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 slotnIdForm- the form idnIdWeekDefinition- the week definition idbShiftSlot- 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 inappointmentForm- 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 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, java.util.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:
-
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
-
-