Search in sources :

Example 1 with RecurType

use of ietf.params.xml.ns.icalendar_2.RecurType in project bw-calendar-engine by Bedework.

the class ToXEvent method doRecurring.

/**
 * Build recurring properties from event.
 *
 * @param pattern
 * @param compCl - component class for pattern matching
 * @param val
 * @param pl
 * @throws CalFacadeException
 */
public static void doRecurring(final BaseComponentType pattern, final Class compCl, final BwEvent val, final List<JAXBElement<? extends BasePropertyType>> pl) throws CalFacadeException {
    try {
        if (emit(pattern, compCl, RrulePropType.class) && val.hasRrules()) {
            for (String s : val.getRrules()) {
                RRule rule = new RRule();
                rule.setValue(s);
                Recur r = rule.getRecur();
                RecurType rt = new RecurType();
                rt.setFreq(FreqRecurType.fromValue(r.getFrequency()));
                if (r.getCount() > 0) {
                    rt.setCount(BigInteger.valueOf(r.getCount()));
                }
                Date until = r.getUntil();
                if (until != null) {
                    UntilRecurType u = new UntilRecurType();
                    /*
            if (until instanceof DateTime) {
              u.setDateTime(until.toString());
            } else {
              u.setDate(until.toString());
            }
            */
                    XcalUtil.initUntilRecur(u, until.toString());
                }
                if (r.getInterval() > 0) {
                    rt.setInterval(String.valueOf(r.getInterval()));
                }
                listFromNumberList(rt.getBysecond(), r.getSecondList());
                listFromNumberList(rt.getByminute(), r.getMinuteList());
                listFromNumberList(rt.getByhour(), r.getHourList());
                if (r.getDayList() != null) {
                    List<String> l = rt.getByday();
                    for (WeekDay wd : r.getDayList()) {
                        l.add(wd.getDay().name());
                    }
                }
                listFromNumberList(rt.getByyearday(), r.getYearDayList());
                intlistFromNumberList(rt.getBymonthday(), r.getMonthDayList());
                listFromNumberList(rt.getByweekno(), r.getWeekNoList());
                intlistFromNumberList(rt.getBymonth(), r.getMonthList());
                bigintlistFromNumberList(rt.getBysetpos(), r.getSetPosList());
                RrulePropType rrp = new RrulePropType();
                rrp.setRecur(rt);
                pl.add(of.createRrule(rrp));
            }
        }
    /*
      if (emit(pattern, compCl, ExrulePropType.class) &&
          val.hasExrules()) {
        for(String s: val.getExrules()) {
          ExRule rule = new ExRule();
          rule.setValue(s);

          pl.add(rule);
        }
      }

      if (emit(pattern, compCl, RdatePropType.class) {
        makeDlp(false, val.getRdates(), pl);
      }

      if (emit(pattern, compCl, ExdatePropType.class) {
        makeDlp(true, val.getExdates(), pl);
      }
      */
    // } catch (CalFacadeException cfe) {
    // throw cfe;
    } catch (Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : UntilRecurType(ietf.params.xml.ns.icalendar_2.UntilRecurType) WeekDay(net.fortuna.ical4j.model.WeekDay) RRule(net.fortuna.ical4j.model.property.RRule) FreqRecurType(ietf.params.xml.ns.icalendar_2.FreqRecurType) RecurType(ietf.params.xml.ns.icalendar_2.RecurType) UntilRecurType(ietf.params.xml.ns.icalendar_2.UntilRecurType) BwString(org.bedework.calfacade.BwString) RrulePropType(ietf.params.xml.ns.icalendar_2.RrulePropType) Date(net.fortuna.ical4j.model.Date) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) Recur(net.fortuna.ical4j.model.Recur)

Aggregations

FreqRecurType (ietf.params.xml.ns.icalendar_2.FreqRecurType)1 RecurType (ietf.params.xml.ns.icalendar_2.RecurType)1 RrulePropType (ietf.params.xml.ns.icalendar_2.RrulePropType)1 UntilRecurType (ietf.params.xml.ns.icalendar_2.UntilRecurType)1 Date (net.fortuna.ical4j.model.Date)1 Recur (net.fortuna.ical4j.model.Recur)1 WeekDay (net.fortuna.ical4j.model.WeekDay)1 RRule (net.fortuna.ical4j.model.property.RRule)1 BwString (org.bedework.calfacade.BwString)1 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)1