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;
}
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);
}
}
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());
}
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());
}
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);
}
}
Aggregations