Class CalendarManagerImpl

java.lang.Object
ch.tocco.nice2.optional.calendar.impl.ical.CalendarManagerImpl
All Implemented Interfaces:
CalendarManager

@Component public class CalendarManagerImpl extends Object implements CalendarManager
  • Constructor Details

  • Method Details

    • addCalendarManagerListener

      public void addCalendarManagerListener(CalendarManagerListener listener)
      Specified by:
      addCalendarManagerListener in interface CalendarManager
    • getCalendars

      public List<Calendar> getCalendars(EntityFilter calendarFilter, EntityFilter calendarEventEntityFilter, @Nullable @Nullable Context ctx)
      Description copied from interface: CalendarManager
      Returns calendars depending on the specified calendarEntityFilter. Also a calendarEventEntityFilter may be specified to narrow the list of calendar events of each calendar.
      Specified by:
      getCalendars in interface CalendarManager
    • getCalendar

      @Nullable public @Nullable Calendar getCalendar(EntityFilter calendarEntityFilter, EntityFilter calendarEventEntityFilter, @Nullable @Nullable Context ctx)
      Description copied from interface: CalendarManager
      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.
      Specified by:
      getCalendar in interface CalendarManager
    • requireCalendar

      public Calendar requireCalendar(EntityFilter calendarEntityFilter, EntityFilter calendarEventEntityFilter, @Nullable @Nullable Context ctx)
      Description copied from interface: CalendarManager
      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.
      Specified by:
      requireCalendar in interface CalendarManager
    • getCalendar

      public Calendar getCalendar(String entityModel, EntityFilter calendarEventEntityFilter, @Nullable @Nullable Context ctx)
      Description copied from interface: CalendarManager
      Gets the default calendar for the specified entity type.
      Specified by:
      getCalendar in interface CalendarManager
    • getCalendar

      public Calendar getCalendar(Entity target)
      Description copied from interface: CalendarManager
      Returns the default calendar for the type of the specified entity containing only events that are linked to the specifie dentity.
      Specified by:
      getCalendar in interface CalendarManager
    • getCalendar

      public Calendar getCalendar(String entityModel, String relationName, Entity target)
      Description copied from interface: CalendarManager
      Returns the calendar for the specified entity model containing only events that are linked to the specified target entity with the specified relation name.
      Specified by:
      getCalendar in interface CalendarManager
      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
    • createCalendar

      public Calendar createCalendar(String name, String entityModel, String relationName)
      Description copied from interface: CalendarManager

      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.

      Specified by:
      createCalendar in interface CalendarManager
      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

      public Calendar createCalendar(String name, String entityModel, String relationName, org.joda.time.DateTimeZone timezone)
      Description copied from interface: CalendarManager
      Creates a new empty calendar object with the specified name.
      Specified by:
      createCalendar in interface CalendarManager
      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
    • mapCalendarEntity

      public Calendar mapCalendarEntity(Entity calendarEntity, EntityFilter calendarEventEntityFilter)
      Description copied from interface: CalendarManager
      Creates a calendar object from the specified calendar entity. The calendarEventEntityFilter can be specified to control what calendar events to include.
      Specified by:
      mapCalendarEntity in interface CalendarManager
    • mapCalendarEventEntity

      public CalendarEvent mapCalendarEventEntity(Entity calendarEventEntity, EntityFilter calendarEventEntityFilter)
      Description copied from interface: CalendarManager
      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.
      Specified by:
      mapCalendarEventEntity in interface CalendarManager
    • saveCalendar

      public void saveCalendar(Calendar cal, @Nullable @Nullable Context ctx)
      Description copied from interface: CalendarManager
      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.
      Specified by:
      saveCalendar in interface CalendarManager
    • toICal

      public String toICal(Calendar calendar)
      Description copied from interface: CalendarManager
      Exports the specified calendar object into the ical format.
      Specified by:
      toICal in interface CalendarManager
    • toICal

      public String toICal(String name, @Nullable @Nullable String description, Iterable<CalendarEvent> events)
      Description copied from interface: CalendarManager
      Exports the set of calendar events to the iCal format.
      Specified by:
      toICal in interface CalendarManager
      Parameters:
      name - the name used as calendar name
      description - an optional description
      events - the set of events to export
      Returns:
      the iCal formatted string
    • createRecurrenceRuleBuilder

      public RecurrenceBuilder createRecurrenceRuleBuilder(Frequency freq)
      Description copied from interface: CalendarManager
      Creates a new builder for Recurrences.
      Specified by:
      createRecurrenceRuleBuilder in interface CalendarManager
      Parameters:
      freq - mandatory parameter for a recurrence
    • getEndDate

      public DateTimeValue getEndDate(CalendarEvent event)
      Description copied from interface: CalendarManager
      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.
      Specified by:
      getEndDate in interface CalendarManager