Class CalendarManagerImpl
java.lang.Object
ch.tocco.nice2.optional.calendar.impl.ical.CalendarManagerImpl
- All Implemented Interfaces:
CalendarManager
-
Constructor Summary
ConstructorDescriptionCalendarManagerImpl
(CalendarDao dao, CalendarManagerListenerService listenerService) -
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 ctx) 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 ctx) 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 calendarFilter, EntityFilter calendarEventEntityFilter, @Nullable Context ctx) 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 ctx) Finds one single calendar depending on the specified filters.void
saveCalendar
(Calendar cal, @Nullable Context ctx) 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.
-
Constructor Details
-
CalendarManagerImpl
-
-
Method Details
-
addCalendarManagerListener
- Specified by:
addCalendarManagerListener
in interfaceCalendarManager
-
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 interfaceCalendarManager
-
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 interfaceCalendarManager
-
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 interfaceCalendarManager
-
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 interfaceCalendarManager
-
getCalendar
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 interfaceCalendarManager
-
getCalendar
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 interfaceCalendarManager
- 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
-
createCalendar
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 interfaceCalendarManager
- 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
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 interfaceCalendarManager
- 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
-
mapCalendarEntity
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 interfaceCalendarManager
-
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 interfaceCalendarManager
-
saveCalendar
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 interfaceCalendarManager
-
toICal
Description copied from interface:CalendarManager
Exports the specified calendar object into the ical format.- Specified by:
toICal
in interfaceCalendarManager
-
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 interfaceCalendarManager
- Parameters:
name
- the name used as calendar namedescription
- an optional descriptionevents
- the set of events to export- Returns:
- the iCal formatted string
-
createRecurrenceRuleBuilder
Description copied from interface:CalendarManager
Creates a new builder forRecurrence
s.- Specified by:
createRecurrenceRuleBuilder
in interfaceCalendarManager
- Parameters:
freq
- mandatory parameter for a recurrence
-
getEndDate
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 interfaceCalendarManager
-