[Bedework-commit] calendarapi r247 - in trunk:
calCore/src/org/bedework/calcore/hibernate
calFacade/src/org/bedework/calfacade
calFacade/src/org/bedework/calfacade/base
calsvc/src/org/bedework/calsvc
svnadmin at bedework.org
svnadmin at bedework.org
Mon Apr 2 13:05:56 EDT 2007
Author: douglm
Date: 2007-04-02 13:05:56 -0400 (Mon, 02 Apr 2007)
New Revision: 247
Modified:
trunk/calCore/src/org/bedework/calcore/hibernate/Events.java
trunk/calFacade/src/org/bedework/calfacade/BwEvent.java
trunk/calFacade/src/org/bedework/calfacade/base/RecurrenceEntity.java
trunk/calsvc/src/org/bedework/calsvc/CalSvc.java
Log:
Fix bug in retrieving overrides to recurring instances.
Fixes to freebusy reporting.
Modified: trunk/calCore/src/org/bedework/calcore/hibernate/Events.java
===================================================================
--- trunk/calCore/src/org/bedework/calcore/hibernate/Events.java 2007-04-02 02:01:05 UTC (rev 246)
+++ trunk/calCore/src/org/bedework/calcore/hibernate/Events.java 2007-04-02 17:05:56 UTC (rev 247)
@@ -140,6 +140,7 @@
/* (non-Javadoc)
* @see org.bedework.calcorei.EventsI#getEvent(org.bedework.calfacade.BwCalendar, java.lang.String, java.lang.String, org.bedework.calfacade.RecurringRetrievalMode)
*/
+ @SuppressWarnings("unchecked")
public Collection<CoreEventInfo> getEvent(BwCalendar calendar,
String guid, String rid,
RecurringRetrievalMode recurRetrieval)
@@ -196,7 +197,7 @@
}
Collection<CoreEventInfo> ceis = postGetEvents(evs, privRead,
- returnResultAlways, false);
+ returnResultAlways);
if (ceis.isEmpty()) {
return ceis;
@@ -308,8 +309,7 @@
allCalendars, null, getEvents);
Collection<CoreEventInfo> ceis = postGetEvents(eqr.es, desiredAccess,
- returnResultAlways,
- freeBusy);
+ returnResultAlways);
/* Run the events we got through the filters
*/
@@ -320,7 +320,7 @@
ignoreCreator, eqr, allCalendars, null, getAnnotations);
ceis.addAll(eqr.flt.postExec(postGetEvents(eqr.es, desiredAccess,
- returnResultAlways, freeBusy)));
+ returnResultAlways)));
/* If there were any date limits we need to get any overrides or instances
* that fall in the range and add the unique masters to the Collection
@@ -351,8 +351,7 @@
}
for (BwEvent mstr: masters) {
- ceis.add(postGetEvent(mstr, desiredAccess,
- returnResultAlways, freeBusy));
+ ceis.add(postGetEvent(mstr, desiredAccess, returnResultAlways));
}
}
@@ -380,6 +379,10 @@
}
}
+ if (freeBusy) {
+ res = makeFreeBusy(res);
+ }
+
return res;
}
@@ -412,7 +415,7 @@
return null;
}
- CoreEventInfo cei = postGetEvent(ev, privRead, returnResultAlways, false);
+ CoreEventInfo cei = postGetEvent(ev, privRead, returnResultAlways);
if (cei.getEvent().getRecurring().booleanValue()) {
doRecurrence(cei, null, null, recurRetrieval);
@@ -436,7 +439,7 @@
Collection evs = sess.getList();
- return postGetEvents(evs, privRead, returnResultAlways, false);
+ return postGetEvents(evs, privRead, returnResultAlways);
}
public Collection<BwEventProxy> addEvent(BwEvent val,
@@ -1683,7 +1686,7 @@
sb.append(" and ");
}
- if ((getWhat != getInstances) &&
+ if ((getWhat == getEvents) &&
((startDate != null) || (endDate != null))) {
/* Don't retrieve any recurrences master records if we have a date range.
* We pick these up along with the instances that match the time range.
@@ -2295,18 +2298,17 @@
private Collection<CoreEventInfo> postGetEvents(Collection evs,
int desiredAccess,
- boolean nullForNoAccess,
- boolean freeBusy)
+ boolean nullForNoAccess)
throws CalFacadeException {
TreeSet<CoreEventInfo> outevs = new TreeSet<CoreEventInfo>();
Iterator it = evs.iterator();
while (it.hasNext()) {
- CoreEventInfo cei = postGetEvent((BwEvent)it.next(),
- desiredAccess, nullForNoAccess,
- freeBusy);
+ BwEvent ev = (BwEvent)it.next();
+ CoreEventInfo cei = postGetEvent(ev, desiredAccess, nullForNoAccess);
+
if (cei != null) {
outevs.add(cei);
}
@@ -2318,8 +2320,7 @@
/* Post processing of event. Return null or throw exception for no access
*/
private CoreEventInfo postGetEvent(BwEvent ev, int desiredAccess,
- boolean nullForNoAccess,
- boolean freeBusy) throws CalFacadeException {
+ boolean nullForNoAccess) throws CalFacadeException {
if (ev == null) {
return null;
}
@@ -2340,17 +2341,30 @@
ev = new BwEventProxy((BwEventAnnotation)ev);
}
- if (freeBusy) {
+ CoreEventInfo cei = new CoreEventInfo(ev, ca);
+
+ return cei;
+ }
+
+ private Collection<CoreEventInfo> makeFreeBusy(Collection<CoreEventInfo> ceis)
+ throws CalFacadeException {
+ TreeSet<CoreEventInfo> outevs = new TreeSet<CoreEventInfo>();
+
+ for (CoreEventInfo cei: ceis) {
+ BwEvent ev = cei.getEvent();
if (BwEvent.transparencyTransparent.equals(ev.getTransparency())) {
- return null;
+ continue;
}
- ev = ev.makeFreeBusyEvent();
+ if (debug) {
+ debugMsg(ev.toString());
+ }
+
+ cei.setEvent(ev.makeFreeBusyEvent());
+ outevs.add(cei);
}
- CoreEventInfo cei = new CoreEventInfo(ev, ca);
-
- return cei;
+ return outevs;
}
private class RecuridTable extends HashMap<String, BwEventProxy> {
Modified: trunk/calFacade/src/org/bedework/calfacade/BwEvent.java
===================================================================
--- trunk/calFacade/src/org/bedework/calfacade/BwEvent.java 2007-04-02 02:01:05 UTC (rev 246)
+++ trunk/calFacade/src/org/bedework/calfacade/BwEvent.java 2007-04-02 17:05:56 UTC (rev 247)
@@ -319,6 +319,9 @@
/** Rfc value for a tentative meeting */
public static final String statusTentative = "TENTATIVE";
+ /** Rfc value for an unavailable time-period */
+ public static final String statusUnavailable = "BUSY-UNAVAILABLE";
+
private String status;
private String cost;
Modified: trunk/calFacade/src/org/bedework/calfacade/base/RecurrenceEntity.java
===================================================================
--- trunk/calFacade/src/org/bedework/calfacade/base/RecurrenceEntity.java 2007-04-02 02:01:05 UTC (rev 246)
+++ trunk/calFacade/src/org/bedework/calfacade/base/RecurrenceEntity.java 2007-04-02 17:05:56 UTC (rev 247)
@@ -42,7 +42,7 @@
public void setRecurring(Boolean val);
/**
- * @return Boolean true if a recurring event
+ * @return Boolean true if a recurring event - only relevant for master event.
*/
public Boolean getRecurring();
Modified: trunk/calsvc/src/org/bedework/calsvc/CalSvc.java
===================================================================
--- trunk/calsvc/src/org/bedework/calsvc/CalSvc.java 2007-04-02 02:01:05 UTC (rev 246)
+++ trunk/calsvc/src/org/bedework/calsvc/CalSvc.java 2007-04-02 17:05:56 UTC (rev 247)
@@ -91,6 +91,7 @@
import org.bedework.calfacade.exc.CalFacadeAccessException;
import org.bedework.calfacade.exc.CalFacadeDupNameException;
import org.bedework.calfacade.exc.CalFacadeException;
+import org.bedework.calfacade.filter.BwEntityTypeFilter;
import org.bedework.calfacade.filter.BwFilter;
import org.bedework.calfacade.ifs.Directories;
import org.bedework.calfacade.svc.BwAdminGroup;
@@ -1468,7 +1469,10 @@
BwFreeBusy fb = new BwFreeBusy(who, start, end);
Collection<EventInfo> events = new TreeSet<EventInfo>();
+ /* Only events for freebusy reports. */
+ BwFilter filter = BwEntityTypeFilter.eventFilter(null, false);
+
for (BwSubscription sub: subs) {
if (!sub.getAffectsFreeBusy()) {
continue;
@@ -1479,7 +1483,7 @@
RecurringRetrievalMode rrm = new RecurringRetrievalMode(
Rmode.expanded, start, end);
- Collection<EventInfo> evs = getEvents(sub, null, start, end, rrm, true);
+ Collection<EventInfo> evs = getEvents(sub, filter, start, end, rrm, true);
// Filter out transparent events
for (EventInfo ei : evs) {
@@ -1574,8 +1578,11 @@
return fb;
}
+ /* No granularity specified - more rfc like */
Collection<EventPeriod> eventPeriods = new TreeSet<EventPeriod>();
+ CalTimezones ctz = getTimezones();
+
for (EventInfo ei: events) {
BwEvent ev = ei.getEvent();
@@ -1596,6 +1603,11 @@
String dend;
String endtzid;
+ if ((estart.after(end)) || (eend.before(start))) {
+ //XXX Should get here - but apparently we do.
+ continue;
+ }
+
if (estart.before(start)) {
dstart = start.getDtval();
sttzid = start.getTzid();
@@ -1612,8 +1624,6 @@
endtzid = eend.getTzid();
}
- CalTimezones ctz = getTimezones();
-
dstart = ctz.getUtc(dstart, sttzid, null, ev.getOwner());
dend = ctz.getUtc(dend, endtzid, null, ev.getOwner());
@@ -1627,7 +1637,9 @@
if (BwEvent.statusTentative.equals(ev.getStatus())) {
type = BwFreeBusyComponent.typeBusyTentative;
- }
+ } else if (BwEvent.statusUnavailable.equals(ev.getStatus())) {
+ type = BwFreeBusyComponent.typeBusyUnavailable;
+ }
eventPeriods.add(new EventPeriod(psdt, pedt, type));
}
More information about the Bedework-commit
mailing list