use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManagerTest method testPersistCalendarWithoutDTEndEvent.
/**
* Check a NPE
* @throws IOException
*/
@Test
public void testPersistCalendarWithoutDTEndEvent() throws IOException {
// replace the standard calendar with a forged one
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("cal-test-1-");
File calendarFile = calendarManager.getCalendarFile("user", identity.getName());
if (calendarFile.exists()) {
calendarFile.delete();
}
File newCalendarFile = new File(calendarFile.getParentFile(), calendarFile.getName());
InputStream in = CalendarImportTest.class.getResourceAsStream("cal_without_dtend.ics");
FileUtils.copyInputStreamToFile(in, newCalendarFile);
// to be sure
emptyCalendarCache();
// load the calendar
KalendarRenderWrapper reloadCalWrapper = calendarManager.getPersonalCalendar(identity);
// check if its the right calendar
Collection<KalendarEvent> events = reloadCalWrapper.getKalendar().getEvents();
Assert.assertNotNull(events);
Assert.assertEquals(1, events.size());
KalendarEvent event = events.iterator().next();
Assert.assertEquals("Arbeitszeit: 1-3h", event.getSubject());
Assert.assertNull(event.getEnd());
Assert.assertFalse(event.isToday());
Assert.assertTrue(event.isWithinOneDay());
Assert.assertFalse(event.isAllDayEvent());
// test persist
boolean allOk = calendarManager.persistCalendar(reloadCalWrapper.getKalendar());
Assert.assertTrue(allOk);
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManagerTest method testImportICal_recurringEvent.
@Test
public void testImportICal_recurringEvent() throws URISyntaxException, IOException {
Identity test = JunitTestHelper.createAndPersistIdentityAsRndUser("ur1-");
URL calendarUrl = CalendarImportTest.class.getResource("RecurringEvent.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(2, events.size());
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManagerTest method testImportICal_outlookFullDay.
@Test
public void testImportICal_outlookFullDay() throws URISyntaxException, IOException {
Identity test = JunitTestHelper.createAndPersistIdentityAsRndUser("ur2-");
URL calendarUrl = ICalFileCalendarManagerTest.class.getResource("Fullday_outlook.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());
KalendarEvent event = events.get(0);
Assert.assertTrue(event.isAllDayEvent());
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class WeeklyCalendarController method getCallerKalendarRenderWrapper.
private KalendarRenderWrapper getCallerKalendarRenderWrapper() {
if (callerOres == null || calendarWrappers == null)
return null;
String callerResId = callerOres.getResourceableId().toString();
for (KalendarRenderWrapper calendarWrapper : calendarWrappers) {
String calendarType = calendarWrapper.getKalendar().getType();
String calendarId = calendarWrapper.getKalendar().getCalendarID();
if (callerResId.equals(calendarId)) {
if ((WeeklyCalendarController.CALLER_COLLAB.equals(caller) && CalendarManager.TYPE_GROUP.equals(calendarType)) || (WeeklyCalendarController.CALLER_COURSE.equals(caller) && CalendarManager.TYPE_COURSE.equals(calendarType))) {
return calendarWrapper;
}
} else if ((WeeklyCalendarController.CALLER_PROFILE.equals(caller) || WeeklyCalendarController.CALLER_HOME.equals(caller)) && CalendarManager.TYPE_USER.equals(calendarType) && calendarId.equals(callerOres.getResourceableTypeName())) {
return calendarWrapper;
}
}
return null;
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class WeeklyCalendarController method doConfigure.
private void doConfigure(UserRequest ureq) {
removeAsListenerAndDispose(cmc);
removeAsListenerAndDispose(configurationCtrl);
KalendarRenderWrapper alwaysVisibleKalendar = getCallerKalendarRenderWrapper();
List<KalendarRenderWrapper> allCalendars = new ArrayList<>(calendarWrappers);
configurationCtrl = new CalendarPersonalConfigurationController(ureq, getWindowControl(), allCalendars, alwaysVisibleKalendar, allowImport);
listenTo(configurationCtrl);
String title = translate("cal.configuration.list");
cmc = new CloseableModalController(getWindowControl(), "c", configurationCtrl.getInitialComponent(), true, title);
cmc.setContextHelp(getTranslator(), "Calendar");
listenTo(cmc);
cmc.activate();
}
Aggregations