Search in sources :

Example 11 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class CourseCalendarController method needToDifferentiateManagedEvents.

private boolean needToDifferentiateManagedEvents(List<KalendarRenderWrapper> calendars) {
    boolean hasManaged = false;
    for (KalendarRenderWrapper wrapper : calendars) {
        Kalendar cal = wrapper.getKalendar();
        hasManaged |= cal.hasManagedEvents();
    }
    return hasManaged;
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 12 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class UserInfoMainController method doOpenCalendar.

private WeeklyCalendarController doOpenCalendar(UserRequest ureq) {
    removeAsListenerAndDispose(calendarController);
    KalendarRenderWrapper calendarWrapper = calendarManager.getPersonalCalendar(chosenIdentity);
    CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(calendarWrapper.getKalendar(), getIdentity());
    if (config != null) {
        calendarWrapper.setConfiguration(config);
    }
    calendarWrapper.setPrivateEventsVisible(chosenIdentity.equals(ureq.getIdentity()));
    if (chosenIdentity.equals(ureq.getIdentity())) {
        calendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
    } else {
        calendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
    }
    List<KalendarRenderWrapper> calendars = new ArrayList<KalendarRenderWrapper>();
    calendars.add(calendarWrapper);
    OLATResourceable ores = OresHelper.createOLATResourceableType(CMD_CALENDAR);
    WindowControl bwControl = addToHistory(ureq, ores, null);
    OLATResourceable callerOres = OresHelper.createOLATResourceableInstance(chosenIdentity.getName(), chosenIdentity.getKey());
    calendarController = new WeeklyCalendarController(ureq, bwControl, calendars, WeeklyCalendarController.CALLER_PROFILE, callerOres, false);
    listenTo(calendarController);
    return calendarController;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) WeeklyCalendarController(org.olat.commons.calendar.ui.WeeklyCalendarController) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) WindowControl(org.olat.core.gui.control.WindowControl)

Example 13 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class GroupInfoMainController method getCalendarController.

private WeeklyCalendarController getCalendarController(UserRequest ureq) {
    if (calendarController == null) {
        OLATResourceable ores = OresHelper.createOLATResourceableInstance("Calendar", 0l);
        WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, getWindowControl());
        List<KalendarRenderWrapper> calendarWrappers = new ArrayList<>(2);
        KalendarRenderWrapper groupCalendar = calendarManager.getGroupCalendar(businessGroup);
        groupCalendar.setPrivateEventsVisible(false);
        calendarWrappers.add(groupCalendar);
        calendarController = new WeeklyCalendarController(ureq, bwControl, calendarWrappers, WeeklyCalendarController.CALLER_COLLAB, businessGroup, false);
        listenTo(calendarController);
    }
    layoutController.setCol3(calendarController.getInitialComponent());
    addToHistory(ureq, calendarController);
    return calendarController;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) WeeklyCalendarController(org.olat.commons.calendar.ui.WeeklyCalendarController) WindowControl(org.olat.core.gui.control.WindowControl) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 14 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class ICalFileCalendarManagerTest method testImportICal_icalFullDay.

@Test
public void testImportICal_icalFullDay() throws URISyntaxException, IOException {
    Identity test = JunitTestHelper.createAndPersistIdentityAsRndUser("ur3-");
    URL calendarUrl = ICalFileCalendarManagerTest.class.getResource("Fullday_ical.ics");
    File calendarFile = new File(calendarUrl.toURI());
    String calendarName = UUID.randomUUID().toString().replace("-", "");
    KalendarRenderWrapper importedCalendar = importCalendarManager.importCalendar(test, calendarName, CalendarManager.TYPE_USER, calendarFile);
    List<KalendarEvent> events = importedCalendar.getKalendar().getEvents();
    Assert.assertEquals(3, events.size());
    // 24 hours but on 2 days
    KalendarEvent on2days = importedCalendar.getKalendar().getEvent("EFE10508-15B0-4FCE-A258-37BA642B760D", null);
    Assert.assertFalse(on2days.isAllDayEvent());
    // real all day with the iCal standard
    KalendarEvent allDay = importedCalendar.getKalendar().getEvent("14C0ACCD-AC0B-4B10-A448-0BF129492091", null);
    Assert.assertTrue(allDay.isAllDayEvent());
    // almost a full day bit it miss one minute
    KalendarEvent longDay = importedCalendar.getKalendar().getEvent("C562E736-DCFF-4002-9E5B-77D891D4A322", null);
    Assert.assertFalse(longDay.isAllDayEvent());
}
Also used : KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) Identity(org.olat.core.id.Identity) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) File(java.io.File) URL(java.net.URL) CalendarImportTest(org.olat.commons.calendar.CalendarImportTest) Test(org.junit.Test)

Example 15 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class ICalFileCalendarManagerTest method testCalendarRecurringEventMissingEndDate.

/**
 * A recurring event with missing end date. This error
 * in the calendar cause the whole calendar to crash.
 *
 * @throws URISyntaxException
 * @throws IOException
 */
@Test
public void testCalendarRecurringEventMissingEndDate() throws URISyntaxException, IOException {
    Identity test = JunitTestHelper.createAndPersistIdentityAsRndUser("ur1-");
    URL calendarUrl = CalendarImportTest.class.getResource("RecurringEventMissingEnd.ics");
    File calendarFile = new File(calendarUrl.toURI());
    String calendarName = UUID.randomUUID().toString().replace("-", "");
    KalendarRenderWrapper importedCalendar = importCalendarManager.importCalendar(test, calendarName, CalendarManager.TYPE_USER, calendarFile);
    List<KalendarEvent> events = importedCalendar.getKalendar().getEvents();
    Assert.assertEquals(1, events.size());
    Calendar cal = Calendar.getInstance();
    cal.set(2018, 03, 10, 10, 00);
    Date startDate = cal.getTime();
    cal.set(2018, 03, 17);
    Date endDate = cal.getTime();
    List<KalendarEvent> recurringEvents = calendarManager.getEvents(importedCalendar.getKalendar(), startDate, endDate, true);
    Assert.assertEquals(0, recurringEvents.size());
}
Also used : Calendar(java.util.Calendar) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) Identity(org.olat.core.id.Identity) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) File(java.io.File) URL(java.net.URL) Date(java.util.Date) CalendarImportTest(org.olat.commons.calendar.CalendarImportTest) Test(org.junit.Test)

Aggregations

KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)134 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)46 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)28 Identity (org.olat.core.id.Identity)26 Date (java.util.Date)24 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)24 Calendar (java.util.Calendar)22 Kalendar (org.olat.commons.calendar.model.Kalendar)22 ICourse (org.olat.course.ICourse)20 File (java.io.File)18 BusinessGroup (org.olat.group.BusinessGroup)16 URI (java.net.URI)14 HttpResponse (org.apache.http.HttpResponse)14 CalendarImportTest (org.olat.commons.calendar.CalendarImportTest)14 URL (java.net.URL)12 EventVO (org.olat.commons.calendar.restapi.EventVO)12 CalendarManager (org.olat.commons.calendar.CalendarManager)10 HttpGet (org.apache.http.client.methods.HttpGet)8 UserRequest (org.olat.core.gui.UserRequest)8