* @return a RRule generated by the event
* @throws ParseException
*/
private RRule getRRule(EventVO event) throws ParseException
{
CalendarVO mainCalendar = null;
for(EventCalendarVO vo : event.getEventCalendars()) {
if(EventCalendarVO.ParticipiantType.HOST.equals(vo.getParticipiantType())) {
mainCalendar = vo.getCalendar();
}
}
Recur recur = new Recur("");
if(event.getRecurrenceCycleUnit() == EventVO.RecurrenceUnit.DAY)
recur.setFrequency(Recur.DAILY);
else if(event.getRecurrenceCycleUnit() == EventVO.RecurrenceUnit.WEEK)
recur.setFrequency(Recur.WEEKLY);
else if(event.getRecurrenceCycleUnit() == EventVO.RecurrenceUnit.MONTH)
recur.setFrequency(Recur.MONTHLY);
else if(event.getRecurrenceCycleUnit() == EventVO.RecurrenceUnit.YEAR)
recur.setFrequency(Recur.YEARLY);
if(event.getRecurrenceCycle() != null)
recur.setInterval(event.getRecurrenceCycle());
if(event.getRecurrenceType() == RecurrenceType.UNTIL_DATE)
recur.setUntil(new Date(event.getRecurrenceEndDate()));
else if(event.getRecurrenceType() == RecurrenceType.NUMBER_OF_TIMES)
recur.setCount(event.getRecurrenceNumberOfTimes());
for(RecurrenceInWeek day : event.getRecurrenceInWeek())
{
if (day.getCalendarValue() == java.util.Calendar.MONDAY)
recur.getDayList().add(new WeekDay("MO"));
if (day.getCalendarValue() == java.util.Calendar.TUESDAY)
recur.getDayList().add(new WeekDay("TU"));
if (day.getCalendarValue() == java.util.Calendar.WEDNESDAY)
recur.getDayList().add(new WeekDay("WE"));
if (day.getCalendarValue() == java.util.Calendar.THURSDAY)
recur.getDayList().add(new WeekDay("TH"));
if (day.getCalendarValue() == java.util.Calendar.FRIDAY)
recur.getDayList().add(new WeekDay("FR"));
if (day.getCalendarValue() == java.util.Calendar.SATURDAY)
recur.getDayList().add(new WeekDay("SA"));
if (day.getCalendarValue() == java.util.Calendar.SUNDAY)
recur.getDayList().add(new WeekDay("SU"));
}
if(event.getRecurrenceInMonth() == EventVO.RecurrenceInMonth.DAY_OF_MONTH)
{
java.util.Calendar cal = GregorianCalendar.getInstance();
cal.setFirstDayOfWeek(mainCalendar.getFirstDayOfWeek().getDay());
cal.setTime(event.getStartDate());
recur.getMonthDayList().add(cal.get(java.util.Calendar.DAY_OF_MONTH));
}
else if(event.getRecurrenceInMonth() == EventVO.RecurrenceInMonth.DAY_OF_WEEK)
{
java.util.Calendar cal = GregorianCalendar.getInstance();
cal.setFirstDayOfWeek(mainCalendar.getFirstDayOfWeek().getDay());
cal.setTime(event.getStartDate());
int week = cal.get(java.util.Calendar.WEEK_OF_MONTH);
int day = cal.get(java.util.Calendar.DAY_OF_WEEK);
if (day== java.util.Calendar.MONDAY)
recur.getDayList().add(new WeekDay(week + "MO"));