use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.
the class CalendarPersonalConfigurationController method doDeleteCalendar.
private void doDeleteCalendar(UserRequest ureq, CalendarPersonalConfigurationRow row) {
if (!row.isImported())
return;
Kalendar calendar = row.getWrapper().getKalendar();
importCalendarManager.deleteCalendar(getIdentity(), calendar);
List<CalendarPersonalConfigurationRow> currentRows = model.getObjects();
currentRows.remove(row);
model.setObjects(currentRows);
tableEl.reloadData();
fireEvent(ureq, new CalendarGUIRemoveEvent(row.getWrapper()));
}
use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.
the class CopyEventToCalendarController method formOK.
@Override
protected void formOK(UserRequest ureq) {
for (MultipleSelectionElement copyEl : copyEls) {
if (copyEl.isEnabled() && copyEl.isAtLeastSelected(1)) {
KalendarRenderWrapper calendarWrapper = (KalendarRenderWrapper) copyEl.getUserObject();
Kalendar cal = calendarWrapper.getKalendar();
KalendarEvent clonedKalendarEvent = (KalendarEvent) XStreamHelper.xstreamClone(kalendarEvent);
if (clonedKalendarEvent.getKalendarEventLinks().size() > 0) {
clonedKalendarEvent.setKalendarEventLinks(new ArrayList<KalendarEventLink>());
}
calendarManager.addEventTo(cal, clonedKalendarEvent);
}
}
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.
the class CalendarNotificationHandler method createSubscriptionInfo.
@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
SubscriptionInfo si = null;
Publisher p = subscriber.getPublisher();
Date latestNews = p.getLatestNewsDate();
// can't be loaded when already deleted
if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews)) {
Long id = p.getResId();
String type = p.getSubidentifier();
try {
Translator translator = Util.createPackageTranslator(CalendarModule.class, locale);
String calType = null;
String title = null;
if (type.equals(CalendarController.ACTION_CALENDAR_COURSE)) {
RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(OresHelper.createOLATResourceableInstance("CourseModule", id), false);
if (re.getRepositoryEntryStatus().isClosed() || re.getRepositoryEntryStatus().isUnpublished()) {
return NotificationsManager.getInstance().getNoSubscriptionInfo();
}
String displayName = re.getDisplayname();
calType = CalendarManager.TYPE_COURSE;
title = translator.translate("cal.notifications.header.course", new String[] { displayName });
} else if (type.equals(CalendarController.ACTION_CALENDAR_GROUP)) {
BusinessGroup group = businessGroupDao.load(id);
calType = CalendarManager.TYPE_GROUP;
if (group == null) {
return notificationsManager.getNoSubscriptionInfo();
}
title = translator.translate("cal.notifications.header.group", new String[] { group.getName() });
}
if (calType != null) {
Formatter form = Formatter.getInstance(locale);
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), new TitleItem(title, CSS_CLASS_CALENDAR_ICON), null);
String bPath;
if (StringHelper.containsNonWhitespace(p.getBusinessPath())) {
bPath = p.getBusinessPath();
} else if ("CalendarManager.course".equals(p.getResName())) {
try {
OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.getCourseTypeName(), p.getResId());
RepositoryEntry re = repositoryManager.lookupRepositoryEntry(ores, true);
// Fallback
bPath = "[RepositoryEntry:" + re.getKey() + "]";
} catch (Exception e) {
log.error("Error processing calendar notifications of publisher:" + p.getKey(), e);
return notificationsManager.getNoSubscriptionInfo();
}
} else {
// cannot make link without business path
return notificationsManager.getNoSubscriptionInfo();
}
Kalendar cal = calendarManager.getCalendar(calType, id.toString());
Collection<KalendarEvent> calEvents = cal.getEvents();
for (KalendarEvent kalendarEvent : calEvents) {
if (showEvent(compareDate, kalendarEvent)) {
log.debug("found a KalendarEvent: " + kalendarEvent.getSubject() + " with time: " + kalendarEvent.getBegin() + " modified before: " + compareDate.toString(), null);
// found a modified event in this calendar
Date modDate = null;
if (kalendarEvent.getLastModified() > 0) {
modDate = new Date(kalendarEvent.getLastModified());
} else if (kalendarEvent.getCreated() > 0) {
modDate = new Date(kalendarEvent.getCreated());
} else if (kalendarEvent.getBegin() != null) {
modDate = kalendarEvent.getBegin();
}
String subject = kalendarEvent.getSubject();
String author = kalendarEvent.getCreatedBy();
if (author == null)
author = "";
String location = "";
if (StringHelper.containsNonWhitespace(kalendarEvent.getLocation())) {
location = kalendarEvent.getLocation() == null ? "" : translator.translate("cal.notifications.location", new String[] { kalendarEvent.getLocation() });
}
String dateStr;
if (kalendarEvent.isAllDayEvent()) {
dateStr = form.formatDate(kalendarEvent.getBegin());
} else {
dateStr = form.formatDate(kalendarEvent.getBegin()) + " - " + form.formatDate(kalendarEvent.getEnd());
}
String desc = translator.translate("cal.notifications.entry", new String[] { subject, dateStr, location, author });
String businessPath = bPath + "[path=" + kalendarEvent.getID() + ":0]";
String urlToSend = BusinessControlFactory.getInstance().getURLFromBusinessPathString(businessPath);
SubscriptionListItem subListItem = new SubscriptionListItem(desc, urlToSend, businessPath, modDate, CSS_CLASS_CALENDAR_ICON);
si.addSubscriptionListItem(subListItem);
}
}
}
} catch (Exception e) {
log.error("Unexpected exception", e);
checkPublisher(p);
si = notificationsManager.getNoSubscriptionInfo();
}
} else {
si = notificationsManager.getNoSubscriptionInfo();
}
return si;
}
use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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);
}
}
Aggregations