Search in sources :

Example 1 with KalendarRecurEvent

use of org.olat.commons.calendar.model.KalendarRecurEvent 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);
    }
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) KalendarRecurEvent(org.olat.commons.calendar.model.KalendarRecurEvent) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Example 2 with KalendarRecurEvent

use of org.olat.commons.calendar.model.KalendarRecurEvent 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);
    }
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) KalendarRecurEvent(org.olat.commons.calendar.model.KalendarRecurEvent) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)

Example 3 with KalendarRecurEvent

use of org.olat.commons.calendar.model.KalendarRecurEvent in project OpenOLAT by OpenOLAT.

the class FullCalendarElement method doSelect.

private void doSelect(UserRequest ureq, String eventId, String targetDomId) {
    KalendarEvent event = component.getCalendarEvent(eventId);
    if (component.isOccurenceOfCalendarEvent(eventId)) {
        String uid = component.getCalendarEventUid(eventId);
        KalendarRenderWrapper cal = component.getCalendarById(uid);
        KalendarRecurEvent recurEvent = getCurrenceKalendarEvent(cal, eventId);
        getRootForm().fireFormEvent(ureq, new CalendarGUISelectEvent(this, recurEvent, cal, targetDomId));
    } else if (component.isReccurenceOfCalendarEvent(eventId)) {
        String uid = component.getCalendarEventUid(eventId);
        KalendarRenderWrapper cal = component.getCalendarById(uid);
        KalendarRecurEvent recurEvent = getCurrenceKalendarEvent(cal, eventId);
        getRootForm().fireFormEvent(ureq, new CalendarGUISelectEvent(this, recurEvent, cal, targetDomId));
    } else {
        KalendarRenderWrapper calWrapper = component.getCalendarByNormalizedId(eventId);
        getRootForm().fireFormEvent(ureq, new CalendarGUISelectEvent(this, event, calWrapper, targetDomId));
    }
}
Also used : KalendarRecurEvent(org.olat.commons.calendar.model.KalendarRecurEvent) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) CalendarGUISelectEvent(org.olat.commons.calendar.ui.events.CalendarGUISelectEvent)

Example 4 with KalendarRecurEvent

use of org.olat.commons.calendar.model.KalendarRecurEvent in project OpenOLAT by OpenOLAT.

the class FullCalendarElement method getCurrenceKalendarEvent.

private KalendarRecurEvent getCurrenceKalendarEvent(KalendarRenderWrapper cal, String eventId) {
    boolean privateEventsVisible = cal.isPrivateEventsVisible();
    CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
    Date currentDate = component.getCurrentDate();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(currentDate);
    calendar.add(Calendar.MONTH, -2);
    Date from = calendar.getTime();
    calendar.add(Calendar.MONTH, +4);
    Date to = calendar.getTime();
    List<KalendarEvent> events = calendarManager.getEvents(cal.getKalendar(), from, to, privateEventsVisible);
    for (KalendarEvent event : events) {
        if (event instanceof KalendarRecurEvent) {
            KalendarRecurEvent kEvent = (KalendarRecurEvent) event;
            if (eventId.equals(FullCalendarComponent.normalizeId(event))) {
                return kEvent;
            }
        }
    }
    return null;
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) KalendarRecurEvent(org.olat.commons.calendar.model.KalendarRecurEvent) Calendar(java.util.Calendar) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) Date(java.util.Date)

Example 5 with KalendarRecurEvent

use of org.olat.commons.calendar.model.KalendarRecurEvent in project OpenOLAT by OpenOLAT.

the class ICalFileCalendarManager method getEvents.

