Interface ConflictManager

All Known Implementing Classes:
ConflictManagerImpl

public interface ConflictManager
Managing conflicts between CalendarEvents. To remove conflicts, remove their depending events, they will be removed automatically with them.
  • Method Details

    • loadConflict

      Optional<Conflict> loadConflict(String id, @Nullable @Nullable Context context) throws PersistException
      Throws:
      PersistException
    • createConflict

      Optional<Conflict> createConflict(CalendarEvent event1, CalendarEvent event2, ConflictType type)
    • 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 calendar
      calendarEventEntityFilter - when the calendar is loaded from db, this filter specifies what events are fetched with the calendar
      ctx - 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 CalendarEvents which are linked to the specified target entity using the specified relationName.

      The resulting conflict's CalendarEvents have its Calendar 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 to CalendarEvents which are in turn linked to the specified target entity with the given relationName, and where at least one of the given existingRelations exist -- resolved from either one of the CalendarEvents participating in the conflict.

      This is the same as findConflicts(java.util.List, String, ch.tocco.nice2.persist.core.api.Context) but additionally filters only those conflicts that have targets at the given existingRelations.

      Example:

      
         conflictManager.findConflicts(reservationEntity, "relReservation", "relReservation_registration")
       
      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.
      Throws:
      PersistException
    • findConflictsForCalendarEvent

      EntityList findConflictsForCalendarEvent(Entity calendarEventEnttiy) throws PersistException
      Throws:
      PersistException
    • findConflictsForCalendarEvent

      EntityList findConflictsForCalendarEvent(UUID calendarEventId, Context context) throws PersistException
      Throws:
      PersistException
    • removeConflicts

      void removeConflicts(Entity calendarEvent)
      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

      Conflict mapConflictEntity(Entity conflictEntity) throws PersistException
      Creates a Conflict object from the given entity. The entity must be of model Conflict.
      Throws:
      PersistException