Search in sources :

Example 51 with RepositoryEntryLifecycle

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());
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) Calendar(java.util.Calendar) Date(java.util.Date) Test(org.junit.Test)

Example 52 with RepositoryEntryLifecycle

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));
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) Test(org.junit.Test)

Example 53 with RepositoryEntryLifecycle

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());
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) Calendar(java.util.Calendar) RepositoryEntry(org.olat.repository.RepositoryEntry) Date(java.util.Date) Test(org.junit.Test)

Example 54 with RepositoryEntryLifecycle

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);
    }
}
Also used : CourseEditorEnv(org.olat.course.editor.CourseEditorEnv) RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle)

Aggregations

RepositoryEntryLifecycle (org.olat.repository.model.RepositoryEntryLifecycle)54 Date (java.util.Date)34 Test (org.junit.Test)22 Calendar (java.util.Calendar)18 ArrayList (java.util.ArrayList)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 List (java.util.List)6 Identity (org.olat.core.id.Identity)6 RepositoryEntryLifecycleVO (org.olat.restapi.support.vo.RepositoryEntryLifecycleVO)6 Produces (javax.ws.rs.Produces)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 VFSContainer (org.olat.core.util.vfs.VFSContainer)4 ICourse (org.olat.course.ICourse)4 CourseEditorEnv (org.olat.course.editor.CourseEditorEnv)4 RepositoryEntryLifecycleDAO (org.olat.repository.manager.RepositoryEntryLifecycleDAO)4 LocalFileImpl (org.olat.core.util.vfs.LocalFileImpl)3 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)3 File (java.io.File)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2