Search in sources :

Example 6 with RecurPeriods

use of org.bedework.icalendar.RecurUtil.RecurPeriods in project bw-calendar-engine by Bedework.

the class Events method getInstances.

@Override
public InstancesResponse getInstances(final GetInstancesRequest req) {
    final InstancesResponse resp = new InstancesResponse();
    resp.setId(req.getId());
    if (!req.validate(resp)) {
        return resp;
    }
    // Use a BwEvent to build the instance set
    final BwEvent ev = new BwEventObj();
    try {
        final BwDateTime st = req.getStartDt();
        ev.setDtstart(st);
        ev.setDtend(req.getEndDt());
        ev.addRrule(req.getRrule());
        if (!Util.isEmpty(req.getExdates())) {
            for (final String dt : req.getExdates()) {
                ev.addExdate(BwDateTime.makeBwDateTime(st.getDateType(), dt, st.getTzid()));
            }
        }
        if (!Util.isEmpty(req.getRdates())) {
            for (final String dt : req.getRdates()) {
                ev.addRdate(BwDateTime.makeBwDateTime(st.getDateType(), dt, st.getTzid()));
            }
        }
        final RecurPeriods rp = RecurUtil.getPeriods(ev, getAuthpars().getMaxYears(), getAuthpars().getMaxInstances(), req.getBegin(), req.getEnd());
        resp.setInstances(rp.instances);
        return resp;
    } catch (final Throwable t) {
        return Response.error(resp, t);
    }
}
Also used : BwDateTime(org.bedework.calfacade.BwDateTime) BwEvent(org.bedework.calfacade.BwEvent) InstancesResponse(org.bedework.calfacade.responses.InstancesResponse) RecurPeriods(org.bedework.icalendar.RecurUtil.RecurPeriods) BwEventObj(org.bedework.calfacade.BwEventObj)

Aggregations

BwDateTime (org.bedework.calfacade.BwDateTime)6 BwEvent (org.bedework.calfacade.BwEvent)6 RecurPeriods (org.bedework.icalendar.RecurUtil.RecurPeriods)6 Period (net.fortuna.ical4j.model.Period)5 HashMap (java.util.HashMap)3 BwRecurrenceInstance (org.bedework.calfacade.BwRecurrenceInstance)3 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)2 EventInfo (org.bedework.calfacade.svc.EventInfo)2 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1 DateTime (net.fortuna.ical4j.model.DateTime)1 TimeZone (net.fortuna.ical4j.model.TimeZone)1 CurrentAccess (org.bedework.access.Acl.CurrentAccess)1 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)1 BwCalendar (org.bedework.calfacade.BwCalendar)1 CollectionInfo (org.bedework.calfacade.BwCalendar.CollectionInfo)1 BwEventObj (org.bedework.calfacade.BwEventObj)1 BwEventProxy (org.bedework.calfacade.BwEventProxy)1 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)1 InstancesResponse (org.bedework.calfacade.responses.InstancesResponse)1