Class ReservationEventRequest
java.lang.Object
ch.tocco.nice2.optional.reservation.api.ReservationEventRequest
Encapsulates all information needed to create or modify a
CalendarEvent
for
a given Reservation
entity.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A calendar event of a reservation may be associated to either a room or appliance.static final class
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ReservationEventRequest
Creates a new request using this request and the new specified assigned entity.forTargetRelation
(String relationName) Creates a new request using this request and adds a new assigned entity using only the givenrelationName
which is the path from theCalendar_event
to an entity that is expected to be linked to the calendar_event.Returns a filter forCalendarEvent
s.Returns the relation-path and target entity of the entity to create conflicts for.Returns the context from theReservation
entity.Returns a filter forCalendarEvent
s.getDates()
Returns the most specific from/to dates for this request: If aassignedTarget
relation is defined, those specific dates are returned, or the standard from/to dates of the reservation as a fallback. If noassignedTarget
is defined, the reservation dates are returned if available, and those of facility and/or inventory serve as fallback.Returns the from/to fields for the facility, if the model contains those fields.Returns the from/to fields for the inventory, if the model contains those fields.Returns the from/to fields of theReservation
entity.static boolean
isFacilityDateField
(String fieldname) Returnstrue
iff the given fieldname equals eitherFACILITY_FROM
orFACILITY_TILL
.static boolean
isInventoryDateField
(String fieldname) Returnstrue
, iff the given fieldname equals eitherINVENTORY_FROM
orINVENTORY_TILL
.static boolean
isReservationDateField
(String fieldname) Returnstrue
, iff the given fieldname equals eitherRESERVATION_FROM
orRESERVATION_TILL
static boolean
isReservationLabelField
(String fieldname) Returns `true`, iff the given field name denotes the label field of the Reservation entity.resolveFrom
(Entity source, Entity target, String relationPath) Resolves to the entity found atrelationPath
going from the given source entity.withConflictSettings
(Entity target, String relationName) Conflict settings are essentially another assigned-target consisting of a path from theCalendar_event
to the entity that is the physical potential conflicting entity regarding this calendar event.
-
Field Details
-
RESERVATION
- See Also:
-
REL_RESERVATION
- See Also:
-
REL_APPLIANCE
- See Also:
-
REL_FACILITY
- See Also:
-
ENTITY_APPLIANCE
- See Also:
-
ENTITY_FACILITY
- See Also:
-
-
Method Details
-
createFor
-
forTarget
Creates a new request using this request and the new specified assigned entity. TherelationName
is the path from theCalendar_event
to the entity that is expected to be linked to the calendar event. -
forTargetRelation
Creates a new request using this request and adds a new assigned entity using only the givenrelationName
which is the path from theCalendar_event
to an entity that is expected to be linked to the calendar_event. -
withConflictSettings
Conflict settings are essentially another assigned-target consisting of a path from theCalendar_event
to the entity that is the physical potential conflicting entity regarding this calendar event. In most cases it is the same as the entity that is directly linked to the calendar event (like "Room/relRoom" or "Appliance/relAppliance"). But it might also be further down, like on registrations (User/relReservation_registration.relRegistration.relUser). This method creates a new request using this request and the specified conflict settings. -
getReservation
-
getAssignedTarget
-
getConflictSetting
Returns the relation-path and target entity of the entity to create conflicts for. This is not necessarily the same asassignedTarget
(which is the entity the calendar-event is linked to!). But if no special conflicting target is specified, theassignedTarget
is returned. -
isFacilityDateField
Returnstrue
iff the given fieldname equals eitherFACILITY_FROM
orFACILITY_TILL
. -
isInventoryDateField
Returnstrue
, iff the given fieldname equals eitherINVENTORY_FROM
orINVENTORY_TILL
. -
isReservationDateField
Returnstrue
, iff the given fieldname equals eitherRESERVATION_FROM
orRESERVATION_TILL
-
isReservationLabelField
Returns `true`, iff the given field name denotes the label field of the Reservation entity. -
resolveFrom
public static Optional<Entity> resolveFrom(Entity source, Entity target, String relationPath) throws PersistException Resolves to the entity found atrelationPath
going from the given source entity. This is a helper, becauseentity.resolve("relSomething.relAntoher")
does not work! It only resolves one step (a relation name, but not a relation path)!- Throws:
PersistException
-
getContext
Returns the context from theReservation
entity. -
getCalendarEventFilter
Returns a filter forCalendarEvent
s. This is deduced from the values given to this request and applies any existing constraints. At first, the filter will always return calendar events linked to the reservation entity of this request. If aassignedTarget
is defined, it is used to further constrain the query by requiring the calendar events to have an existing target for the specified relation name, and, if the target-entity is defined, too, this target must exist. -
getDateRestrictedEventFilter
Returns a filter forCalendarEvent
s. This filter restricts the events based on the from/to date pairs that exist on the reservation entity of this request. First, only calendar events that are linked to the reservation entity of this request are returned. Then the following applies: If facility dates are specified, the filter will skip all calendar events that are linked to rooms. If inventory dates are specified, the filter will skip all calendar events that are linked to appliances.- Throws:
PersistException
-
getFacilityDates
Returns the from/to fields for the facility, if the model contains those fields. If thereservation-facility
module is not present, those fields will not exists andOptional.empty()
is returned. If no dates exists (i.e. thefrom
date isnull
), thenOptional.empty()
is returned, too.- Throws:
PersistException
-
getInventoryDates
Returns the from/to fields for the inventory, if the model contains those fields. If thereservation-appliance
module is not present, those fields will not exists andOptional.empty()
is returned. If no dates exists (i.e. thefrom
date isnull
), thenOptional.empty()
is returned, too.- Throws:
PersistException
-
getReservationDates
Returns the from/to fields of theReservation
entity. If thefrom
field is not defined,Optional.empty()
is returned.- Throws:
PersistException
-
getDates
Returns the most specific from/to dates for this request:-
If a
assignedTarget
relation is defined, those specific dates are returned, or the standard from/to dates of the reservation as a fallback. -
If no
assignedTarget
is defined, the reservation dates are returned if available, and those of facility and/or inventory serve as fallback. If the reservation from/to fields are mandatory in the form (which should be true by now) this case does not occur.
Optional.empty()
this means, that there are no dates at all to return. IfassignedTarget
is defined, and its relation field is neitherrelRoom
norrelAppliance
, the standard reservation dates are returned.- Throws:
PersistException
-
If a
-