Class SlotService


  • public final class SlotService
    extends java.lang.Object
    Service class of a slot
    Author:
    Laurent Payen
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addDateAndTimeToSlot​(Slot slot)
      Form the DTO, adding the date and the time to the slot
      static java.util.List<Slot> buildListSlot​(int nIdForm, java.util.HashMap<java.time.LocalDate,​WeekDefinition> mapWeekDefinition, java.time.LocalDate startingDate, java.time.LocalDate endingDate)
      Build all the slot for a period with all the rules (open hours ...) to apply on each day, for each slot
      static java.util.List<Slot> buildListSlot​(int nIdForm, java.util.Map<WeekDefinition,​ReservationRule> mapReservationRule, java.time.LocalDate startingDate, java.time.LocalDate endingDate)
      Build all the slot for a period with all the rules (open hours ...) to apply on each day, for each slot
      static java.util.List<Slot> buildListSlot​(int nIdForm, java.util.Map<WeekDefinition,​ReservationRule> mapReservationRule, java.time.LocalDate startingDate, java.time.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
      static java.util.List<Slot> buildListSlot​(int nIdForm, java.util.Map<WeekDefinition,​ReservationRule> mapReservationRule, java.time.LocalDate startingDate, java.time.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
      static java.util.HashMap<java.time.LocalDateTime,​Slot> buildMapSlotsByIdFormAndDateRangeWithDateForKey​(int nIdForm, java.time.LocalDateTime startingDateTime, java.time.LocalDateTime endingDateTime)
      Build a map (Date, Slot) of all the slots found between the two dates
      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
      static Slot createSlot​(Slot slot)
      Create a slot in db
      static void deleteListSlots​(java.util.List<Slot> listSlotToDelete)
      Delete a list of slots
      static void deleteSlot​(Slot slot)
      Delete a slot
      static java.util.List<Slot> findListOpenSlotByIdFormAndDateRange​(int nIdForm, java.time.LocalDateTime startingDateTime, java.time.LocalDateTime endingDateTime)
      Find the open slots of a form on a given period of time
      static java.util.List<Slot> findListSlot​(int nIdForm)
      Fins all the slots of a form
      static java.util.List<Slot> findListSlotByIdAppointment​(int nIdAppointment)
      Fins all the slots of a form
      static Slot findSlotById​(int nIdSlot)
      Find a slot with its primary key
      static java.util.List<Slot> findSlotsByIdFormAndDateRange​(int nIdForm, java.time.LocalDateTime startingDateTime, java.time.LocalDateTime endingDateTime)
      Find slots of a form on a given period of time
      static java.util.List<Slot> findSlotWithAppointmentByDateRange​(int nIdForm, java.time.LocalDateTime startingDateTime, java.time.LocalDateTime endingDateTime)
      Find slots with appointment of a form on a given period of time
      static Slot findSlotWithMaxDate​(int nIdForm)
      Return the slot with the max Date
      static java.util.List<Slot> findSpecificSlotsByIdForm​(int nIdForm)
      Find specific slots of a form
      static boolean isSpecificSlot​(Slot slot)
      To know if it's a specific slot, need to search for a similar time slot
      static boolean isSpecificSlot​(Slot slot, WorkingDay workingDay, java.util.List<TimeSlot> listTimeSlot, int nMaxCapacity)
      To know if it's a specific slot, need to search for a similar time slot
      static Slot saveSlot​(Slot slot)
      Save a slot in database
      static void updateRemainingPlaces​(Slot slot)
      Update the capacity of the slot
      static Slot updateSlot​(Slot slot)
      Update a slot
      static void updateSlot​(Slot slot, boolean bEndingTimeHasChanged, java.time.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)
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • findSlotsByIdFormAndDateRange

        public static java.util.List<Slot> findSlotsByIdFormAndDateRange​(int nIdForm,
                                                                         java.time.LocalDateTime startingDateTime,
                                                                         java.time.LocalDateTime endingDateTime)
        Find slots of a form on a given period of time
        Parameters:
        nIdForm - the form Id
        startingDateTime - the starting date time to search
        endingDateTime - the ending date time to search
        Returns:
        a list of the slots found
      • findSlotWithAppointmentByDateRange

        public static java.util.List<Slot> findSlotWithAppointmentByDateRange​(int nIdForm,
                                                                              java.time.LocalDateTime startingDateTime,
                                                                              java.time.LocalDateTime endingDateTime)
        Find slots with appointment of a form on a given period of time
        Parameters:
        nIdForm - the form Id
        startingDateTime - the starting date time to search
        endingDateTime - the ending date time to search
        Returns:
        a list of the slots found
      • findSpecificSlotsByIdForm

        public static java.util.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 java.util.HashMap<java.time.LocalDateTime,​Slot> buildMapSlotsByIdFormAndDateRangeWithDateForKey​(int nIdForm,
                                                                                                                            java.time.LocalDateTime startingDateTime,
                                                                                                                            java.time.LocalDateTime endingDateTime)
        Build a map (Date, Slot) of all the slots found between the two dates
        Parameters:
        nIdForm - the form id
        startingDateTime - the starting date time
        endingDateTime - the ending date time
        Returns:
        the map
      • findListSlot

        public static java.util.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 java.util.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 java.util.List<Slot> findListOpenSlotByIdFormAndDateRange​(int nIdForm,
                                                                                java.time.LocalDateTime startingDateTime,
                                                                                java.time.LocalDateTime endingDateTime)
        Find the open slots of a form on a given period of time
        Parameters:
        nIdForm - the form Id
        startingDateTime - the starting Date time to search
        endingDateTime - 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 java.util.List<Slot> buildListSlot​(int nIdForm,
                                                         java.util.HashMap<java.time.LocalDate,​WeekDefinition> mapWeekDefinition,
                                                         java.time.LocalDate startingDate,
                                                         java.time.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 Id
        mapWeekDefinition - the map of the week definition
        startingDate - the starting date of the period
        nNbWeeksToDisplay - the number of weeks to build
        Returns:
        a list of all the slots built
      • buildListSlot

        public static java.util.List<Slot> buildListSlot​(int nIdForm,
                                                         java.util.Map<WeekDefinition,​ReservationRule> mapReservationRule,
                                                         java.time.LocalDate startingDate,
                                                         java.time.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 Id
        mapReservationRule - the map of the rule week definition
        startingDate - the starting date of the period
        endingDate -
      • buildListSlot

        public static java.util.List<Slot> buildListSlot​(int nIdForm,
                                                         java.util.Map<WeekDefinition,​ReservationRule> mapReservationRule,
                                                         java.time.LocalDate startingDate,
                                                         java.time.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 Id
        mapReservationRule - the map of the rule week definition
        startingDate - the starting date of the period
        endingDate - the ending date of the periode
        nNbPlaces - the number of place to take
      • buildListSlot

        public static java.util.List<Slot> buildListSlot​(int nIdForm,
                                                         java.util.Map<WeekDefinition,​ReservationRule> mapReservationRule,
                                                         java.time.LocalDate startingDate,
                                                         java.time.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 Id
        mapReservationRule - the map of the rule week definition
        startingDate - the starting date of the period
        endingDate - the ending date of the periode
        nNbPlaces - the number of place to take
        bAllOpenSlot - 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 Id
        startingDateTime - the starting date time
        endingDateTime - the ending date time
        nMaxCapacity - the maximum capacity for the slot
        nNbRemainingPlaces - the number of remaining places of the slot
        bIsOpen - 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,
                                             java.util.List<TimeSlot> listTimeSlot,
                                             int nMaxCapacity)
        To know if it's a specific slot, need to search for a similar time slot
        Parameters:
        slot - the slot
        workingDay - the working day
        listTimeSlot - the list of time slots
        Returns:
        true if it's a specific slot
      • updateSlot

        public static void updateSlot​(Slot slot,
                                      boolean bEndingTimeHasChanged,
                                      java.time.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 update
        bEndingTimeHasChanged - true if the ending time has changed
        previousEndingTime - the previous ending time
        bShifSlot - 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​(java.util.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