Search in sources :

Example 16 with RepositoryEntryLifecycle

use of org.olat.repository.model.RepositoryEntryLifecycle in project OpenOLAT by OpenOLAT.

the class LifecycleAdminController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == createLifeCycle) {
        doEdit(ureq, null);
    } else if (source == tableEl) {
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            if ("delete-lifecycle".equals(se.getCommand())) {
                RepositoryEntryLifecycle row = model.getObject(se.getIndex());
                doConfirmDelete(ureq, row);
            } else if ("edit-lifecycle".equals(se.getCommand())) {
                RepositoryEntryLifecycle row = model.getObject(se.getIndex());
                doEdit(ureq, row);
            }
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)

Example 17 with RepositoryEntryLifecycle

use of org.olat.repository.model.RepositoryEntryLifecycle in project OpenOLAT by OpenOLAT.

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)

Example 18 with RepositoryEntryLifecycle

use of org.olat.repository.model.RepositoryEntryLifecycle in project OpenOLAT by OpenOLAT.

the class GetCourseEndDateFunction 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.getValidTo() != null) {
        Double end = Double.valueOf(lifecycle.getValidTo().getTime());
        return end;
    } 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)

Example 19 with RepositoryEntryLifecycle

use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.

the class GetCourseEndDateFunction 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.getValidTo() != null) {
        Double end = Double.valueOf(lifecycle.getValidTo().getTime());
        return end;
    } 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)

Example 20 with RepositoryEntryLifecycle

use of org.olat.repository.model.RepositoryEntryLifecycle in project openolat by klemens.

the class ReminderRuleEngineTest method afterBeginDate.

@Test
public void afterBeginDate() {
    // create a course with 3 members
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("before-begin-1");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("before-begin-2");
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("before-begin-3");
    ICourse course = CoursesWebService.createEmptyCourse(null, "initial-launch-dates", "course long name", null);
    RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
    Calendar cal = Calendar.getInstance();
    // now
    cal.setTime(new Date());
    cal.add(Calendar.DATE, -21);
    Date validFrom = cal.getTime();
    cal.add(Calendar.DATE, 90);
    Date validTo = cal.getTime();
    RepositoryEntryLifecycle cycle = lifecycleDao.create("Cycle 1", "Cycle soft 1", false, validFrom, validTo);
    re = repositoryManager.setDescriptionAndName(re, null, null, null, null, null, null, null, cycle);
    repositoryEntryRelationDao.addRole(id1, re, GroupRoles.owner.name());
    repositoryEntryRelationDao.addRole(id2, re, GroupRoles.coach.name());
    repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name());
    dbInstance.commit();
    {
        // check after 2 days
        List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(2, LaunchUnit.day);
        boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
        Assert.assertTrue(match);
    }
    {
        // check after 7 days (between begin and and date)
        List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(7, LaunchUnit.day);
        boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
        Assert.assertTrue(match);
    }
    {
        // check after 2 week s
        List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(2, LaunchUnit.week);
        boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
        Assert.assertTrue(match);
    }
    {
        // check after 21 days
        List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(21, LaunchUnit.day);
        boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
        Assert.assertTrue(match);
    }
    {
        // check after 3 weeks
        List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(3, LaunchUnit.week);
        boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
        Assert.assertTrue(match);
    }
    {
        // check after 22 days
        List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(22, LaunchUnit.day);
        boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
        Assert.assertFalse(match);
    }
    {
        // check after 4 weeks
        List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(4, LaunchUnit.week);
        boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
        Assert.assertFalse(match);
    }
    {
        // check after 1 month
        List<ReminderRule> rules = getRepositoryEntryLifecycleRuleValidFromRule(1, LaunchUnit.month);
        boolean match = ruleEngine.evaluateRepositoryEntryRule(re, rules);
        Assert.assertFalse(match);
    }
}
Also used : RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) Calendar(java.util.Calendar) ICourse(org.olat.course.ICourse) List(java.util.List) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

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