Search in sources :

Example 11 with CalendarUserConfiguration

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

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

the class OLATUpgrade_10_4_0 method processKalendarConfig.

private void processKalendarConfig(Identity identity, String calendarId, KalendarConfig config) {
    Kalendar cal;
    CalendarUserConfiguration userConfig;
    if (StringHelper.isLong(calendarId)) {
        // guess if it's a course or a group calendar
        if (calendarMgr.getCalendarFile(CalendarManager.TYPE_COURSE, calendarId) != null) {
            cal = new Kalendar(calendarId, CalendarManager.TYPE_COURSE);
        } else if (calendarMgr.getCalendarFile(CalendarManager.TYPE_GROUP, calendarId) != null) {
            cal = new Kalendar(calendarId, CalendarManager.TYPE_GROUP);
        } else {
            return;
        }
    } else {
        // personal calendar
        cal = new Kalendar(calendarId, CalendarManager.TYPE_USER);
    }
    userConfig = calendarUserConfigurationDao.getCalendarUserConfiguration(identity, cal.getCalendarID(), cal.getType());
    if (userConfig == null) {
        userConfig = calendarUserConfigurationDao.createCalendarUserConfiguration(cal, identity);
        userConfig.setCssClass(config.getCss());
        userConfig.setVisible(config.isVis());
        userConfig = calendarUserConfigurationDao.update(userConfig);
    }
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration)

Example 13 with CalendarUserConfiguration

use of org.olat.commons.calendar.model.CalendarUserConfiguration in project openolat by klemens.

the class CalendarUserConfigurationDAOTest method getCalendarUserConfigurations_byTypes.

@Test
public void getCalendarUserConfigurations_byTypes() {
    Identity user = JunitTestHelper.createAndPersistIdentityAsRndUser("Cal-3");
    String calendarId = UUID.randomUUID().toString();
    Kalendar courseCalendar = new Kalendar(calendarId, CalendarManager.TYPE_COURSE);
    CalendarUserConfiguration courseCalConfig = calendarDao.createCalendarUserConfiguration(courseCalendar, user);
    Kalendar groupCalendar = new Kalendar(calendarId, CalendarManager.TYPE_GROUP);
    CalendarUserConfiguration groupCalConfig = calendarDao.createCalendarUserConfiguration(groupCalendar, user);
    Kalendar personalCalendar = new Kalendar(user.getName(), CalendarManager.TYPE_USER);
    CalendarUserConfiguration personalCalConfig = calendarDao.createCalendarUserConfiguration(personalCalendar, user);
    dbInstance.commit();
    Assert.assertNotNull(courseCalConfig);
    // get all
    List<CalendarUserConfiguration> configList = calendarDao.getCalendarUserConfigurations(user);
    Assert.assertNotNull(configList);
    Assert.assertEquals(3, configList.size());
    Assert.assertTrue(configList.contains(courseCalConfig));
    Assert.assertTrue(configList.contains(groupCalConfig));
    Assert.assertTrue(configList.contains(personalCalConfig));
    // get course
    List<CalendarUserConfiguration> courseConfigList = calendarDao.getCalendarUserConfigurations(user, CalendarManager.TYPE_COURSE);
    Assert.assertNotNull(courseConfigList);
    Assert.assertEquals(1, courseConfigList.size());
    Assert.assertTrue(courseConfigList.contains(courseCalConfig));
    // null check
    List<CalendarUserConfiguration> nullConfigList = calendarDao.getCalendarUserConfigurations(user, (String) null);
    Assert.assertNotNull(nullConfigList);
    Assert.assertEquals(3, nullConfigList.size());
}
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 14 with CalendarUserConfiguration

use of org.olat.commons.calendar.model.CalendarUserConfiguration in project openolat by klemens.

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 15 with CalendarUserConfiguration

use of org.olat.commons.calendar.model.CalendarUserConfiguration in project openolat by klemens.

the class OLATUpgrade_10_4_0 method processCalendarProperty.

private void processCalendarProperty(Property property) {
    String calendarId;
    Identity identity = property.getIdentity();
    String resourceType = property.getResourceTypeName();
    if (StringHelper.containsNonWhitespace(resourceType) && property.getResourceTypeId() != null) {
        calendarId = property.getResourceTypeId().toString();
    } else {
        resourceType = CalendarManager.TYPE_USER;
        calendarId = identity.getName();
    }
    CalendarUserConfiguration config = calendarUserConfigurationDao.getCalendarUserConfiguration(identity, calendarId, resourceType);
    if (config == null) {
        String token = property.getStringValue();
        Kalendar mockCal = new Kalendar(calendarId, resourceType);
        calendarUserConfigurationDao.createCalendarUserConfiguration(mockCal, identity, token, true, true);
    }
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) Identity(org.olat.core.id.Identity)

Aggregations

CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)46 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)24 Kalendar (org.olat.commons.calendar.model.Kalendar)12 Identity (org.olat.core.id.Identity)12 ArrayList (java.util.ArrayList)10 BusinessGroup (org.olat.group.BusinessGroup)10 CalendarKey (org.olat.commons.calendar.model.CalendarKey)8 Test (org.junit.Test)6 CalendarManager (org.olat.commons.calendar.CalendarManager)6 CorruptedCourseException (org.olat.course.CorruptedCourseException)6 ICourse (org.olat.course.ICourse)6 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 CollaborationTools (org.olat.collaboration.CollaborationTools)4 CollaborationToolsFactory (org.olat.collaboration.CollaborationToolsFactory)4 Roles (org.olat.core.id.Roles)4 CourseGroupManager (org.olat.course.groupsandrights.CourseGroupManager)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 File (java.io.File)2 URISyntaxException (java.net.URISyntaxException)2