use of org.olat.commons.calendar.model.Kalendar in project openolat by klemens.
the class LectureServiceImpl method fullSyncCourseCalendar.
private void fullSyncCourseCalendar(RepositoryEntry entry) {
List<LectureBlock> blocks = getLectureBlocks(entry);
Map<String, LectureBlock> externalIds = blocks.stream().collect(Collectors.toMap(b -> generateExternalId(b, entry), b -> b));
Kalendar cal = calendarMgr.getCalendar(CalendarManager.TYPE_COURSE, entry.getOlatResource().getResourceableId().toString());
String prefix = generateExternalIdPrefix(entry);
List<KalendarEvent> events = new ArrayList<>(cal.getEvents());
for (KalendarEvent event : events) {
String externalId = event.getExternalId();
if (StringHelper.containsNonWhitespace(externalId) && externalId.startsWith(prefix)) {
if (externalIds.containsKey(externalId)) {
if (updateEvent(externalIds.get(externalId), event)) {
calendarMgr.updateEventFrom(cal, event);
}
externalIds.remove(externalId);
} else {
calendarMgr.removeEventFrom(cal, event);
}
}
}
// add new calendar events
List<KalendarEvent> eventsToAdd = new ArrayList<>();
for (Map.Entry<String, LectureBlock> entryToAdd : externalIds.entrySet()) {
eventsToAdd.add(createEvent(entryToAdd.getValue(), entry));
}
if (eventsToAdd.size() > 0) {
calendarMgr.addEventTo(cal, eventsToAdd);
}
}
use of org.olat.commons.calendar.model.Kalendar in project openolat by klemens.
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 klemens.
the class WeeklyCalendarController method doResize.
private void doResize(UserRequest ureq, KalendarEvent calEvent, Long minuteDelta, Boolean allDay) {
if (calEvent instanceof KalendarRecurEvent && !StringHelper.containsNonWhitespace(calEvent.getRecurrenceID())) {
updateCtr = new ConfirmUpdateController(ureq, getWindowControl(), (KalendarRecurEvent) calEvent, 0L, minuteDelta, allDay, false);
listenTo(updateCtr);
String title = translate("cal.edit.update");
cmc = new CloseableModalController(getWindowControl(), translate("close"), updateCtr.getInitialComponent(), true, title);
listenTo(cmc);
cmc.activate();
} else {
Kalendar cal = calEvent.getCalendar();
calEvent.setEnd(doMove(calEvent.getEnd(), 0L, minuteDelta));
if (allDay != null && calEvent.isAllDayEvent() != allDay.booleanValue()) {
calEvent.setAllDayEvent(allDay.booleanValue());
}
calendarManager.updateEventFrom(cal, calEvent);
calendarEl.getComponent().setDirty(true);
}
}
use of org.olat.commons.calendar.model.Kalendar in project openolat by klemens.
the class WeeklyCalendarController method doMove.
private void doMove(UserRequest ureq, KalendarEvent calEvent, Long dayDelta, Long minuteDelta, Boolean allDay) {
if (calEvent instanceof KalendarRecurEvent && !StringHelper.containsNonWhitespace(calEvent.getRecurrenceID())) {
updateCtr = new ConfirmUpdateController(ureq, getWindowControl(), (KalendarRecurEvent) calEvent, dayDelta, minuteDelta, allDay, true);
listenTo(updateCtr);
String title = translate("cal.edit.update");
cmc = new CloseableModalController(getWindowControl(), translate("close"), updateCtr.getInitialComponent(), true, title);
listenTo(cmc);
cmc.activate();
} else {
Kalendar cal = calEvent.getCalendar();
calEvent.setBegin(doMove(calEvent.getBegin(), dayDelta, minuteDelta));
calEvent.setEnd(doMove(calEvent.getEnd(), dayDelta, minuteDelta));
if (allDay != null && calEvent.isAllDayEvent() != allDay.booleanValue()) {
calEvent.setAllDayEvent(allDay.booleanValue());
}
calendarManager.updateEventFrom(cal, calEvent);
calendarEl.getComponent().setDirty(true);
}
}
use of org.olat.commons.calendar.model.Kalendar in project openolat by klemens.
the class WeeklyCalendarController method event.
@Override
public void event(UserRequest ureq, Controller source, Event event) {
Kalendar affectedCal = null;
if (dirty) {
dirty = false;
fireEvent(ureq, new CalendarGUIModifiedEvent());
}
if (source == editController) {
affectedCal = editController.getKalendarEvent().getCalendar();
cmc.deactivate();
calendarEl.getComponent().setDirty(true);
// do logging if affectedCal not null
if (affectedCal != null) {
ThreadLocalUserActivityLogger.log(getCalLoggingAction(), getClass(), LoggingResourceable.wrap(ureq.getIdentity()), LoggingResourceable.wrap(affectedCal));
}
cleanUp();
} else if (source == eventDetailsCtr) {
if (event instanceof CalendarGUIEditEvent) {
eventCalloutCtr.deactivate();
cleanUp();
CalendarGUIEditEvent editEvent = (CalendarGUIEditEvent) event;
pushEditEventController(ureq, editEvent.getKalendarEvent(), editEvent.getKalendarRenderWrapper());
} else if (event == Event.DONE_EVENT) {
eventCalloutCtr.deactivate();
cleanUp();
}
} else if (source == updateCtr) {
if (event instanceof CalendarGUIUpdateEvent) {
doUpdate((CalendarGUIUpdateEvent) event, updateCtr.getKalendarEvent(), updateCtr.getDayDelta(), updateCtr.getMinuteDelta(), updateCtr.getAllDay(), updateCtr.getChangeBegin());
}
cmc.deactivate();
cleanUp();
} else if (source == printCtrl) {
if (event instanceof CalendarGUIPrintEvent) {
CalendarGUIPrintEvent printEvent = (CalendarGUIPrintEvent) event;
if (printEvent.getFrom() != null && printEvent.getTo() != null) {
doPrint(printEvent.getFrom(), printEvent.getTo());
}
}
eventCalloutCtr.deactivate();
cleanUp();
} else if (source == cmc) {
calendarEl.getComponent().setDirty(true);
cleanUp();
} else if (source == dbcSequence) {
if (event != Event.CANCELLED_EVENT) {
int pos = DialogBoxUIFactory.getButtonPos(event);
CalendarGUIEditEvent guiEvent = (CalendarGUIEditEvent) dbcSequence.getUserObject();
KalendarRenderWrapper kalendarWrapper = guiEvent.getKalendarRenderWrapper();
KalendarEvent kalendarEvent = guiEvent.getKalendarEvent();
if (pos == 0) {
// edit the sequence
// load the parent event of this sequence
KalendarEvent parentEvent = kalendarWrapper.getKalendar().getEvent(kalendarEvent.getID(), kalendarEvent.getRecurrenceID());
pushEditEventController(ureq, parentEvent, kalendarWrapper);
} else if (pos == 1) {
// delete a single event of the sequence
deleteSingleYesNoController = activateYesNoDialog(ureq, null, translate("cal.delete.dialogtext"), deleteSingleYesNoController);
deleteSingleYesNoController.setUserObject(kalendarEvent);
} else if (pos == 2) {
// delete the whole sequence
deleteSequenceYesNoController = activateYesNoDialog(ureq, null, translate("cal.delete.dialogtext.sequence"), deleteSequenceYesNoController);
deleteSequenceYesNoController.setUserObject(kalendarEvent);
}
}
dbcSequence.dispose();
} else if (source == deleteSingleYesNoController) {
if (DialogBoxUIFactory.isYesEvent(event)) {
KalendarEvent kalendarEvent = (KalendarEvent) deleteSingleYesNoController.getUserObject();
affectedCal = kalendarEvent.getCalendar();
KalendarEvent kEvent = affectedCal.getEvent(kalendarEvent.getID(), kalendarEvent.getRecurrenceID());
kEvent.addRecurrenceExc(kalendarEvent.getBegin());
calendarManager.updateEventFrom(affectedCal, kEvent);
deleteSingleYesNoController.dispose();
calendarEl.getComponent().setDirty(true);
}
} else if (source == deleteSequenceYesNoController) {
if (DialogBoxUIFactory.isYesEvent(event)) {
KalendarEvent kalendarEvent = (KalendarEvent) deleteSequenceYesNoController.getUserObject();
affectedCal = kalendarEvent.getCalendar();
calendarManager.removeEventFrom(affectedCal, kalendarEvent);
deleteSequenceYesNoController.dispose();
calendarEl.getComponent().setDirty(true);
}
} else if (configurationCtrl == source) {
if (event instanceof CalendarGUIImportEvent) {
CalendarGUIImportEvent importEvent = (CalendarGUIImportEvent) event;
calendarWrappers.add(importEvent.getCalendar());
calendarEl.setCalendars(calendarWrappers);
} else if (event instanceof CalendarGUIRemoveEvent) {
CalendarGUIRemoveEvent removeEvent = (CalendarGUIRemoveEvent) event;
calendarWrappers.remove(removeEvent.getCalendar());
calendarEl.setCalendars(calendarWrappers);
} else if (event instanceof CalendarGUISettingEvent) {
calendarEl.setCalendars(calendarWrappers);
}
} else if (eventCalloutCtr == source) {
cleanUp();
} else if (eventDetailsCtr == source) {
}
if (calendarEl.getComponent().isDirty()) {
if (subsContext != null) {
// group or course calendar -> prepared subscription context is the right one
NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
} else if (caller.equals(CALLER_HOME) && affectedCal != null) {
// one can add/edit/remove dates of group and course calendars from the home calendar view -> choose right subscription context
for (KalendarRenderWrapper calWrapper : calendarWrappers) {
if (affectedCal == calWrapper.getKalendar()) {
SubscriptionContext tmpSubsContext = calendarNotificationsManager.getSubscriptionContext(calWrapper);
NotificationsManager.getInstance().markPublisherNews(tmpSubsContext, ureq.getIdentity(), true);
}
}
}
}
}
Aggregations