List Info

Thread: InstanceList code




InstanceList code
user name
2006-01-25 22:31:48
Hi Cyrus,

I'm working on sorting out some reporting issues I'm having
with  
Cosmo. I found the following code in addMaster() in
InstanceList.java  
(line 100)


         // Always add first instance if included in range..
         if (start.before(rangeEnd) ) {
             Instance instance = new Instance(comp, start,
end);
             put(instance.getRid().toString(), instance);
         }


How come you only check that start is less than rangeEnd?
How come  
not all these checks as specified in the CalDAV spec:

          (DTSTART <= start AND DTEND > start) OR
          (DTSTART <= start AND DTSTART+DURATION >
start) OR
          (DTSTART >= start AND DTSTART < end) OR
          (DTEND   > start AND DTEND <= end)

Thanks!

Bobby



_______________________________________________
Cosmo mailing list
Cosmoosafoundation.org
http://lists.osafoundation.org/mailman/listinfo/cosmo
InstanceList code
user name
2006-01-25 23:29:16
Hi Bobby,

--On January 25, 2006 5:31:48 PM -0500 Bobby Rullo
<brosafoundation.org> 
wrote:

> I'm working on sorting out some reporting issues I'm
having with  Cosmo.
> I found the following code in addMaster() in
InstanceList.java  (line 100)
>
>
>          // Always add first instance if included in
range..
>          if (start.before(rangeEnd) ) {
>              Instance instance = new Instance(comp,
start, end);
>              put(instance.getRid().toString(),
instance);
>          }
>
>
> How come you only check that start is less than
rangeEnd? How come  not
> all these checks as specified in the CalDAV spec:

What this method does is expand the set of recurrences from
the very first 
one out to the supplied rangeEnd. So if the start is greater
than the end, 
then there will be no instances within the range and no need
to add the 
first one as determined by the 'start' value.

The overlap tests:

          (DTSTART <= start AND DTEND > start) OR
          (DTSTART <= start AND DTSTART+DURATION >
start) OR
          (DTSTART >= start AND DTSTART < end) OR
          (DTEND   > start AND DTEND <= end)

are not done exactly like that. What happens is that a set
of Instance 
objects is generated for each recurrence instance. The
Instance object has 
its own start/end associated with it, so all we need to do
is see whether 
those overlap the required range. That test is done
somewhere else.

-- 
Cyrus Daboo

_______________________________________________
Cosmo mailing list
Cosmoosafoundation.org
http://lists.osafoundation.org/mailman/listinfo/cosmo
InstanceList code
user name
2006-01-27 23:23:15
Cyrus Daboo wrote:
> What this method does is expand the set of recurrences
from the very 
> first one out to the supplied rangeEnd. So if the start
is greater 
> than the end, then there will be no instances within
the range and no 
> need to add the first one as determined by the 'start'
value.
>
[This is mostly for Bobby...]
We had a similar sort of epiphany in the chandler codebase -
There is a 
general pattern for determining if an event appears in a
given week, or 
month or whatever. As long as you can guarantee that for all
start/end 
values, start<end, then the only real important checks
when checking if 
an event occurs within a range is when the following is
true:

(eventStart <= rangeEnd && eventEnd >
rangeStart)

This covers all 4 cases of overlap between the event and the
range:
1) the event starts before the current range, but ends
within the range
2) the event starts before the range, and ends after the
range, thus 
does appear in the range.
3) the event starts in the range, but ends after the range
4) the event both starts and ends within the range

There are some subtle difference when dealing with
recurrence instances 
but I thought this was a useful enough tip/optimization
anyway...

Alec
> The overlap tests:
>
>          (DTSTART <= start AND DTEND > start) OR
>          (DTSTART <= start AND DTSTART+DURATION >
start) OR
>          (DTSTART >= start AND DTSTART < end) OR
>          (DTEND   > start AND DTEND <= end)
>
> are not done exactly like that. What happens is that a
set of Instance 
> objects is generated for each recurrence instance. The
Instance object 
> has its own start/end associated with it, so all we
need to do is see 
> whether those overlap the required range. That test is
done somewhere 
> else.
>

_______________________________________________
Cosmo mailing list
Cosmoosafoundation.org
http://lists.osafoundation.org/mailman/listinfo/cosmo
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )