use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManager method updateCalendar.
@Override
public boolean updateCalendar(final Kalendar cal, final Kalendar importedCal) {
OLATResourceable calOres = getOresHelperFor(cal);
Boolean updatedSuccessful = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(calOres, new SyncerCallback<Boolean>() {
@Override
public Boolean execute() {
Map<KalendarEventKey, KalendarEvent> uidToEvent = new HashMap<>();
for (KalendarEvent event : cal.getEvents()) {
if (StringHelper.containsNonWhitespace(event.getID())) {
uidToEvent.put(new KalendarEventKey(event), event);
}
}
Kalendar loadedCal = getCalendarFromCache(cal.getType(), cal.getCalendarID());
for (KalendarEvent importedEvent : importedCal.getEvents()) {
KalendarEventKey uid = new KalendarEventKey(importedEvent);
if (uidToEvent.containsKey(uid)) {
// remove old event
loadedCal.removeEvent(importedEvent);
// add changed event
loadedCal.addEvent(importedEvent);
} else {
loadedCal.addEvent(importedEvent);
}
}
boolean successfullyPersist = persistCalendar(cal);
// inform all controller about calendar change for reload
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(cal), OresHelper.lookupType(CalendarManager.class));
return new Boolean(successfullyPersist);
}
});
return updatedSuccessful.booleanValue();
}
use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManager method createKalendar.
protected Kalendar createKalendar(String type, String calendarID, Calendar calendar) {
Kalendar cal = new Kalendar(calendarID, type);
for (Iterator<?> iter = calendar.getComponents().iterator(); iter.hasNext(); ) {
Object comp = iter.next();
if (comp instanceof VEvent) {
VEvent vevent = (VEvent) comp;
KalendarEvent calEvent = getKalendarEvent(vevent);
cal.addEvent(calEvent);
} else if (comp instanceof VTimeZone) {
log.info("createKalendar: VTimeZone Component is not supported and will not be added to calender");
log.debug("createKalendar: VTimeZone=" + comp);
} else {
log.warn("createKalendar: unknown Component=" + comp);
}
}
return cal;
}
use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method unsyncInternalCalendar.
/*
private void unsyncParticipantsCalendar(RepositoryEntry entry) {
List<Identity> participants = getParticipants(entry);
unsyncInternalCalendar(entry, participants);
}
*/
private void unsyncInternalCalendar(RepositoryEntry entry, List<Identity> identities) {
String prefix = generateExternalIdPrefix(entry);
for (Identity identity : identities) {
Kalendar cal = calendarMgr.getCalendar(CalendarManager.TYPE_USER, identity.getName());
List<KalendarEvent> events = new ArrayList<>(cal.getEvents());
for (KalendarEvent event : events) {
if (event.getExternalId() != null && event.getExternalId().startsWith(prefix)) {
calendarMgr.removeEventFrom(cal, event);
}
}
lectureParticipantSummaryDao.updateCalendarSynchronization(entry, identity);
}
}
use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method syncCourseCalendar.
private void syncCourseCalendar(LectureBlock lectureBlock, RepositoryEntry entry) {
Kalendar cal = calendarMgr.getCalendar(CalendarManager.TYPE_COURSE, entry.getOlatResource().getResourceableId().toString());
syncEvent(lectureBlock, entry, cal);
}
use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.
the class LectureServiceImpl method unsyncCourseCalendar.
private void unsyncCourseCalendar(LectureBlock lectureBlock, RepositoryEntry entry) {
Kalendar cal = calendarMgr.getCalendar(CalendarManager.TYPE_COURSE, entry.getOlatResource().getResourceableId().toString());
unsyncEvent(lectureBlock, entry, cal);
}
Aggregations