use of org.olat.commons.calendar.model.ImportedToCalendar in project OpenOLAT by OpenOLAT.
the class ImportedToCalendarDAO method createImportedToCalendar.
public ImportedToCalendar createImportedToCalendar(String toCalendarId, String toType, String url, Date lastUpdate) {
ImportedToCalendar calendar = new ImportedToCalendar();
calendar.setCreationDate(new Date());
calendar.setLastModified(calendar.getCreationDate());
calendar.setLastUpdate(lastUpdate);
calendar.setToCalendarId(toCalendarId);
calendar.setToType(toType);
calendar.setUrl(url);
dbInstance.getCurrentEntityManager().persist(calendar);
return calendar;
}
use of org.olat.commons.calendar.model.ImportedToCalendar in project OpenOLAT by OpenOLAT.
the class ImportedToCalendarDAO method delete.
public void delete(ImportedToCalendar importedToCalendar) {
ImportedToCalendar reloadedImportedToCalendar = dbInstance.getCurrentEntityManager().getReference(ImportedToCalendar.class, importedToCalendar.getKey());
dbInstance.getCurrentEntityManager().remove(reloadedImportedToCalendar);
}
use of org.olat.commons.calendar.model.ImportedToCalendar in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_10_4_0 method processImportedCalendarsTo.
private void processImportedCalendarsTo(Property property) {
// the calendar are imported in an existent calendar
// urls are | separated
String calendarId = property.getName();
String type = property.getResourceTypeName();
if ("user".equals(type)) {
// don't convert this, they have there own synchronization mechanism
return;
}
String importUrls = property.getTextValue();
if (StringHelper.containsNonWhitespace(importUrls) && StringHelper.containsNonWhitespace(calendarId) && StringHelper.containsNonWhitespace(type)) {
for (StringTokenizer tokenizer = new StringTokenizer(importUrls, "|"); tokenizer.hasMoreTokens(); ) {
String importUrl = tokenizer.nextToken();
List<ImportedToCalendar> currentCalendars = importedToCalendarDao.getImportedToCalendars(calendarId, type, importUrl);
if (currentCalendars.isEmpty()) {
Date importDate;
if (property.getLongValue() != null) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(property.getLongValue().longValue());
importDate = calendar.getTime();
} else {
importDate = new Date();
}
importedToCalendarDao.createImportedToCalendar(calendarId, type, importUrl, importDate);
}
}
}
}
use of org.olat.commons.calendar.model.ImportedToCalendar in project OpenOLAT by OpenOLAT.
the class ImportedToCalendarDAOTest method getImportedToCalendars_byCalendarIdTypeAndUrl.
@Test
public void getImportedToCalendars_byCalendarIdTypeAndUrl() {
String toCalendarId = UUID.randomUUID().toString();
String toType = "to-rnd-2";
String url = "http://www.openolat.org/importedto/calendar2.ics";
ImportedToCalendar importToCalendar = importedToCalendarDao.createImportedToCalendar(toCalendarId, toType, url, new Date());
dbInstance.commitAndCloseSession();
Assert.assertNotNull(importToCalendar);
List<ImportedToCalendar> loadedToCalendars = importedToCalendarDao.getImportedToCalendars(toCalendarId, toType, url);
Assert.assertNotNull(loadedToCalendars);
Assert.assertEquals(1, loadedToCalendars.size());
Assert.assertTrue(loadedToCalendars.contains(importToCalendar));
// paranoia check
ImportedToCalendar loadedToCalendar = loadedToCalendars.get(0);
Assert.assertEquals(importToCalendar, loadedToCalendar);
Assert.assertEquals(importToCalendar.getKey(), loadedToCalendar.getKey());
Assert.assertNotNull(loadedToCalendar.getCreationDate());
Assert.assertNotNull(loadedToCalendar.getLastModified());
Assert.assertNotNull(loadedToCalendar.getLastUpdate());
Assert.assertEquals(toCalendarId, loadedToCalendar.getToCalendarId());
Assert.assertEquals(toType, loadedToCalendar.getToType());
Assert.assertEquals(url, loadedToCalendar.getUrl());
}
use of org.olat.commons.calendar.model.ImportedToCalendar in project openolat by klemens.
the class ImportedToCalendarDAOTest method getImportedToCalendars_byCalendarIdTypeAndUrl.
@Test
public void getImportedToCalendars_byCalendarIdTypeAndUrl() {
String toCalendarId = UUID.randomUUID().toString();
String toType = "to-rnd-2";
String url = "http://www.openolat.org/importedto/calendar2.ics";
ImportedToCalendar importToCalendar = importedToCalendarDao.createImportedToCalendar(toCalendarId, toType, url, new Date());
dbInstance.commitAndCloseSession();
Assert.assertNotNull(importToCalendar);
List<ImportedToCalendar> loadedToCalendars = importedToCalendarDao.getImportedToCalendars(toCalendarId, toType, url);
Assert.assertNotNull(loadedToCalendars);
Assert.assertEquals(1, loadedToCalendars.size());
Assert.assertTrue(loadedToCalendars.contains(importToCalendar));
// paranoia check
ImportedToCalendar loadedToCalendar = loadedToCalendars.get(0);
Assert.assertEquals(importToCalendar, loadedToCalendar);
Assert.assertEquals(importToCalendar.getKey(), loadedToCalendar.getKey());
Assert.assertNotNull(loadedToCalendar.getCreationDate());
Assert.assertNotNull(loadedToCalendar.getLastModified());
Assert.assertNotNull(loadedToCalendar.getLastUpdate());
Assert.assertEquals(toCalendarId, loadedToCalendar.getToCalendarId());
Assert.assertEquals(toType, loadedToCalendar.getToType());
Assert.assertEquals(url, loadedToCalendar.getUrl());
}
Aggregations