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);
}
}
Aggregations