Context
- Type of the context for the data access object.public final class AppointmentValidationBuilder<Context> extends Object
When an appointment is validated successfully, it is stored locally and taken into consideration when validating other appointments.
Modifier and Type | Method and Description |
---|---|
AppointmentValidationBuilder<Context> |
clearFlags()
Clears all flags that are used for validation.
|
AppointmentValidationBuilder<Context> |
flags(EAppointmentBookingFlag... flags)
Uses the given flags for validation.
|
AppointmentValidationBuilder<Context> |
flags(Set<EAppointmentBookingFlag> flags)
Uses the given flags for validation.
|
static AppointmentValidationBuilder<IEntityContext> |
forActiveDatabase(IEntityContext ec,
AppointmentTemplate template)
Returns a validation builder backed by an active database connection.
|
static <Context> AppointmentValidationBuilder<Context> |
forCustom(IAppointmentValidationAccessObject<Context> dao,
AppointmentTemplate template)
Returns a validation builder backed by the given data access object.
|
com.google.common.collect.ImmutableList<EAppointmentBookingError> |
getAllErrors() |
com.google.common.collect.ImmutableSet<UUID> |
getSuccessfullyModified() |
int |
getSuccessfullyModifiedCount() |
IAppointmentValidationInfo |
getValidationInfo(long appointmentId) |
AppointmentValidationBuilder<Context> |
now(Instant now) |
void |
registerAppointment(Appointment appointment,
EAppointmentActionType actionType)
Registers an appointment to be validated.
|
Set<EAppointmentBookingError> |
validateAppointment(Context ctx,
Appointment appointment,
EAppointmentActionType actionType,
com.google.common.collect.Range<Instant> newTime)
Validates the given appointment and returns all validation errors.
|
Set<EAppointmentBookingError> |
validateAppointment(Context ctx,
Appointment appointment,
SubmittedAppointment action)
Validates the given appointment and returns all validation errors.
|
public AppointmentValidationBuilder<Context> clearFlags()
validateAppointment(Object, Appointment, EAppointmentActionType, Range)
.public AppointmentValidationBuilder<Context> flags(EAppointmentBookingFlag... flags)
validateAppointment(Object, Appointment, EAppointmentActionType, Range)
.flags
- Flags to use for validation. They are added to the existing flags.public AppointmentValidationBuilder<Context> flags(Set<EAppointmentBookingFlag> flags)
validateAppointment(Object, Appointment, EAppointmentActionType, Range)
.flags
- Flags to use for validation. They are added to the existing flags.public com.google.common.collect.ImmutableList<EAppointmentBookingError> getAllErrors()
validateAppointment(Object, Appointment, EAppointmentActionType, Range)
.public com.google.common.collect.ImmutableSet<UUID> getSuccessfullyModified()
public int getSuccessfullyModifiedCount()
public AppointmentValidationBuilder<Context> now(Instant now)
now
- An instant to use as the current server time.public void registerAppointment(Appointment appointment, EAppointmentActionType actionType)
validateAppointment(Object, Appointment, EAppointmentActionType, Range)
. However, when you wish to
validate multiple appointments, you should call this method on all appointments first. This ensures an optimal
order of validation, e.g. booking an appointment at 12:00 o'clock and then cancelling an existing appointment at
12:00 o'clock does not work, but canceling the existing one first and then booking the other appointment works.
If you call this method on an appointment, you must also later call
validateAppointment(Object, Appointment, EAppointmentActionType, Range)
, or the total validation result
getAllErrors()
may be wrong.
appointment
- Appointment that will be validated later.actionType
- Action that would be applied to the appointment.public Set<EAppointmentBookingError> validateAppointment(Context ctx, Appointment appointment, EAppointmentActionType actionType, com.google.common.collect.Range<Instant> newTime)
ctx
- Context for the data access object.appointment
- Appointment to validate.actionType
- Action that would be performed with the appointment.newTime
- New time of a moved appointment. Should be null
otherwise.public Set<EAppointmentBookingError> validateAppointment(Context ctx, Appointment appointment, SubmittedAppointment action)
ctx
- Context for the data access object.appointment
- Appointment to validate.action
- Action that would be performed with the appointment.public IAppointmentValidationInfo getValidationInfo(long appointmentId)
public static AppointmentValidationBuilder<IEntityContext> forActiveDatabase(IEntityContext ec, AppointmentTemplate template)
ec
- An entity context that must be active.template
- A template for which to validate appointments. Must be contained in the given entity context.public static <Context> AppointmentValidationBuilder<Context> forCustom(IAppointmentValidationAccessObject<Context> dao, AppointmentTemplate template)
Context
- Context required by the data access object.dao
- The data access object to use for looking up existing appointments.template
- A template for which to validate appointments. Must have references its
AppointmentTemplate.getSlots()
, AppointmentTemplate.getClosingTimes()
,
AppointmentTemplate.getAppointmentTypes()
set and accessible.Copyright © 2021 XIMA MEDIA GmbH. All rights reserved.