Class SlotService
- java.lang.Object
-
- fr.paris.lutece.plugins.appointment.service.SlotService
-
public final class SlotService extends Object
Service class of a slot- Author:
- Laurent Payen
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddDateAndTimeToSlot(Slot slot)Form the DTO, adding the date and the time to the slotstatic 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 slotstatic 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 slotstatic 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 slotstatic 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 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 slotstatic List<Slot>findListOpenSlotByIdFormAndDateRange(int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime)Find the open slots of a form on a given period of timestatic List<Slot>findListSlot(int nIdForm)Fins all the slots of a formstatic List<Slot>findListSlotByIdAppointment(int nIdAppointment)Fins all the slots of a formstatic SlotfindSlotById(int nIdSlot)Find a slot with its primary keystatic List<Slot>findSlotsByIdFormAndDateRange(int nIdForm, LocalDateTime startingDateTime, LocalDateTime endingDateTime)Find slots of a form on a given period of timestatic List<Slot>findSlotWithAppointmentByDateRange(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 Datestatic List<Slot>findSpecificSlotsByIdForm(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 SlotsaveSlot(Slot slot)Save 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 Detail
-
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
public static List<Slot> findSpecificSlotsByIdForm(int nIdForm)
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
public static List<Slot> findListSlot(int nIdForm)
Fins all the slots of a form- Parameters:
nIdForm- the form id- Returns:
- a list of all the slots of a form
-
findListSlotByIdAppointment
public static List<Slot> findListSlotByIdAppointment(int nIdAppointment)
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
public static Slot findSlotById(int nIdSlot)
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
-
isSpecificSlot
public static boolean isSpecificSlot(Slot slot)
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
public static void updateRemainingPlaces(Slot slot)
Update the capacity of the slot- Parameters:
slot- the slot to update
-
saveSlot
public static Slot saveSlot(Slot slot)
Save a slot in database- Parameters:
slot- the slot to save- Returns:
- the slot saved
-
updateSlot
public static Slot updateSlot(Slot slot)
Update a slot- Parameters:
slot- the slot updated
-
addDateAndTimeToSlot
public static void addDateAndTimeToSlot(Slot slot)
Form the DTO, adding the date and the time to the slot- Parameters:
slot- the slot on which to add values
-
createSlot
public static Slot createSlot(Slot slot)
Create a slot in db- Parameters:
slot- the slot to create- Returns:
- the slot created
-
deleteListSlots
public static void deleteListSlots(List<Slot> listSlotToDelete)
Delete a list of slots- Parameters:
listSlotToDelete- the lost of slots to delete
-
deleteSlot
public static void deleteSlot(Slot slot)
Delete a slot- Parameters:
slot- the slot to delete
-
findSlotWithMaxDate
public static Slot findSlotWithMaxDate(int nIdForm)
Return the slot with the max Date- Parameters:
nIdForm- the form id- Returns:
- the slot with the max date
-
-