Class SlotService
java.lang.Object
fr.paris.lutece.plugins.appointment.service.SlotService
Service class of a slot
- Author:
- Laurent Payen
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddDateAndTimeToSlot(Slot slot) Form the DTO, adding the date and the time to the slotbuildListSlot(int nIdForm, HashMap<LocalDate, WeekDefinition> mapWeekDefinition, LocalDate startingDate, LocalDate endingDate) Build all the slot for a period with all the rules (open hours ...) to apply on each day, for each slotbuildListSlot(int nIdForm, Map<WeekDefinition, ReservationRule> mapReservationRule, LocalDate startingDate, LocalDate endingDate) Build all the slot for a period with all the rules (open hours ...) to apply on each day, for each slotbuildListSlot(int nIdForm, Map<WeekDefinition, ReservationRule> mapReservationRule, LocalDate startingDate, LocalDate endingDate, int nNbPlaces) Build all the slot for a period with all the rules (open hours ...) to apply on each day, for each slotbuildListSlot(int nIdForm, Map<WeekDefinition, ReservationRule> mapReservationRule, LocalDate startingDate, LocalDate endingDate, int nNbPlaces, boolean bAllOpenSlot) Build all the slot for a period with all the rules (open hours ...) to apply on each day, for each slotstatic HashMap<LocalDateTime,Slot> buildMapSlotsByIdFormAndDateRangeWithDateForKey(int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime) Build a map (Date, Slot) of all the slots found between the two datesstatic SlotbuildSlot(int nIdForm, Period period, int nMaxCapacity, int nNbRemainingPlaces, int nNbPotentialRemainingPlaces, int nNbPlacesTaken, boolean bIsOpen, boolean bIsSpecific) Build a slot with all its valuesstatic SlotcreateSlot(Slot slot) Create a slot in dbstatic voiddeleteListSlots(List<Slot> listSlotToDelete) Delete a list of slotsstatic voiddeleteSlot(Slot slot) Delete a slotfindFirstAvailableSlot(int nIdForm) Find the first slot of a form a user can book from now: inside the weeks the form displays and its validity, after the minimum time before an appointment, open and with a place left.findListOpenSlotByIdFormAndDateRange(int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime) Find the open slots of a form on a given period of timefindListSlot(int nIdForm) Fins all the slots of a formfindListSlotByIdAppointment(int nIdAppointment) Fins all the slots of a formstatic SlotfindSlotById(int nIdSlot) Find a slot with its primary keyfindSlotsByIdFormAndDateRange(int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime) Find slots of a form on a given period of timefindSlotWithAppointmentByDateRange(int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime) Find slots with appointment of a form on a given period of timestatic SlotfindSlotWithMaxDate(int nIdForm) Return the slot with the max DatefindSpecificSlotsByIdForm(int nIdForm) Find specific slots of a formstatic booleanisSpecificSlot(Slot slot) To know if it's a specific slot, need to search for a similar time slotstatic booleanisSpecificSlot(Slot slot, WorkingDay workingDay, List<TimeSlot> listTimeSlot, int nMaxCapacity) To know if it's a specific slot, need to search for a similar time slotstatic SlotSave a slot in databasestatic voidupdateRemainingPlaces(Slot slot) Update the capacity of the slotstatic SlotupdateSlot(Slot slot) Update a slotstatic voidupdateSlot(Slot slot, boolean bEndingTimeHasChanged, LocalTime previousEndingTime, boolean bShifSlot) Update a slot in database and possibly all the slots after (if the ending hour has changed, all the next slots are impacted in case of the user decide to shift the next slots)
-
Method Details
-
findSlotsByIdFormAndDateRange
public static List<Slot> findSlotsByIdFormAndDateRange(int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime) Find slots of a form on a given period of time- Parameters:
nIdForm- the form IdstartingDateTime- the starting date time to searchendingDateTime- the ending date time to search- Returns:
- a list of the slots found
-
findSlotWithAppointmentByDateRange
public static List<Slot> findSlotWithAppointmentByDateRange(int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime) Find slots with appointment of a form on a given period of time- Parameters:
nIdForm- the form IdstartingDateTime- the starting date time to searchendingDateTime- the ending date time to search- Returns:
- a list of the slots found
-
findSpecificSlotsByIdForm
Find specific slots of a form- Parameters:
nIdForm- the form Id- Returns:
- a list of the slots found
-
buildMapSlotsByIdFormAndDateRangeWithDateForKey
public static HashMap<LocalDateTime,Slot> buildMapSlotsByIdFormAndDateRangeWithDateForKey(int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime) Build a map (Date, Slot) of all the slots found between the two dates- Parameters:
nIdForm- the form idstartingDateTime- the starting date timeendingDateTime- the ending date time- Returns:
- the map
-
findListSlot
Fins all the slots of a form- Parameters:
nIdForm- the form id- Returns:
- a list of all the slots of a form
-
findListSlotByIdAppointment
Fins all the slots of a form- Parameters:
nIdAppointment- the appointment id- Returns:
- a list of all the slots of a form
-
findListOpenSlotByIdFormAndDateRange
public static List<Slot> findListOpenSlotByIdFormAndDateRange(int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime) Find the open slots of a form on a given period of time- Parameters:
nIdForm- the form IdstartingDateTime- the starting Date time to searchendingDateTime- the ending Date time to search- Returns:
- a list of open slots whose matches the criteria
-
findSlotById
Find a slot with its primary key- Parameters:
nIdSlot- the slot Id- Returns:
- the Slot object
-
buildListSlot
public static List<Slot> buildListSlot(int nIdForm, HashMap<LocalDate, WeekDefinition> mapWeekDefinition, LocalDate startingDate, LocalDate endingDate) Build all the slot for a period with all the rules (open hours ...) to apply on each day, for each slot- Parameters:
nIdForm- the form IdmapWeekDefinition- the map of the week definitionstartingDate- the starting date of the periodnNbWeeksToDisplay- the number of weeks to build- Returns:
- a list of all the slots built
-
buildListSlot
public static List<Slot> buildListSlot(int nIdForm, Map<WeekDefinition, ReservationRule> mapReservationRule, LocalDate startingDate, LocalDate endingDate) Build all the slot for a period with all the rules (open hours ...) to apply on each day, for each slot- Parameters:
nIdForm- the form IdmapReservationRule- the map of the rule week definitionstartingDate- the starting date of the periodendingDate-
-
buildListSlot
public static List<Slot> buildListSlot(int nIdForm, Map<WeekDefinition, ReservationRule> mapReservationRule, LocalDate startingDate, LocalDate endingDate, int nNbPlaces) Build all the slot for a period with all the rules (open hours ...) to apply on each day, for each slot- Parameters:
nIdForm- the form IdmapReservationRule- the map of the rule week definitionstartingDate- the starting date of the periodendingDate- the ending date of the periodenNbPlaces- the number of place to take
-
buildListSlot
public static List<Slot> buildListSlot(int nIdForm, Map<WeekDefinition, ReservationRule> mapReservationRule, LocalDate startingDate, LocalDate endingDate, int nNbPlaces, boolean bAllOpenSlot) Build all the slot for a period with all the rules (open hours ...) to apply on each day, for each slot- Parameters:
nIdForm- the form IdmapReservationRule- the map of the rule week definitionstartingDate- the starting date of the periodendingDate- the ending date of the periodenNbPlaces- the number of place to takebAllOpenSlot- build slots with the all open slot- Returns:
- list of all the slots built
-
buildSlot
public static Slot buildSlot(int nIdForm, Period period, int nMaxCapacity, int nNbRemainingPlaces, int nNbPotentialRemainingPlaces, int nNbPlacesTaken, boolean bIsOpen, boolean bIsSpecific) Build a slot with all its values- Parameters:
nIdForm- the form IdstartingDateTime- the starting date timeendingDateTime- the ending date timenMaxCapacity- the maximum capacity for the slotnNbRemainingPlaces- the number of remaining places of the slotbIsOpen- true if the slot is open- Returns:
- the slot built
-
findFirstAvailableSlot
Find the first slot of a form a user can book from now: inside the weeks the form displays and its validity, after the minimum time before an appointment, open and with a place left.- Parameters:
nIdForm- the id of the form- Returns:
- the first bookable slot, or empty when the form has none
-
isSpecificSlot
To know if it's a specific slot, need to search for a similar time slot- Parameters:
slot- the slot- Returns:
- true if specific
-
isSpecificSlot
public static boolean isSpecificSlot(Slot slot, WorkingDay workingDay, List<TimeSlot> listTimeSlot, int nMaxCapacity) To know if it's a specific slot, need to search for a similar time slot- Parameters:
slot- the slotworkingDay- the working daylistTimeSlot- the list of time slots- Returns:
- true if it's a specific slot
-
updateSlot
public static void updateSlot(Slot slot, boolean bEndingTimeHasChanged, LocalTime previousEndingTime, boolean bShifSlot) Update a slot in database and possibly all the slots after (if the ending hour has changed, all the next slots are impacted in case of the user decide to shift the next slots)- Parameters:
slot- the slot to updatebEndingTimeHasChanged- true if the ending time has changedpreviousEndingTime- the previous ending timebShifSlot- true if the user has decided to shift the next slots
-
updateRemainingPlaces
Update the capacity of the slot- Parameters:
slot- the slot to update
-
saveSlot
Save a slot in database- Parameters:
slot- the slot to save- Returns:
- the slot saved
-
updateSlot
Update a slot- Parameters:
slot- the slot updated
-
addDateAndTimeToSlot
Form the DTO, adding the date and the time to the slot- Parameters:
slot- the slot on which to add values
-
createSlot
Create a slot in db- Parameters:
slot- the slot to create- Returns:
- the slot created
-
deleteListSlots
Delete a list of slots- Parameters:
listSlotToDelete- the lost of slots to delete
-
deleteSlot
Delete a slot- Parameters:
slot- the slot to delete
-
findSlotWithMaxDate
Return the slot with the max Date- Parameters:
nIdForm- the form id- Returns:
- the slot with the max date
-