use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.
the class RepositoryEntryLifecycleDAOTest method createLifeCycle.
@Test
public void createLifeCycle() {
String label = "My first life cycle";
String softKey = UUID.randomUUID().toString();
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DATE, -1);
Date from = cal.getTime();
cal.add(Calendar.DATE, +2);
Date to = cal.getTime();
RepositoryEntryLifecycle relf = reLifeCycleDao.create(label, softKey, true, from, to);
dbInstance.commitAndCloseSession();
// check
Assert.assertNotNull(relf);
Assert.assertNotNull(relf.getKey());
Assert.assertNotNull(relf.getCreationDate());
Assert.assertNotNull(relf.getLastModified());
Assert.assertEquals("My first life cycle", relf.getLabel());
Assert.assertEquals(softKey, relf.getSoftKey());
Assert.assertTrue(relf.isPrivateCycle());
Assert.assertEquals(from, relf.getValidFrom());
Assert.assertEquals(to, relf.getValidTo());
}
use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.
the class RepositoryEntryLifecycleDAOTest method loadPublicLifeCycles.
@Test
public void loadPublicLifeCycles() {
// create a public life cycle object
String label = "A public life cycle";
RepositoryEntryLifecycle publicRelf = reLifeCycleDao.create(label, null, false, null, null);
dbInstance.commitAndCloseSession();
// load public life cycle
List<RepositoryEntryLifecycle> publicLifeCycles = reLifeCycleDao.loadPublicLifecycle();
Assert.assertNotNull(publicLifeCycles);
Assert.assertFalse(publicLifeCycles.isEmpty());
Assert.assertTrue(publicLifeCycles.contains(publicRelf));
}
use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.
the class RepositoryEntryLifecycleDAOTest method loadLifeCycle_byEntry.
@Test
public void loadLifeCycle_byEntry() {
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry("", false);
String label = "A life cycle";
String softKey = UUID.randomUUID().toString();
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(Calendar.DATE, -1);
Date from = cal.getTime();
cal.add(Calendar.DATE, +2);
Date to = cal.getTime();
RepositoryEntryLifecycle cycle = reLifeCycleDao.create(label, softKey, true, from, to);
re.setLifecycle(cycle);
re = dbInstance.getCurrentEntityManager().merge(re);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(cycle);
Assert.assertNotNull(cycle.getKey());
// check
RepositoryEntryLifecycle loadedLifeCycle = reLifeCycleDao.loadByEntry(re);
Assert.assertNotNull(loadedLifeCycle);
Assert.assertNotNull(loadedLifeCycle.getCreationDate());
Assert.assertNotNull(loadedLifeCycle.getLastModified());
Assert.assertEquals(cycle.getKey(), loadedLifeCycle.getKey());
Assert.assertEquals("A life cycle", loadedLifeCycle.getLabel());
Assert.assertEquals(softKey, loadedLifeCycle.getSoftKey());
Assert.assertTrue(loadedLifeCycle.isPrivateCycle());
Assert.assertNotNull(loadedLifeCycle.getValidFrom());
Assert.assertNotNull(loadedLifeCycle.getValidTo());
}
use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.
the class GetCourseBeginDateFunction method call.
/**
* @see com.neemsoft.jmep.FunctionCB#call(java.lang.Object[])
*/
@Override
public Object call(Object[] inStack) {
CourseEditorEnv cev = getUserCourseEnv().getCourseEditorEnv();
if (cev != null) {
return defaultValue();
}
RepositoryEntryLifecycle lifecycle = getUserCourseEnv().getLifecycle();
if (lifecycle != null && lifecycle.getValidFrom() != null) {
return Double.valueOf(lifecycle.getValidFrom().getTime());
} else {
// what to do in case of no date available??? -> return date in the future
return new Double(Double.POSITIVE_INFINITY);
}
}
Aggregations