use of fi.otavanopisto.muikku.calendar.CalendarEventStatus in project muikku by otavanopisto.
the class GoogleCalendarClient method toMuikkuEvent.
private CalendarEvent toMuikkuEvent(String calendarId, Event event) {
String url = event.getHangoutLink();
CalendarEventLocation location = new DefaultCalendarEventLocation(event.getLocation(), null, null, null);
CalendarEventStatus status = CalendarEventStatus.valueOf(event.getStatus().toUpperCase(Locale.ROOT));
// TODO: attendees
List<CalendarEventAttendee> attendees = null;
CalendarEventUser organizer = new GoogleCalendarEventUser(event.getOrganizer().getDisplayName(), event.getOrganizer().getEmail());
CalendarEventTemporalField start = Convert.toCalendarEventTemporalField(event.getStart());
CalendarEventTemporalField end = Convert.toCalendarEventTemporalField(event.getEnd());
boolean allDay = event.getStart().getDate() != null;
Map<String, String> extendedProperties = Collections.emptyMap();
// TODO: reminders
List<CalendarEventReminder> reminders = null;
String recurrence = null;
if (event.getRecurrence() != null && !event.getRecurrence().isEmpty()) {
List<String> rrules = new ArrayList<String>();
for (String rule : event.getRecurrence()) {
if (StringUtils.startsWith(rule, "RRULE:")) {
rrules.add(rule);
} else {
logger.warning(String.format("Ignoring unsupported recurrence rule %s from Google", rule));
}
}
if (rrules.isEmpty()) {
logger.warning("Could not parse recurring event recurrene because all rules were in unsupported formats");
} else {
if (rrules.size() > 1) {
logger.warning(String.format("More than one recurrence rule defined. Ignoring %d rules", rrules.size() - 1));
}
recurrence = StringUtils.substring(rrules.get(0), 6);
}
}
return new DefaultCalendarEvent(event.getId(), calendarId, "google", event.getSummary(), event.getDescription(), url, location, status, attendees, organizer, start, end, allDay, Convert.toDate(event.getCreated()), Convert.toDate(event.getUpdated()), extendedProperties, reminders, recurrence);
}
Aggregations