use of org.bedework.calcore.hibernate.EventQueryBuilder.EventsQueryResult in project bw-calendar-engine by Bedework.
the class CoreEvents method getEvent.
@Override
public Collection<CoreEventInfo> getEvent(final String colPath, final String uid) throws CalFacadeException {
final TreeSet<CoreEventInfo> ts = new TreeSet<>();
final int desiredAccess = privRead;
/*
if (colPath != null) {
BwCalendar cal = getEntityCollection(colPath, privRead, scheduling, false);
desiredAccess = ((CalendarWrapper)cal).getLastDesiredAccess();
}
*/
/* This works as follows:
*
* First try to retrieve the master event from the events table.
*
* If not there try the annotations table. If it's there, it's a reference
* to an event owned by somebody else. Otherwise we drew a blank.
*
* If no recurrence id was specified process any recurrence information for
* each event retrieved and return.
*
* Note that the event we retrieved might be a reference to a recurring
* instance. In that case it will inherit the recurrence id. We should check
* for this case and assume we were being asked for that event.
*
* If a recurrence id was specified then, for each master event retrieved,
* we need to retrieve the instance and build a proxy using any appropriate
* overrides.
*/
// First look in the events table for the master(s).
Collection evs = dao.eventQuery(BwEventObj.class, colPath, uid, null, null, // overrides
null, // recurRetrieval);
null);
if (Util.isEmpty(evs)) {
/* Look for an annotation to that event by the current user.
*/
evs = dao.eventQuery(BwEventAnnotation.class, colPath, uid, /*null*/
null, null, // overrides
false, // recurRetrieval);
null);
}
if (Util.isEmpty(evs)) {
return ts;
}
final Collection<CoreEventInfo> ceis = postGetEvents(evs, desiredAccess, returnResultAlways, null);
if (ceis.isEmpty()) {
return ceis;
}
/* If the recurrence id is null, do recurrences for each retrieved event,
* otherwise just retrieve the instance.
*/
final EventsQueryResult eqr = new EventsQueryResult();
eqr.flt = new Filters(cb, null);
eqr.addColPath(colPath);
for (final CoreEventInfo cei : ceis) {
final BwEvent master = cei.getEvent();
if (master.getEntityType() == IcalDefs.entityTypeVavailability) {
for (final String auid : master.getAvailableUids()) {
final Collection<CoreEventInfo> aceis = getEvent(colPath, auid);
if (aceis.size() != 1) {
throwException(CalFacadeException.badResponse);
}
cei.addContainedItem(aceis.iterator().next());
}
ts.add(cei);
} else if (!master.testRecurring()) {
ts.add(cei);
} else {
doRecurrence(cei, null);
ts.add(cei);
}
}
return ts;
}
Aggregations