Package de.xima.fc.appointment
Class BaseAppointmentHelper
java.lang.Object
de.xima.fc.appointment.BaseAppointmentHelper
- Direct Known Subclasses:
AppointmentHelper
Helper methods for the appointment module.
- Since:
- 6.5.0
- Author:
- XIMA MEDIA GmbH
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LocalDate
The week to use for the UI that lets the user configure the availableAppointmentSlot
s. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<AppointmentSlot>
applySlotConstraints
(List<AppointmentSlot> slots, AppointmentTemplate template) Sanitizes the given slots so that they conform the restrictions imposed by the given appointment template.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.static List<AppointmentSlot>
Creates the defaultAppointmentTemplate.getSlots()
when none are set yet.static AppointmentSlot
createSlot
(LocalDateTime dateTime) Creates a new slot starting at the given date.static com.google.common.collect.Range<LocalDateTime>
static com.google.common.collect.Range<LocalDateTime>
Returns the date time range of the given slot.static LocalDateTime
static LocalDateTime
static LocalTime
getTimeOnGrid
(LocalTime time, Duration duration) Adjusts the given time to a time that lies on the grid defined by the appointment type.static boolean
isSlotOverlapping
(AppointmentTemplate template, AppointmentSlot slot) Checks whether the given slot is overlapping any slot of the given template.static AppointmentSlot
Takes two overlapping slots and creates a new slot with the start and end time set to the overlapping interval.static List<AppointmentSlot>
mergeOverlappingSlots
(List<AppointmentSlot> slots) Merges all overlapping slots.
-
Field Details
-
WEEK_START
The week to use for the UI that lets the user configure the availableAppointmentSlot
s.
-
-
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 theAppointmentTemplate.getZoneId()
of theAppointmentClosingTime.getAppointmentTemplate()
.- Returns:
- The disjoint ranges corresponding to the given closing times, converted to the given target time zone.
-
createDefaultSlots
Creates the defaultAppointmentTemplate.getSlots()
when none are set yet.- Returns:
- The default slots.
-
createSlot
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
- 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
- Parameters:
slot
- A slot to use.- Returns:
- The date time for the start of the given slot that lies in the
WEEK_START
.
-
getSlotToDateTime
- Parameters:
slot
- A slot to use.- Returns:
- The date time for the end of the given slot that lies in the
WEEK_START
.
-
getTimeOnGrid
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
Checks whether the given slot is overlapping any slot of the given template.- Parameters:
template
- AnAppointmentTemplate
with slots.slot
- A slot to check.- Returns:
true
if the given slot has any overlap with any slot of the given template.
-
mergeOverlappingSlots
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
Merges all overlapping slots.- Parameters:
slots
- List of slots to merge.- Returns:
- A list of merged slots.
-