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 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 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 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 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 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 id
      startingDateTime - the starting date time
      endingDateTime - 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 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 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 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 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 Id
      mapReservationRule - the map of the rule week definition
      startingDate - the starting date of the period
      endingDate -
    • 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 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 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 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, 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, 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(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