Class ConflictManagerImpl
java.lang.Object
ch.tocco.nice2.optional.conflict.impl.ConflictManagerImpl
- All Implemented Interfaces:
ConflictManager
-
Constructor Summary
ConstructorDescriptionConflictManagerImpl
(CalendarManager calendarManager, ConflictDao conflictDao, QueryBuilderFactory queryBuilderFactory, NiceDataModel niceDataModel) -
Method Summary
Modifier and TypeMethodDescriptioncreateConflict
(CalendarEvent event1, CalendarEvent event2, ConflictType type) findConflicts
(List<PrimaryKey> targets, String relationName, Context context) Returns all conflicts from the database that are linked toCalendarEvent
s which are linked to the specified target entity using the specified relationName.findConflicts
(List<PrimaryKey> targets, String relationName, Context context, String... existingRelations) Returns all conflicts that are linked toCalendarEvent
s which are in turn linked to the specifiedtarget
entity with the givenrelationName
, and where at least one of the givenexistingRelations
exist -- resolved from either one of theCalendarEvent
s participating in the conflict.findConflictsForCalendarEvent
(Entity calendarEventEnttiy) findConflictsForCalendarEvent
(UUID calendarEventId, Context context) getOfftimeCalendars
(String entityModel, EntityFilter calendarEventEntityFilter, @Nullable Context ctx) Gets the offtime calendars for the specified entity model.loadConflict
(String id, @Nullable Context context) mapConflictEntity
(Entity conflictEntity) Creates aConflict
object from the given entity.void
removeConflicts
(Entity calendarEvent) This removes conflicts that are related to the specified calendar event, but without removing the calendar events itself!void
setConflictSetting
(String list)
-
Constructor Details
-
ConflictManagerImpl
public ConflictManagerImpl(CalendarManager calendarManager, ConflictDao conflictDao, QueryBuilderFactory queryBuilderFactory, NiceDataModel niceDataModel)
-
-
Method Details
-
setConflictSetting
-
loadConflict
public Optional<Conflict> loadConflict(String id, @Nullable @Nullable Context context) throws PersistException - Specified by:
loadConflict
in interfaceConflictManager
- Throws:
PersistException
-
createConflict
public Optional<Conflict> createConflict(CalendarEvent event1, CalendarEvent event2, ConflictType type) - Specified by:
createConflict
in interfaceConflictManager
-
getOfftimeCalendars
public List<Calendar> getOfftimeCalendars(String entityModel, EntityFilter calendarEventEntityFilter, @Nullable @Nullable Context ctx) Description copied from interface:ConflictManager
Gets the offtime calendars for the specified entity model. The relation name for the offtime calendar will be the same as in the main calendar of the entity model.- Specified by:
getOfftimeCalendars
in interfaceConflictManager
- Parameters:
entityModel
- the entity model for the offtime calendarcalendarEventEntityFilter
- when the calendar is loaded from db, this filter specifies what events are fetched with the calendarctx
- an optional context to use- Returns:
- the list of offtime calendars
-
findConflicts
public EntityList findConflicts(List<PrimaryKey> targets, String relationName, Context context) throws PersistException Description copied from interface:ConflictManager
Returns all conflicts from the database that are linked to
CalendarEvent
s which are linked to the specified target entity using the specified relationName.The resulting conflict's
CalendarEvent
s have itsCalendar
attached but without any events.- Specified by:
findConflicts
in interfaceConflictManager
- Throws:
PersistException
-
findConflicts
public EntityList findConflicts(List<PrimaryKey> targets, String relationName, Context context, String... existingRelations) throws PersistException Description copied from interface:ConflictManager
Returns all conflicts that are linked toCalendarEvent
s which are in turn linked to the specifiedtarget
entity with the givenrelationName
, and where at least one of the givenexistingRelations
exist -- resolved from either one of theCalendarEvent
s participating in the conflict. This is the same asConflictManager.findConflicts(java.util.List, String, ch.tocco.nice2.persist.core.api.Context)
but additionally filters only those conflicts that have targets at the givenexistingRelations
. Example:
Finds all conflicts to the given reservation entity where the calendar events have an existing relation "relReservation_registration". In other words, it finds all registration conflicts for the given reservation.conflictManager.findConflicts(reservationEntity, "relReservation", "relReservation_registration")
- Specified by:
findConflicts
in interfaceConflictManager
- Throws:
PersistException
-
findConflictsForCalendarEvent
public EntityList findConflictsForCalendarEvent(UUID calendarEventId, Context context) throws PersistException - Specified by:
findConflictsForCalendarEvent
in interfaceConflictManager
- Throws:
PersistException
-
findConflictsForCalendarEvent
- Specified by:
findConflictsForCalendarEvent
in interfaceConflictManager
- Throws:
PersistException
-
removeConflicts
Description copied from interface:ConflictManager
This removes conflicts that are related to the specified calendar event, but without removing the calendar events itself!- Specified by:
removeConflicts
in interfaceConflictManager
- Parameters:
calendarEvent
- the calendar event that is a source of conflicts
-
mapConflictEntity
Description copied from interface:ConflictManager
Creates aConflict
object from the given entity. The entity must be of modelConflict
.- Specified by:
mapConflictEntity
in interfaceConflictManager
- Throws:
PersistException
-