Search in sources :

Example 26 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project OpenOLAT by OpenOLAT.

the class ReminderRuleEngineTest method getRepositoryEntryLifecycleRuleValidFromRule.

private List<ReminderRule> getRepositoryEntryLifecycleRuleValidFromRule(int amount, LaunchUnit unit) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(RepositoryEntryLifecycleAfterValidFromRuleSPI.class.getSimpleName());
    rule.setOperator(">");
    rule.setRightOperand(Integer.toString(amount));
    rule.setRightUnit(unit.name());
    List<ReminderRule> rules = new ArrayList<>(1);
    rules.add(rule);
    return rules;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) ArrayList(java.util.ArrayList) RepositoryEntryLifecycleAfterValidFromRuleSPI(org.olat.modules.reminder.rule.RepositoryEntryLifecycleAfterValidFromRuleSPI)

Example 27 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project OpenOLAT by OpenOLAT.

the class ReminderRuleEngineTest method dateRule.

@Test
public void dateRule() {
    Calendar cal = Calendar.getInstance();
    // check rule with date in the past
    List<ReminderRule> rulePastList = new ArrayList<>();
    ReminderRuleImpl pastRule = new ReminderRuleImpl();
    pastRule.setType(DateRuleSPI.class.getSimpleName());
    pastRule.setOperator(DateRuleSPI.AFTER);
    cal.add(Calendar.HOUR_OF_DAY, -4);
    pastRule.setRightOperand(Formatter.formatDatetime(cal.getTime()));
    rulePastList.add(pastRule);
    boolean pastEval = ruleEngine.evaluateDateRule(rulePastList);
    Assert.assertTrue(pastEval);
    // check rule with date in the future
    List<ReminderRule> ruleFutureList = new ArrayList<>();
    ReminderRuleImpl futureRule = new ReminderRuleImpl();
    futureRule.setType(DateRuleSPI.class.getSimpleName());
    futureRule.setOperator(DateRuleSPI.AFTER);
    cal.add(Calendar.DATE, 4);
    futureRule.setRightOperand(Formatter.formatDatetime(cal.getTime()));
    ruleFutureList.add(futureRule);
    boolean futureEval = ruleEngine.evaluateDateRule(ruleFutureList);
    Assert.assertFalse(futureEval);
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) CourseEnrollmentDateRuleSPI(org.olat.modules.reminder.rule.CourseEnrollmentDateRuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 28 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project OpenOLAT by OpenOLAT.

the class ReminderRuleEngineTest method getRecentLaunchRules.

private List<ReminderRule> getRecentLaunchRules(int amount, LaunchUnit unit) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(RecentCourseLaunchRuleSPI.class.getSimpleName());
    rule.setOperator(">");
    rule.setRightOperand(Integer.toString(amount));
    rule.setRightUnit(unit.name());
    List<ReminderRule> rules = new ArrayList<>(1);
    rules.add(rule);
    return rules;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) ArrayList(java.util.ArrayList) RecentCourseLaunchRuleSPI(org.olat.modules.reminder.rule.RecentCourseLaunchRuleSPI)

Example 29 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project OpenOLAT by OpenOLAT.

the class ReminderRuleEngineTest method getInitialAttemptsRules.

private List<ReminderRule> getInitialAttemptsRules(int value, String unit, String nodeIdent) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(InitialAttemptsRuleSPI.class.getSimpleName());
    rule.setLeftOperand(nodeIdent);
    rule.setOperator(">");
    rule.setRightOperand(Integer.toString(value));
    rule.setRightUnit(unit);
    List<ReminderRule> rules = new ArrayList<>(1);
    rules.add(rule);
    return rules;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) ArrayList(java.util.ArrayList) InitialAttemptsRuleSPI(org.olat.course.reminder.rule.InitialAttemptsRuleSPI)

Example 30 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project OpenOLAT by OpenOLAT.

the class ReminderRuleEngineTest method getRepositoryEntryLifecycleRuleValidToRule.

private List<ReminderRule> getRepositoryEntryLifecycleRuleValidToRule(int amount, LaunchUnit unit) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(RepositoryEntryLifecycleAfterValidToRuleSPI.class.getSimpleName());
    rule.setOperator(">");
    rule.setRightOperand(Integer.toString(amount));
    rule.setRightUnit(unit.name());
    List<ReminderRule> rules = new ArrayList<>(1);
    rules.add(rule);
    return rules;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) ArrayList(java.util.ArrayList) RepositoryEntryLifecycleAfterValidToRuleSPI(org.olat.modules.reminder.rule.RepositoryEntryLifecycleAfterValidToRuleSPI)

Aggregations

ReminderRule (org.olat.modules.reminder.ReminderRule)46 ArrayList (java.util.ArrayList)32 ReminderRuleImpl (org.olat.modules.reminder.model.ReminderRuleImpl)26 RuleSPI (org.olat.modules.reminder.RuleSPI)12 ReminderRules (org.olat.modules.reminder.model.ReminderRules)12 DateRuleSPI (org.olat.modules.reminder.rule.DateRuleSPI)10 RepositoryEntryRoleRuleSPI (org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI)8 UserPropertyRuleSPI (org.olat.modules.reminder.rule.UserPropertyRuleSPI)8 Identity (org.olat.core.id.Identity)6 FilterRuleSPI (org.olat.modules.reminder.FilterRuleSPI)6 IdentitiesProviderRuleSPI (org.olat.modules.reminder.IdentitiesProviderRuleSPI)6 RepositoryEntryRuleSPI (org.olat.modules.reminder.RepositoryEntryRuleSPI)6 BusinessGroupRoleRuleSPI (org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI)6 InitialAttemptsRuleSPI (org.olat.course.reminder.rule.InitialAttemptsRuleSPI)4 Reminder (org.olat.modules.reminder.Reminder)4 ReminderModule (org.olat.modules.reminder.ReminderModule)4 ReminderService (org.olat.modules.reminder.ReminderService)4 CourseEnrollmentDateRuleSPI (org.olat.modules.reminder.rule.CourseEnrollmentDateRuleSPI)4 ParseException (java.text.ParseException)2 Calendar (java.util.Calendar)2