Search in sources :

Example 21 with Kalendar

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

the class LectureServiceImpl method syncInternalCalendar.

private void syncInternalCalendar(LectureBlock lectureBlock, List<Identity> identities) {
    RepositoryEntry entry = lectureBlock.getEntry();
    for (Identity identity : identities) {
        Kalendar cal = calendarMgr.getCalendar(CalendarManager.TYPE_USER, identity.getName());
        syncEvent(lectureBlock, entry, cal);
        lectureParticipantSummaryDao.updateCalendarSynchronization(entry, identity);
    }
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity)

Example 22 with Kalendar

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

the class CourseCalendarPeekViewController method init.

private void init(UserRequest ureq, CalCourseNode courseNode, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
    CourseCalendars myCal = CourseCalendars.createCourseCalendarsWrapper(ureq, getWindowControl(), courseEnv, ne);
    Date refDate;
    ModuleConfiguration config = courseNode.getModuleConfiguration();
    if (CalEditController.getAutoDate(config)) {
        refDate = new Date();
    } else {
        refDate = CalEditController.getStartDate(config);
        if (refDate == null)
            refDate = new Date();
    }
    List<KalendarEvent> nextEvents = new ArrayList<KalendarEvent>();
    for (KalendarRenderWrapper calendar : myCal.getCalendars()) {
        Kalendar cal = calendar.getKalendar();
        Collection<KalendarEvent> events = cal.getEvents();
        for (KalendarEvent event : events) {
            if (refDate.compareTo(event.getBegin()) <= 0) {
                nextEvents.add(event);
            }
        }
    }
    Collections.sort(nextEvents, new KalendarEventComparator());
    List<KalendarEvent> nextThreeEvents = nextEvents.subList(0, Math.min(3, nextEvents.size()));
    TableGuiConfiguration tableConfig = new TableGuiConfiguration();
    tableConfig.setTableEmptyMessage(translate("calendar.noEvents"));
    tableConfig.setDisplayTableHeader(false);
    tableConfig.setCustomCssClass("o_portlet_table");
    tableConfig.setDisplayRowCount(false);
    tableConfig.setPageingEnabled(false);
    tableConfig.setDownloadOffered(false);
    tableConfig.setSortingEnabled(false);
    removeAsListenerAndDispose(tableController);
    tableController = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    listenTo(tableController);
    // dummy header key, won't be used since setDisplayTableHeader is set to
    // false
    tableController.addColumnDescriptor(new DefaultColumnDescriptor("calendar.date", 0, null, ureq.getLocale()));
    tableController.addColumnDescriptor(new DefaultColumnDescriptor("calendar.subject", 1, null, ureq.getLocale(), ColumnDescriptor.ALIGNMENT_LEFT));
    tableController.setTableDataModel(new CourseCalendarPeekViewModel(nextThreeEvents, getTranslator()));
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) TableController(org.olat.core.gui.components.table.TableController) ArrayList(java.util.ArrayList) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) Date(java.util.Date) Kalendar(org.olat.commons.calendar.model.Kalendar) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 23 with Kalendar

use of org.olat.commons.calendar.model.Kalendar 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 24 with Kalendar

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

the class CalendarUserConfigurationDAOTest method createConfiguration.

@Test
public void createConfiguration() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Cal-1");
    String calendarId = UUID.randomUUID().toString();
    Kalendar calendar = new Kalendar(calendarId, CalendarManager.TYPE_USER);
    CalendarUserConfiguration config = calendarDao.createCalendarUserConfiguration(calendar, user);
    dbInstance.commit();
    Assert.assertNotNull(config);
    Assert.assertNotNull(config.getKey());
    Assert.assertNotNull(config.getCreationDate());
    Assert.assertNotNull(config.getLastModified());
    Assert.assertEquals(calendarId, config.getCalendarId());
    Assert.assertEquals(CalendarManager.TYPE_USER, config.getType());
    Assert.assertEquals(user, config.getIdentity());
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 25 with Kalendar

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

the class CalendarUserConfigurationDAOTest method getCalendarUserConfigurations.

@Test
public void getCalendarUserConfigurations() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Cal-2");
    String calendarId = UUID.randomUUID().toString();
    Kalendar calendar = new Kalendar(calendarId, CalendarManager.TYPE_COURSE);
    CalendarUserConfiguration config = calendarDao.createCalendarUserConfiguration(calendar, user);
    dbInstance.commit();
    Assert.assertNotNull(config);
    // retrieve
    List<CalendarUserConfiguration> configList = calendarDao.getCalendarUserConfigurations(user);
    Assert.assertNotNull(configList);
    Assert.assertEquals(1, configList.size());
    Assert.assertEquals(config, configList.get(0));
    // paranoia check
    CalendarUserConfiguration loadedConfig = configList.get(0);
    Assert.assertNotNull(loadedConfig.getCreationDate());
    Assert.assertNotNull(loadedConfig.getLastModified());
    Assert.assertEquals(config.getKey(), loadedConfig.getKey());
    Assert.assertEquals(calendarId, loadedConfig.getCalendarId());
    Assert.assertEquals(CalendarManager.TYPE_COURSE, loadedConfig.getType());
    Assert.assertEquals(user, loadedConfig.getIdentity());
    Assert.assertTrue(loadedConfig.isVisible());
    Assert.assertTrue(loadedConfig.isInAggregatedFeed());
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

Kalendar (org.olat.commons.calendar.model.Kalendar)126 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)68 Identity (org.olat.core.id.Identity)40 Date (java.util.Date)38 Test (org.junit.Test)26 CalendarManager (org.olat.commons.calendar.CalendarManager)24 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)22 ArrayList (java.util.ArrayList)20 CalendarImportTest (org.olat.commons.calendar.CalendarImportTest)20 OLATResourceable (org.olat.core.id.OLATResourceable)20 CalendarGUIModifiedEvent (org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)18 Calendar (java.util.Calendar)14 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)12 URISyntaxException (java.net.URISyntaxException)10 ParseException (java.text.ParseException)10 ExDate (net.fortuna.ical4j.model.property.ExDate)10 IOException (java.io.IOException)8 InputStream (java.io.InputStream)8 ICourse (org.olat.course.ICourse)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8