Hi Mike,
We have done this on several occasions. Here is our model for an
event that can be recurring :
Event
-------
the basic event data
>frequency
Frequency
-------
dayOfMonth // the day of the month that the event must occur on
daysFromMonthEnd // the number of days from the month end the event
occurs on
daysFromMonthStart // the number of days from the month start the
event occurs on
daysOfWeek // a bit string representing the days of the week this
occurs on (ie. 0101010 = Monday Wednesday Friday)
recurUntil // when to stop recurring
In Frequency.java, in awakeFromInsertion, we set the bit string to
all zeroes
here is more code :
/**
* The daysOfWeek attribute is stored as a binary string with 7 digits
* (one for every day of the week). The value for any day is 0 or 1.
* This method returns whether or not the frequency for a task occurs
* on a specific day of the week. (Sun = 0, Sat = 6)
*/
public boolean occursOnDayOfWeek(int iDayOfWeek) {
boolean aResult = false;
if (daysOfWeek() != null) {
try {
char aValue = daysOfWeek().charAt(iDayOfWeek-1);
if (aValue == '1')
aResult = true;
} catch (IndexOutOfBoundsException e) {
ISTDebug.println(0, "Exception getting days for task
"+e);
}
}
return aResult;
}
public void setOccursOnDayOfWeek(int iDayOfWeek, boolean iOccur) {
char[] aCharList = daysOfWeek().toCharArray();
try {
char aValue = aCharList[iDayOfWeek-1];
if (iOccur)
aValue = '1';
else
aValue = '0';
aCharList[iDayOfWeek-1] = aValue;
} catch (IndexOutOfBoundsException e) {
ISTDebug.println(0, "Exception getting days for task
"+e);
}
setDaysOfWeek(new String(aCharList));
}
/**
* Returns whether or not this frequency occurs on the specified day
in the specified month
* FIXME -- this method could be totally improved by using Calendar
methods instead of hard coding numbers.
*/
public boolean occursOnDayOfMonth(int iDay, int iMonth, int iYear) {
// dayOfMonth, daysFromMonthEnd
boolean aReturnVal = false;
int aDayOfMonth, aDayFromEnd = 0;
int daysInMonth = 31;
// Get the days in month
if (iMonth == 4 || iMonth == 6 || iMonth == 9 || iMonth == 11)
daysInMonth = 30;
if (iMonth == 2) {
java.util.GregorianCalendar aCalendar = new
java.util.GregorianCalendar();
if (aCalendar.isLeapYear(iYear))
daysInMonth = 29;
else
daysInMonth = 28;
}
// Check for dayOfMonth
if (dayOfMonth() != null) {
aDayOfMonth = dayOfMonth().intValue();
if (iDay == aDayOfMonth)
aReturnVal = true;
}
// Check for daysFromMonthEnd
if (daysFromMonthEnd() != null) {
aDayFromEnd = daysFromMonthEnd().intValue();
if (iDay == (daysInMonth - aDayFromEnd))
aReturnVal = true;
}
return aReturnVal;
}
On Feb 6, 2008, at 8:37 AM, Mike Schrag wrote:
I'm wondering if anyone has addressed modeling recurring calendar
events with EOF in a nice way? None of the options seem
particularly attractive to me at the moment, but I was hoping
someone might have some clever insight into the problem. I think
the proper impl is to make "ghost" events appear in the results
that don't become "real" EO's until someone touches them to make a
change from the original pattern, but this seems like sort of a
huge pain with EOF ... I don't know what the overhead will be of
constantly making and throwing away unsaved EOs on every view. I
was considering a non-EO cover object for an event that can turn
into an EO, but it means you have to "write it twice" to support
all the API of the EO version of the event.
Ack.
I've also considered an EOF adaptor on top of icalserver on
Leopard, but this has all sorts of its own undesirable complications.
Ideas welcome :)
ms
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/ddenboer%
40apple.com
This email sent to [EMAIL PROTECTED]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]