Search in sources :

Example 1 with CalendarServiceProvider

use of fi.otavanopisto.muikku.calendar.CalendarServiceProvider in project muikku by otavanopisto.

the class CalendarController method updateCalendarEvent.

public CalendarEvent updateCalendarEvent(UserCalendar userCalendar, CalendarEvent calendarEvent) throws CalendarServiceException {
    CalendarServiceProvider provider = getCalendarServiceProvider(userCalendar.getCalendarProvider());
    Calendar calendar = provider.findCalendar(userCalendar.getCalendarId());
    if (calendar == null) {
        throw new CalendarServiceException("Could not find calendar for user calendar #" + userCalendar.getId());
    }
    if (StringUtils.isBlank(calendarEvent.getId())) {
        throw new CalendarServiceException("Cannot update event without id");
    }
    return provider.updateEvent(calendarEvent);
}
Also used : CalendarServiceException(fi.otavanopisto.muikku.calendar.CalendarServiceException) CalendarServiceProvider(fi.otavanopisto.muikku.calendar.CalendarServiceProvider) Calendar(fi.otavanopisto.muikku.calendar.Calendar) UserCalendar(fi.otavanopisto.muikku.plugins.calendar.model.UserCalendar)

Example 2 with CalendarServiceProvider

use of fi.otavanopisto.muikku.calendar.CalendarServiceProvider in project muikku by otavanopisto.

the class CalendarController method findCalendarEvent.

public fi.otavanopisto.muikku.calendar.CalendarEvent findCalendarEvent(UserCalendar userCalendar, String eventId) throws CalendarServiceException {
    CalendarServiceProvider provider = getCalendarServiceProvider(userCalendar.getCalendarProvider());
    Calendar calendar = provider.findCalendar(userCalendar.getCalendarId());
    if (calendar == null) {
        throw new CalendarServiceException("Could not find calendar for user calendar #" + userCalendar.getId());
    }
    return provider.findEvent(calendar, eventId);
}
Also used : CalendarServiceException(fi.otavanopisto.muikku.calendar.CalendarServiceException) CalendarServiceProvider(fi.otavanopisto.muikku.calendar.CalendarServiceProvider) Calendar(fi.otavanopisto.muikku.calendar.Calendar) UserCalendar(fi.otavanopisto.muikku.plugins.calendar.model.UserCalendar)

Example 3 with CalendarServiceProvider

use of fi.otavanopisto.muikku.calendar.CalendarServiceProvider in project muikku by otavanopisto.

the class CalendarController method createCalendarEvent.

public CalendarEvent createCalendarEvent(UserCalendar userCalendar, String summary, String description, CalendarEventStatus status, Date start, TimeZone startTimeZone, Date end, TimeZone endTimeZone, List<CalendarEventAttendee> attendees, List<CalendarEventReminder> reminders, String recurrence, boolean allDay, Map<String, String> extendedProperties) throws CalendarServiceException {
    CalendarServiceProvider provider = getCalendarServiceProvider(userCalendar.getCalendarProvider());
    Calendar calendar = provider.findCalendar(userCalendar.getCalendarId());
    if (calendar == null) {
        throw new CalendarServiceException("Could not find calendar for user calendar #" + userCalendar.getId());
    }
    return provider.createEvent(calendar.getId(), summary, description, status, attendees, new DefaultCalendarEventTemporalField(start, startTimeZone), new DefaultCalendarEventTemporalField(end, endTimeZone), reminders, recurrence, allDay);
}
Also used : CalendarServiceException(fi.otavanopisto.muikku.calendar.CalendarServiceException) DefaultCalendarEventTemporalField(fi.otavanopisto.muikku.calendar.DefaultCalendarEventTemporalField) CalendarServiceProvider(fi.otavanopisto.muikku.calendar.CalendarServiceProvider) Calendar(fi.otavanopisto.muikku.calendar.Calendar) UserCalendar(fi.otavanopisto.muikku.plugins.calendar.model.UserCalendar)

Example 4 with CalendarServiceProvider

use of fi.otavanopisto.muikku.calendar.CalendarServiceProvider in project muikku by otavanopisto.

the class CalendarController method listCalendarEvents.

public List<fi.otavanopisto.muikku.calendar.CalendarEvent> listCalendarEvents(UserCalendar userCalendar, OffsetDateTime timeMin, OffsetDateTime timeMax) throws CalendarServiceException {
    CalendarServiceProvider provider = getCalendarServiceProvider(userCalendar.getCalendarProvider());
    Calendar calendar = provider.findCalendar(userCalendar.getCalendarId());
    if (calendar == null) {
        throw new CalendarServiceException("Could not find calendar for user calendar #" + userCalendar.getId());
    }
    if (timeMin != null || timeMax != null) {
        return provider.listEvents(timeMin, timeMax, calendar.getId());
    } else {
        return provider.listEvents(calendar.getId());
    }
}
Also used : CalendarServiceException(fi.otavanopisto.muikku.calendar.CalendarServiceException) CalendarServiceProvider(fi.otavanopisto.muikku.calendar.CalendarServiceProvider) Calendar(fi.otavanopisto.muikku.calendar.Calendar) UserCalendar(fi.otavanopisto.muikku.plugins.calendar.model.UserCalendar)

Example 5 with CalendarServiceProvider

use of fi.otavanopisto.muikku.calendar.CalendarServiceProvider in project muikku by otavanopisto.

the class CalendarController method deleteCalendarEvent.

public void deleteCalendarEvent(UserCalendar userCalendar, String eventId) throws CalendarServiceException {
    CalendarServiceProvider provider = getCalendarServiceProvider(userCalendar.getCalendarProvider());
    Calendar calendar = provider.findCalendar(userCalendar.getCalendarId());
    if (calendar == null) {
        throw new CalendarServiceException("Could not find calendar for user calendar #" + userCalendar.getId());
    }
    provider.deleteEvent(calendar, eventId);
}
Also used : CalendarServiceException(fi.otavanopisto.muikku.calendar.CalendarServiceException) CalendarServiceProvider(fi.otavanopisto.muikku.calendar.CalendarServiceProvider) Calendar(fi.otavanopisto.muikku.calendar.Calendar) UserCalendar(fi.otavanopisto.muikku.plugins.calendar.model.UserCalendar)

Aggregations

Calendar (fi.otavanopisto.muikku.calendar.Calendar)6 CalendarServiceException (fi.otavanopisto.muikku.calendar.CalendarServiceException)6 CalendarServiceProvider (fi.otavanopisto.muikku.calendar.CalendarServiceProvider)6 UserCalendar (fi.otavanopisto.muikku.plugins.calendar.model.UserCalendar)6 DefaultCalendarEventTemporalField (fi.otavanopisto.muikku.calendar.DefaultCalendarEventTemporalField)1