/** * Build recurring properties from ical recurrence. * * @param r * @return RecurTyp filled in * @throws Throwable */ public static RecurType doRecur(final Recur r) throws Throwable { 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(); 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 (Object o : r.getDayList()) { l.add(((WeekDay) o).getDay()); } } 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()); return rt; }
public TeamEventRecurrenceData(final Recur recur, final TimeZone timeZone) { this.timeZone = timeZone; if (recur == null) { return; } this.interval = recur.getInterval(); if (this.interval < 1) { this.interval = 1; } if (recur.getUntil() != null) { this.until = CalendarUtils.getEndOfDay(recur.getUntil(), timeZone); } this.frequency = ICal4JUtils.getFrequency(recur); }
public static String getRecurrence(final String rule) { if (rule != null) { try { final Recur recur = new Recur(rule); final String frequency = recur.getFrequency(); final WeekDayList wdl = recur.getDayList(); final Integer interval = recur.getInterval(); if ((wdl != null && wdl.size() > 0)) { // we only support one rule with daylist return CalendarEntry.WORKDAILY; } else if (interval != null && interval == 2) { // we only support one rule with interval return CalendarEntry.BIWEEKLY; } else { // native supportet rule return frequency; } } catch (final ParseException e) { log.error("cannot restore recurrence rule", e); } } return null; }