Class BaseAppointmentHelper

java.lang.Object
de.xima.fc.appointment.BaseAppointmentHelper
Direct Known Subclasses:
AppointmentHelper

public class BaseAppointmentHelper extends Object
Helper methods for the appointment module.
Since:
6.5.0
Author:
XIMA MEDIA GmbH
  • Field Details

    • WEEK_START

      public static final LocalDate WEEK_START
      The week to use for the UI that lets the user configure the available AppointmentSlots.
  • Constructor Details

    • BaseAppointmentHelper

      public BaseAppointmentHelper()
  • Method Details

    • applySlotConstraints

      public static List<AppointmentSlot> applySlotConstraints(List<AppointmentSlot> slots, AppointmentTemplate template)
      Sanitizes the given slots so that they conform the restrictions imposed by the given appointment template.
      Parameters:
      slots - Slots to constrain.
      template - Template to which the slots must adhere.
      Returns:
      A list of slots that is identical to the given list if all slots meet the constraints of the given template. Otherwise, slots may be modified or deleted to meet those constraints.
    • createClosedDateTimeRanges

      public static com.google.common.collect.ImmutableRangeSet<Instant> createClosedDateTimeRanges(List<IAppointmentClosingTime> closingTimes, com.google.common.collect.BoundType boundType, ZoneId sourceZone)
      Creates the temporal disjoint intervals corresponding the given closing times. Closing times are interpreted in the given source time zone and converted to the given target time zone.
      Parameters:
      closingTimes - List of closing times to process.
      boundType - Whether to create closed or open ranges from the closing times.
      sourceZone - The source time zone in which the given closing times are interpreted. Should usually be the AppointmentTemplate.getZoneId() of the AppointmentClosingTime.getAppointmentTemplate().
      Returns:
      The disjoint ranges corresponding to the given closing times, converted to the given target time zone.
    • createDefaultSlots

      public static List<AppointmentSlot> createDefaultSlots()
      Creates the default AppointmentTemplate.getSlots() when none are set yet.
      Returns:
      The default slots.
    • createSlot

      public static AppointmentSlot createSlot(LocalDateTime dateTime)
      Creates a new slot starting at the given date.
      Parameters:
      dateTime - Starting date for the new slot.
      Returns:
      A new slot that starts at the given date.
    • getSlotDateTime

      public static com.google.common.collect.Range<LocalDateTime> getSlotDateTime(AppointmentSlot slot)
      Parameters:
      slot - A slot to process.
      Returns:
      The date time range for the given slot that lies in the WEEK_START.
    • getSlotDateTimeRange

      public static com.google.common.collect.Range<LocalDateTime> getSlotDateTimeRange(AppointmentSlot slot)
      Returns the date time range of the given slot.
      Parameters:
      slot - A slot to process.
      Returns:
      The date time range of the given slot.
    • getSlotFromDateTime

      public static LocalDateTime getSlotFromDateTime(AppointmentSlot slot)
      Parameters:
      slot - A slot to use.
      Returns:
      The date time for the start of the given slot that lies in the WEEK_START.
    • getSlotToDateTime

      public static LocalDateTime getSlotToDateTime(AppointmentSlot slot)
      Parameters:
      slot - A slot to use.
      Returns:
      The date time for the end of the given slot that lies in the WEEK_START.
    • getTimeOnGrid

      public static LocalTime getTimeOnGrid(LocalTime time, Duration duration)
      Adjusts the given time to a time that lies on the grid defined by the appointment type.
      Parameters:
      time - A local time to process.
      duration - Duration of the grid.
      Returns:
      The given time, adjusted so that is lies on the grid given by the appointment type.
    • isSlotOverlapping

      public static boolean isSlotOverlapping(AppointmentTemplate template, AppointmentSlot slot)
      Checks whether the given slot is overlapping any slot of the given template.
      Parameters:
      template - An AppointmentTemplate with slots.
      slot - A slot to check.
      Returns:
      true if the given slot has any overlap with any slot of the given template.
    • mergeOverlappingSlots

      public static AppointmentSlot mergeOverlappingSlots(AppointmentSlot lhs, AppointmentSlot rhs)
      Takes two overlapping slots and creates a new slot with the start and end time set to the overlapping interval.
      Parameters:
      lhs - First slot to merge.
      rhs - Seconds slot to merge.
      Returns:
      The merged appointment slot.
    • mergeOverlappingSlots

      public static List<AppointmentSlot> mergeOverlappingSlots(List<AppointmentSlot> slots)
      Merges all overlapping slots.
      Parameters:
      slots - List of slots to merge.
      Returns:
      A list of merged slots.