Interface CalendarManager

All Known Implementing Classes:
CalendarManagerImpl

public interface CalendarManager
Service to work with Calendars. Any method that receives an optional Context argument, this is used when loading or storing entities. If it is null, the context of the current thread is used. For example, when using this service from within a listener, always pass the context of the source entity into the methods.
  • Method Details

    • addCalendarManagerListener

      void addCalendarManagerListener(CalendarManagerListener listener)
    • createCalendar

      Calendar createCalendar(String name, String entityModel, String relationName)

      Creates a new empty calendar object with the specified name, entity type and relation name.

      The entity type and relation name specifies the relation type of each calendar event in this calendar. The relation name is the name of the relation from the calendar event (source entity) to a target entity specified by entityType.

      The calendar is created with UTC time zone.

      Parameters:
      name - the name of the calendar
      entityModel - the target entity type for the linked entities from calendar events
      relationName - the name of the relation to the target entity
    • createCalendar

      Calendar createCalendar(String name, String entityModel, String relationName, org.joda.time.DateTimeZone timezone)
      Creates a new empty calendar object with the specified name.
      Parameters:
      name - name the name of the calendar
      entityModel - entityType the target entity type for the linked entities from calendar events
      relationName - relationName the name of the relation to the target entity
      timezone - a time zone for the calendar
    • createRecurrenceRuleBuilder

      RecurrenceBuilder createRecurrenceRuleBuilder(Frequency freq)
      Creates a new builder for Recurrences.
      Parameters:
      freq - mandatory parameter for a recurrence
    • getEndDate

      DateTimeValue getEndDate(CalendarEvent event)
      Returns either the end date of the event, if not null. otherwise it checks whether it is an allday event, and returns the datetime of the end of the day. If its not and the end date is null, the start date is returned.
    • getCalendars

      List<Calendar> getCalendars(EntityFilter calendarEntityFilter, EntityFilter calendarEventEntityFilter, @Nullable @Nullable Context context)
      Returns calendars depending on the specified calendarEntityFilter. Also a calendarEventEntityFilter may be specified to narrow the list of calendar events of each calendar.
    • getCalendar

      @Nullable @Nullable Calendar getCalendar(EntityFilter calendarEntityFilter, EntityFilter calendarEventEntityFilter, @Nullable @Nullable Context context)
      Finds one single calendar depending on the specified filters. It expects the calendarEntityFilter to create query for one or no result; throwing an exception if more than one result is returned. Returns null if nothing is found.
    • requireCalendar

      Calendar requireCalendar(EntityFilter calendarEntityFilter, EntityFilter calendarEventEntityFilter, @Nullable @Nullable Context context)
      Finds one single calendar depending on the specified filters. It expects the calendarEntityFilter to create query for exaclty one result; throwing an exception if more than one result is returned or nothing is found.
    • getCalendar

      Calendar getCalendar(String entityModel, EntityFilter calendarEventEntityFilter, @Nullable @Nullable Context context)
      Gets the default calendar for the specified entity type.
    • getCalendar

      Calendar getCalendar(Entity target)
      Returns the default calendar for the type of the specified entity containing only events that are linked to the specifie dentity.
    • getCalendar

      Calendar getCalendar(String entityModel, String relationName, Entity target)
      Returns the calendar for the specified entity model containing only events that are linked to the specified target entity with the specified relation name.
      Parameters:
      entityModel - the entity model the calendar is associated to
      relationName - the name of the relation that yields in the target entity
      target - the target of the relation
    • saveCalendar

      void saveCalendar(Calendar cal, @Nullable @Nullable Context context)
      Saves the calendar to the database. If it already exists, all new events are saved, but no event is deleted, so the event lists are not fully synchronized.
    • mapCalendarEntity

      Calendar mapCalendarEntity(Entity calendarEntity, EntityFilter calendarEventEntityFilter)
      Creates a calendar object from the specified calendar entity. The calendarEventEntityFilter can be specified to control what calendar events to include.
    • mapCalendarEventEntity

      CalendarEvent mapCalendarEventEntity(Entity calendarEventEntity, EntityFilter calendarEventEntityFilter)
      Creates a calendar event object from the specified "Calendar_event" entity. The returned calendar event object is attached to its calendar, which is also loaded from the database. The calendarEventEntityFilter is used to obtain the list of events (additional to the returned) of the calendar.
    • toICal

      String toICal(Calendar calendar)
      Exports the specified calendar object into the ical format.
    • toICal

      String toICal(String name, @Nullable @Nullable String description, Iterable<CalendarEvent> events)
      Exports the set of calendar events to the iCal format.
      Parameters:
      name - the name used as calendar name
      description - an optional description
      events - the set of events to export
      Returns:
      the iCal formatted string