public abstract class CalendarModel extends Object
CalendarModel is an abstract base class that represents a model for a Calendar component. The calendarModel returns CalendarActivity objects.
The Calendar model needs to generate separate CalendarActivity objects representing each recurring calendar activity.
CalendarActivity
Constructor and Description |
---|
CalendarModel() |
Modifier and Type | Method and Description |
---|---|
abstract CalendarActivity |
getActivity(String providerId, String activityId, Date rangeStart, Date rangeEnd, TimeZone timeZone)
Return CalendarActivity based on providerId and id within a range.
|
abstract List<CalendarActivity> |
getAllDayActivities(Date rangeStart, Date rangeEnd, TimeZone timeZone)
Returns activities that intersect the range.
|
List<CalendarActivity> |
getDurationActivities(Date rangeStart, Date rangeEnd, TimeZone tz)
Returns activities that intersect the range.
|
CalendarProvider |
getProvider(String id)
Find a provider, or activity owner, based on an id.
|
List<CalendarProvider> |
getProviders()
A CalendarProvider represents the provider, or owner, of activities.
|
abstract List<CalendarActivity> |
getTimeActivities(Date rangeStart, Date rangeEnd, TimeZone timeZone)
Returns activities that intersect the range.
|
static boolean |
isActivityInRange(CalendarActivity activity, TimeZone timeZone, Date rangeStart, Date rangeEnd)
Return true if the activity intersects the date range.
|
public abstract List<CalendarActivity> getTimeActivities(Date rangeStart, Date rangeEnd, TimeZone timeZone)
Returns activities that intersect the range. The start date is inclusive, meaning if the activity start date is an exact match to the range start date it is included in the returned list. The end date is exclusive, meaning if the activity start date is an exact match to the range end date it is not included in the returned list.
This method will generate a List of CalendarActivity objects where TimeType is TIME. The activities are returned in sorted order by start date.
If the start date is null, return all the activities before the end date (exclusive). If the end date is null, return all the activities after the start date (inclusive). If both are null, return all activities
Activities should be stable per request. Meaning between the time the model is asked for activities in a range, and the time the activities are rendered, the activity should not change. For example the start and end time should not change, the timeType should not change, etc.
rangeStart
- range start date (inclusive)rangeEnd
- range end date (exclusive)timeZone
- the timeZoneCalendarActivity
objectspublic abstract List<CalendarActivity> getAllDayActivities(Date rangeStart, Date rangeEnd, TimeZone timeZone)
Returns activities that intersect the range. The start date is inclusive, meaning if the activity start date is an exact match to the range start date it is included in the returned list. The end date is exclusive, meaning if the activity start date is an exact match to the range end date it is not included in the returned list.
This method will generate a List of CalendarActivity objects where TimeType is ALLDAY. The activities must be returned in sorted order by start date.
If the start date is null, return all the activities before the end date (exclusive). If the end date is null, return all the activities after the start date (inclusive). If both are null, return all activities
Activities should be stable per request. Meaning between the time the model is asked for activities in a range, and the time the activities are rendered, the activity should not change. For example the start and end time should not change, the timeType should not change, etc.
rangeStart
- range start date (inclusive)rangeEnd
- range end date (exclusive)timeZone
- the timeZoneCalendarActivity
objects.public List<CalendarActivity> getDurationActivities(Date rangeStart, Date rangeEnd, TimeZone tz)
rangeStart
- the start of the range to search in.rangeEnd
- the end of the range to search in.tz
- the timezone for the datespublic abstract CalendarActivity getActivity(String providerId, String activityId, Date rangeStart, Date rangeEnd, TimeZone timeZone)
providerId
- the id of the provideractivityId
- the id of the activityrangeStart
- the start of the range to search in. This is just a hint which the model may (or may not) be able to use to search efficiently, for example by looking at the expected range the model may know whether or not to search cached activities. If the activity exists it will be returned, regardless of whether it's in the range. A rangeStart of null is legal.rangeEnd
- the end of the range to search in. This is just a hint which the model may (or may not) be able to use to search efficiently, for example by looking at the expected range the model may know whether or not to search cached activities. If the activity exists it will be returned, regardless of whether it's in the range. A rangeEnd of null is legal.timeZone
- the timeZoneCalendarActivity
object or null if its not found.public CalendarProvider getProvider(String id)
id
- the id of the provider to returnpublic List<CalendarProvider> getProviders()
public static boolean isActivityInRange(CalendarActivity activity, TimeZone timeZone, Date rangeStart, Date rangeEnd)
The conditions in which an activity intersects the date range are as follows:
activity
-timeZone
-rangeStart
-rangeEnd
-NullPointerException
- if activity or timeZone is null
.