| |
The event
list expander Dataport
|
 |
|
 |
|
|
|
Calendaring
needs the notion of recurring events, where
recurrences can be daily, weekly and so forth. When
creating an event, the user specifies a start time and
a recurrence pattern (daily/weekly/whatever) for the
event, and subsequently expects to see the event shown
to her whenever an occurrence of that event falls in
the interval being displayed.
|
|
|
|
On the implementation side,
the database cannot possibly maintain one event record for
every occurrence of the event, because there could be an
unbounded number of occurrences. So it must maintain only
one record for the event. This means that we need a
way to determine, given a recurring event and a time
window, whether an occurrence of that event falls
within the window. More generally, given a time
window and a list of base events, we need to compute all
occurrences of all the base events that fall within the
window. The latter facility will, for example, enable us
to compute all occurrences of a user's events on a given
day or in a given week.
|
|
|
|
The event list expander
is a data port that fills this need. Given an event list
and a time window, it "expands" the list into a
list of occurrences within that window. This data port
behaves just like the database data port, with some
restrictions. It can only handle one table, and that is
the Event table whose structure is stipulated in the
database schema of the site. It performs its actions by simply
"forwarding" its invocation to the database data
port and then doing the necessary post-processing for
expanding the list of events that the database port
provides.
|
|
|
|
The
event list expander uses the RecurrencePattern
abstraction available within zeroCode -- the same one
used for controlling zeroCode's periodic services.
|
|
|
The
recurrence pattern
|
|
The recurrence pattern
maintains a start time and information about the
periodicity of the recurrence. The recurrence may be for
fixed times (e.g., every so many minutes), weekly (e.g.,
every Sunday and Wednesday), monthly or annual. A
monthly recurrence can be either fixed (e.g., the third
day of the month) or indexed (e.g., the second Sunday of
the month). Similarly, an annual recurrence can be
either fixed (e.g., the 15th of April) or indexed (e.g.,
the first Sunday of May). So the pattern's
representation in XML contains tags that correspond to
these quantities. Here are some examples that illustrate
all the possibilities.
|
<?xml
version="1.0"?>
<recurrence>
<startTime value="12:00am" />
<unit value="none"
amount="" />
</recurrence>
| Non-recurring pattern, indicated by
unit value being 'none'. |
<?xml
version="1.0"?>
<recurrence>
<startTime value="10:00am" />
<unit value="minutes"
amount="1440" />
</recurrence>
| A daily recurrence, as indicated by
the value being "minutes" (meaning that
the repetition interval is in minutes) and the
amount being 1440 (the number of minutes in a
day). |
<?xml
version="1.0"?>
<recurrence>
<startTime value="07:00pm" />
<unit value="weekly"
amount="2" />
<days value="2,4" />
</recurrence> |
A weekly recurrence (as determined
by unit="weekly") that happens every
other week (since amount="2", which is
the number of weeks between occurrences) on
Tuesday and Thursday (days 2 and 4 of the week) at
7:00 pm. |
<?xml version="1.0"?>
<recurrence>
<startTime value="12:00am" />
<unit value="monthly" amount="2" />
<monthlyFixed monthDay="4" />
</recurrence>
|
A monthly fixed recurrence,
occurring every other month (since
amount="2") on the fourth day of the
month. |
<?xml version="1.0"?>
<recurrence>
<startTime value="11:47am" />
<unit value="monthly" amount="1" />
<monthlyIndexed dayIndex="2" daySpec="4" />
</recurrence>
|
Monthly indexed recurrence occurring
every month, on the second Wednesday of the month.
Note that weekdays are counted from 1, so
Wednesday is day 4. |
<?xml
version="1.0"?>
<recurrence>
<startTime value="07:00am" />
<unit value="annual"
amount="1" />
<annualFixed monthFixed="3"
monthDayFixed="15" />
</recurrence> |
An annual fixed recurrence,
occurring at 7:00 am on the 15th day of
month number 3, i.e., April 15th
(months are counted from 0). The
amount="1" parameter indicates that the
recurrence happens every (one) year. |
|
|
|
|