use of org.olat.commons.calendar.model.Kalendar in project openolat by klemens.
the class ICalFileCalendarManager method removeOccurenceOfEvent.
@Override
public boolean removeOccurenceOfEvent(final Kalendar cal, final KalendarRecurEvent kalendarEvent) {
OLATResourceable calOres = getOresHelperFor(cal);
Boolean removeSuccessful = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(calOres, new SyncerCallback<Boolean>() {
@Override
public Boolean execute() {
String uid = kalendarEvent.getID();
Date occurenceDate = kalendarEvent.getBegin();
Kalendar loadedCal = getCalendarFromCache(cal.getType(), cal.getCalendarID());
KalendarEvent rootEvent = loadedCal.getEvent(kalendarEvent.getID(), null);
rootEvent.addRecurrenceExc(kalendarEvent.getBegin());
for (KalendarEvent kEvent : loadedCal.getEvents()) {
if (uid.equals(kEvent.getID()) && kEvent.getOccurenceDate() != null && occurenceDate.equals(kEvent.getOccurenceDate())) {
loadedCal.removeEvent(kEvent);
}
}
boolean successfullyPersist = persistCalendar(loadedCal);
return new Boolean(successfullyPersist);
}
});
// inform all controller about calendar change for reload
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(cal), OresHelper.lookupType(CalendarManager.class));
return removeSuccessful.booleanValue();
}
use of org.olat.commons.calendar.model.Kalendar in project openolat by klemens.
the class ICalFileCalendarManager method addEventTo.
@Override
public boolean addEventTo(final Kalendar cal, final List<KalendarEvent> kalendarEvents) {
OLATResourceable calOres = getOresHelperFor(cal);
Boolean persistSuccessful = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(calOres, new SyncerCallback<Boolean>() {
@Override
public Boolean execute() {
Kalendar loadedCal = getCalendarFromCache(cal.getType(), cal.getCalendarID());
for (KalendarEvent kalendarEvent : kalendarEvents) {
loadedCal.addEvent(kalendarEvent);
kalendarEvent.resetImmutableDates();
}
boolean successfullyPersist = persistCalendar(loadedCal);
return new Boolean(successfullyPersist);
}
});
// inform all controller about calendar change for reload
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(cal), OresHelper.lookupType(CalendarManager.class));
return persistSuccessful.booleanValue();
}
use of org.olat.commons.calendar.model.Kalendar in project openolat by klemens.
the class ICalFileCalendarManager method getCalendarForDeletion.
@Override
public KalendarRenderWrapper getCalendarForDeletion(OLATResourceable resource) {
String type;
if ("CourseModule".equals(resource.getResourceableTypeName())) {
type = CalendarManager.TYPE_COURSE;
} else {
type = CalendarManager.TYPE_GROUP;
}
Kalendar cal = getCalendar(type, resource.getResourceableId().toString());
KalendarRenderWrapper calendarWrapper = new KalendarRenderWrapper(cal, "To delete");
calendarWrapper.setCssClass(KalendarRenderWrapper.CALENDAR_COLOR_GREEN);
calendarWrapper.setVisible(true);
return calendarWrapper;
}
use of org.olat.commons.calendar.model.Kalendar in project openolat by klemens.
the class ICalFileCalendarManager method createKalendarEventRecurringOccurence.
@Override
public KalendarEvent createKalendarEventRecurringOccurence(KalendarRecurEvent recurEvent) {
KalendarEvent rootEvent = recurEvent.getCalendar().getEvent(recurEvent.getID(), null);
VEvent vEvent = getVEvent(recurEvent);
PropertyList vEventProperties = vEvent.getProperties();
for (Iterator<?> objIt = vEventProperties.iterator(); objIt.hasNext(); ) {
Object property = objIt.next();
if (property instanceof RRule || property instanceof ExDate) {
objIt.remove();
}
}
try {
Kalendar calendar = recurEvent.getCalendar();
Date startDate = recurEvent.getOccurenceDate();
String startString = CalendarUtils.formatRecurrenceDate(startDate, rootEvent.isAllDayEvent());
RecurrenceId recurId;
if (rootEvent.isAllDayEvent()) {
recurId = new RecurrenceId(tz);
recurId.setDate(CalendarUtils.createDate(startDate));
} else {
recurId = new RecurrenceId(startString, tz);
}
vEventProperties.add(recurId);
KalendarEvent kEvent = getKalendarEvent(vEvent);
kEvent.setKalendar(calendar);
return kEvent;
} catch (ParseException e) {
log.error("", e);
return null;
}
}
use of org.olat.commons.calendar.model.Kalendar in project openolat by klemens.
the class ICalFileCalendarManager method getImportedCalendar.
@Override
public KalendarRenderWrapper getImportedCalendar(Identity identity, String calendarId) {
Kalendar cal = getCalendar(CalendarManager.TYPE_USER, calendarId);
KalendarRenderWrapper calendarWrapper = new KalendarRenderWrapper(cal, calendarId);
calendarWrapper.setCssClass(KalendarRenderWrapper.CALENDAR_COLOR_BLUE);
calendarWrapper.setVisible(true);
calendarWrapper.setImported(true);
return calendarWrapper;
}
Aggregations