Search in sources :

Example 1 with CalendarEventStatus

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);
}
Also used : DefaultCalendarEventLocation(fi.otavanopisto.muikku.calendar.DefaultCalendarEventLocation) CalendarEventLocation(fi.otavanopisto.muikku.calendar.CalendarEventLocation) CalendarEventTemporalField(fi.otavanopisto.muikku.calendar.CalendarEventTemporalField) DefaultCalendarEventLocation(fi.otavanopisto.muikku.calendar.DefaultCalendarEventLocation) ArrayList(java.util.ArrayList) GoogleCalendarEventUser(fi.otavanopisto.muikku.plugins.googlecalendar.model.GoogleCalendarEventUser) CalendarEventStatus(fi.otavanopisto.muikku.calendar.CalendarEventStatus) CalendarEventUser(fi.otavanopisto.muikku.calendar.CalendarEventUser) GoogleCalendarEventUser(fi.otavanopisto.muikku.plugins.googlecalendar.model.GoogleCalendarEventUser) CalendarEventAttendee(fi.otavanopisto.muikku.calendar.CalendarEventAttendee) CalendarEventReminder(fi.otavanopisto.muikku.calendar.CalendarEventReminder) DefaultCalendarEvent(fi.otavanopisto.muikku.calendar.DefaultCalendarEvent)

Aggregations

CalendarEventAttendee (fi.otavanopisto.muikku.calendar.CalendarEventAttendee)1 CalendarEventLocation (fi.otavanopisto.muikku.calendar.CalendarEventLocation)1 CalendarEventReminder (fi.otavanopisto.muikku.calendar.CalendarEventReminder)1 CalendarEventStatus (fi.otavanopisto.muikku.calendar.CalendarEventStatus)1 CalendarEventTemporalField (fi.otavanopisto.muikku.calendar.CalendarEventTemporalField)1 CalendarEventUser (fi.otavanopisto.muikku.calendar.CalendarEventUser)1 DefaultCalendarEvent (fi.otavanopisto.muikku.calendar.DefaultCalendarEvent)1 DefaultCalendarEventLocation (fi.otavanopisto.muikku.calendar.DefaultCalendarEventLocation)1 GoogleCalendarEventUser (fi.otavanopisto.muikku.plugins.googlecalendar.model.GoogleCalendarEventUser)1 ArrayList (java.util.ArrayList)1