@Override
public List<KalendarEvent> getEvents(Kalendar calendar, Date from, Date to, boolean privateEventsVisible) {
    List<KalendarEvent> allEvents = calendar.getEvents();
    List<KalendarEvent> events = new ArrayList<>(128);
    Map<String, List<KalendarRecurEvent>> idToRecurringEvents = new HashMap<>();
    // first pass, ignore events with recurrenceId
    for (KalendarEvent event : allEvents) {
        if (!privateEventsVisible && event.getClassification() == KalendarEvent.CLASS_PRIVATE) {
            continue;
        }
        if (StringHelper.containsNonWhitespace(event.getRecurrenceID())) {
            continue;
        }
        if (StringHelper.containsNonWhitespace(event.getRecurrenceRule())) {
            List<KalendarRecurEvent> recurringEvents = getRecurringEventsInPeriod(event, from, to, tz);
            if (recurringEvents.size() > 0) {
                idToRecurringEvents.put(event.getID(), recurringEvents);
                for (KalendarRecurEvent recurEvent : recurringEvents) {
                    events.add(recurEvent);
                }
            }
        } else if (isInRange(from, to, event)) {
            events.add(event);
        }
    }
    // process events with recurrenceId
    for (KalendarEvent event : allEvents) {
        if (!StringHelper.containsNonWhitespace(event.getRecurrenceID())) {
            continue;
        }
        String id = event.getID();
        if (idToRecurringEvents.containsKey(id)) {
            VEvent vEvent = getVEvent(event);
            RecurrenceId recurrenceId = vEvent.getRecurrenceId();
            net.fortuna.ical4j.model.Date startDate = recurrenceId.getDate();
            if (startDate instanceof net.fortuna.ical4j.model.DateTime) {
                List<KalendarRecurEvent> recurringEvents = idToRecurringEvents.get(id);
                for (KalendarRecurEvent recurEvent : recurringEvents) {
                    Date beginDate = recurEvent.getBegin();
                    if (beginDate.equals(startDate)) {
                        recurEvent.setRecurrenceEvent(event);
                    }
                }
            } else {
                List<KalendarRecurEvent> recurringEvents = idToRecurringEvents.get(id);
                for (KalendarRecurEvent recurEvent : recurringEvents) {
                    Date beginDate = recurEvent.getBegin();
                    net.fortuna.ical4j.model.Date occDate = CalendarUtils.createDate(beginDate);
                    if (occDate.equals(startDate)) {
                        recurEvent.setRecurrenceEvent(event);
                    }
                }
            }
        }
    }
    return events;
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) DateTime(net.fortuna.ical4j.model.DateTime) Date(java.util.Date) ExDate(net.fortuna.ical4j.model.property.ExDate) KalendarRecurEvent(org.olat.commons.calendar.model.KalendarRecurEvent) PropertyList(net.fortuna.ical4j.model.PropertyList) List(java.util.List) DateList(net.fortuna.ical4j.model.DateList) ArrayList(java.util.ArrayList) PeriodList(net.fortuna.ical4j.model.PeriodList) RecurrenceId(net.fortuna.ical4j.model.property.RecurrenceId)

Aggregations

KalendarRecurEvent (org.olat.commons.calendar.model.KalendarRecurEvent)20 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)12 Date (java.util.Date)8 Kalendar (org.olat.commons.calendar.model.Kalendar)8 ExDate (net.fortuna.ical4j.model.property.ExDate)6 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)6 ArrayList (java.util.ArrayList)4 DateTime (net.fortuna.ical4j.model.DateTime)4 PeriodList (net.fortuna.ical4j.model.PeriodList)4 VEvent (net.fortuna.ical4j.model.component.VEvent)4 CalendarManager (org.olat.commons.calendar.CalendarManager)4 Calendar (java.util.Calendar)2 HashMap (java.util.HashMap)2 List (java.util.List)2 DateList (net.fortuna.ical4j.model.DateList)2 Period (net.fortuna.ical4j.model.Period)2 PropertyList (net.fortuna.ical4j.model.PropertyList)2 RecurrenceId (net.fortuna.ical4j.model.property.RecurrenceId)2 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)2 CalendarGUIModifiedEvent (org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)2