Java Code Examples for net.fortuna.ical4j.model.Recur#DAILY

The following examples show how to use net.fortuna.ical4j.model.Recur#DAILY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ICalRecurConverter.java    From scipio-erp with Apache License 2.0 6 votes vote down vote up
@Override
public void visit(TemporalExpressions.DayOfWeekRange expr) {
    int startDay = expr.getStartDay();
    int endDay = expr.getEndDay();
    WeekDayList dayList = new WeekDayList();
    dayList.add(dayOfWeekArray[startDay - 1]);
    while (startDay != endDay) {
        startDay++;
        if (startDay > Calendar.SATURDAY) {
            startDay = Calendar.SUNDAY;
        }
        dayList.add(dayOfWeekArray[startDay - 1]);
    }
    Recur recur = new Recur(Recur.DAILY, 0);
    recur.getDayList().addAll(dayList);
    this.state.addRecur(recur);
}
 
Example 2
Source File: ICal4JUtils.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param recur
 * @return
 */
public static String getFrequency(final RecurrenceFrequency interval)
{
  if (interval == null) {
    return null;
  }
  if (interval == RecurrenceFrequency.WEEKLY) {
    return Recur.WEEKLY;
  } else if (interval == RecurrenceFrequency.DAILY) {
    return Recur.DAILY;
  } else if (interval == RecurrenceFrequency.MONTHLY) {
    return Recur.MONTHLY;
  } else if (interval == RecurrenceFrequency.YEARLY) {
    return Recur.YEARLY;
  }
  return null;
}
 
Example 3
Source File: ICalRecurConverter.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(TemporalExpressions.DayOfMonthRange expr) {
    int startDay = expr.getStartDay();
    int endDay = expr.getEndDay();
    NumberList dayList = new NumberList();
    dayList.add(startDay);
    while (startDay != endDay) {
        startDay++;
        dayList.add(startDay);
    }
    Recur recur = new Recur(Recur.DAILY, 0);
    recur.getMonthDayList().addAll(dayList);
    this.state.addRecur(recur);
}
 
Example 4
Source File: ICal4JUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static String getCal4JFrequencyString(final RecurrenceFrequency interval)
{
  if (interval == RecurrenceFrequency.DAILY) {
    return Recur.DAILY;
  } else if (interval == RecurrenceFrequency.WEEKLY) {
    return Recur.WEEKLY;
  } else if (interval == RecurrenceFrequency.MONTHLY) {
    return Recur.MONTHLY;
  } else if (interval == RecurrenceFrequency.YEARLY) {
    return Recur.YEARLY;
  }
  return null;
}
 
Example 5
Source File: ICalRecurConverter.java    From scipio-erp with Apache License 2.0 4 votes vote down vote up
protected Recur consolidateRecurs(List<Recur> recurList) {
    // Try to consolidate a list of Recur instances into one instance
    Set<Integer> monthList = new HashSet<>();
    Set<Integer> monthDayList = new HashSet<>();
    Set<WeekDay> weekDayList = new HashSet<>();
    Set<Integer> hourList = new HashSet<>();
    Set<Integer> minuteList = new HashSet<>();
    String freq = null;
    int freqCount = 0;
    for (Recur recur : recurList) {
        monthList.addAll(recur.getMonthList());
        monthDayList.addAll(recur.getMonthDayList());
        weekDayList.addAll(recur.getDayList());
        hourList.addAll(recur.getHourList());
        minuteList.addAll(recur.getMinuteList());
        if (recur.getInterval() != 0) {
            freq = recur.getFrequency();
            freqCount = recur.getInterval();
        }
    }
    if (freq == null && monthList.size() > 0) {
        freq = Recur.MONTHLY;
    } else if (freq == null && (monthDayList.size() > 0 || weekDayList.size() > 0)) {
        freq = Recur.DAILY;
    } else if (freq == null && hourList.size() > 0) {
        freq = Recur.HOURLY;
    } else if (freq == null && minuteList.size() > 0) {
        freq = Recur.MINUTELY;
    }
    if (freq == null) {
        throw new IllegalStateException("Unable to convert intersection");
    }
    Recur newRecur = new Recur(freq, 0);
    if (freqCount != 0) {
        newRecur.setInterval(freqCount);
    }
    newRecur.getMonthList().addAll(monthList);
    newRecur.getMonthDayList().addAll(monthDayList);
    newRecur.getDayList().addAll(weekDayList);
    newRecur.getHourList().addAll(hourList);
    newRecur.getMinuteList().addAll(minuteList);
    return newRecur;
}