Search in sources :

Example 11 with ICalendar

use of com.axelor.apps.base.db.ICalendar in project axelor-open-suite by axelor.

the class ICalendarService method load.

/**
 * Load the calendar events from the given reader.
 *
 * @param calendar the target {@link ICalendar}
 * @param reader the input source reader
 * @throws IOException
 * @throws ParserException
 */
@Transactional(rollbackOn = { Exception.class })
public void load(ICalendar calendar, Reader reader) throws IOException, ParserException {
    Preconditions.checkNotNull(calendar, "calendar can't be null");
    Preconditions.checkNotNull(reader, "reader can't be null");
    final CalendarBuilder builder = new CalendarBuilder();
    final Calendar cal = builder.build(reader);
    if (calendar.getName() == null && cal.getProperty(X_WR_CALNAME) != null) {
        calendar.setName(cal.getProperty(X_WR_CALNAME).getValue());
    }
    for (Object item : cal.getComponents(Component.VEVENT)) {
        findOrCreateEvent((VEvent) item, calendar);
    }
}
Also used : CalendarBuilder(net.fortuna.ical4j.data.CalendarBuilder) Calendar(net.fortuna.ical4j.model.Calendar) ICalendar(com.axelor.apps.base.db.ICalendar) Transactional(com.google.inject.persist.Transactional)

Aggregations

ICalendar (com.axelor.apps.base.db.ICalendar)11 ICalendarService (com.axelor.apps.base.ical.ICalendarService)5 ICalendarEvent (com.axelor.apps.base.db.ICalendarEvent)3 IOException (java.io.IOException)3 MalformedURLException (java.net.MalformedURLException)3 ParseException (java.text.ParseException)3 ParserException (net.fortuna.ical4j.data.ParserException)3 Calendar (net.fortuna.ical4j.model.Calendar)3 VEvent (net.fortuna.ical4j.model.component.VEvent)3 AxelorException (com.axelor.exception.AxelorException)2 Transactional (com.google.inject.persist.Transactional)2 SocketException (java.net.SocketException)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 FailedOperationException (net.fortuna.ical4j.connector.FailedOperationException)2 ObjectStoreException (net.fortuna.ical4j.connector.ObjectStoreException)2 ConstraintViolationException (net.fortuna.ical4j.model.ConstraintViolationException)2 ValidationException (net.fortuna.ical4j.validate.ValidationException)2 DavException (org.apache.jackrabbit.webdav.DavException)2