Interface ConflictManager
- All Known Implementing Classes:
ConflictManagerImpl
public interface ConflictManager
Managing conflicts between
CalendarEvent
s. To remove conflicts, remove their depending
events
, they will be removed automatically with them.-
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!
-
Method Details
-
loadConflict
Optional<Conflict> loadConflict(String id, @Nullable @Nullable Context context) throws PersistException - Throws:
PersistException
-
createConflict
-
getOfftimeCalendars
List<Calendar> getOfftimeCalendars(String entityModel, EntityFilter calendarEventEntityFilter, @Nullable @Nullable Context ctx) 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.- 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
EntityList findConflicts(List<PrimaryKey> targets, String relationName, Context context) throws PersistException 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.- Throws:
PersistException
-
findConflicts
EntityList findConflicts(List<PrimaryKey> targets, String relationName, Context context, String... existingRelations) throws PersistException 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 asfindConflicts(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")
- Throws:
PersistException
-
findConflictsForCalendarEvent
- Throws:
PersistException
-
findConflictsForCalendarEvent
EntityList findConflictsForCalendarEvent(UUID calendarEventId, Context context) throws PersistException - Throws:
PersistException
-
removeConflicts
This removes conflicts that are related to the specified calendar event, but without removing the calendar events itself!- Parameters:
calendarEvent
- the calendar event that is a source of conflicts
-
mapConflictEntity
Creates aConflict
object from the given entity. The entity must be of modelConflict
.- Throws:
PersistException
-