Interface CalendarManager
- All Known Implementing Classes:
CalendarManagerImpl
public interface CalendarManager
Service to work with
Calendar
s. 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 Summary
Modifier and TypeMethodDescriptionvoid
createCalendar
(String name, String entityModel, String relationName) Creates a new empty calendar object with the specified name, entity type and relation name.createCalendar
(String name, String entityModel, String relationName, org.joda.time.DateTimeZone timezone) Creates a new empty calendar object with the specified name.Creates a new builder forRecurrence
s.@Nullable Calendar
getCalendar
(EntityFilter calendarEntityFilter, EntityFilter calendarEventEntityFilter, @Nullable Context context) Finds one single calendar depending on the specified filters.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
(String entityModel, EntityFilter calendarEventEntityFilter, @Nullable Context context) Gets the default calendar for the specified entity type.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.getCalendars
(EntityFilter calendarEntityFilter, EntityFilter calendarEventEntityFilter, @Nullable Context context) Returns calendars depending on the specified calendarEntityFilter.getEndDate
(CalendarEvent event) Returns either the end date of the event, if not null.mapCalendarEntity
(Entity calendarEntity, EntityFilter calendarEventEntityFilter) Creates a calendar object from the specified calendar entity.mapCalendarEventEntity
(Entity calendarEventEntity, EntityFilter calendarEventEntityFilter) Creates a calendar event object from the specified "Calendar_event" entity.requireCalendar
(EntityFilter calendarEntityFilter, EntityFilter calendarEventEntityFilter, @Nullable Context context) Finds one single calendar depending on the specified filters.void
saveCalendar
(Calendar cal, @Nullable Context context) Saves the calendar to the database.Exports the specified calendar object into the ical format.toICal
(String name, @Nullable String description, Iterable<CalendarEvent> events) Exports the set of calendar events to the iCal format.
-
Method Details
-
addCalendarManagerListener
-
createCalendar
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 calendarentityModel
- the target entity type for the linked entities from calendar eventsrelationName
- 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 calendarentityModel
- entityType the target entity type for the linked entities from calendar eventsrelationName
- relationName the name of the relation to the target entitytimezone
- a time zone for the calendar
-
createRecurrenceRuleBuilder
Creates a new builder forRecurrence
s.- Parameters:
freq
- mandatory parameter for a recurrence
-
getEndDate
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
Returns the default calendar for the type of the specified entity containing only events that are linked to the specifie dentity. -
getCalendar
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 torelationName
- the name of the relation that yields in the target entitytarget
- the target of the relation
-
saveCalendar
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
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
Exports the specified calendar object into the ical format. -
toICal
Exports the set of calendar events to the iCal format.- Parameters:
name
- the name used as calendar namedescription
- an optional descriptionevents
- the set of events to export- Returns:
- the iCal formatted string
-