Search in sources :

Example 31 with ReminderRule

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

the class ReminderRuleEngineTest method getPassedRules.

private List<ReminderRule> getPassedRules(String status, String nodeIdent) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(PassedRuleSPI.class.getSimpleName());
    rule.setLeftOperand(nodeIdent);
    rule.setOperator("=");
    rule.setRightOperand(status);
    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) PassedRuleSPI(org.olat.course.reminder.rule.PassedRuleSPI) ArrayList(java.util.ArrayList)

Example 32 with ReminderRule

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

the class CourseReminderEditController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String description = descriptionEl.getValue();
    reminder.setDescription(description);
    ReminderRules rules = new ReminderRules();
    for (RuleElement ruleEl : ruleEls) {
        ReminderRule rule = ruleEl.getEditor().getConfiguration();
        if (rule != null) {
            rules.getRules().add(rule);
        }
    }
    String configuration = reminderManager.toXML(rules);
    reminder.setConfiguration(configuration);
    String emailSubject = subjectEl.getValue();
    reminder.setEmailSubject(emailSubject);
    String emailBody = emailEl.getValue();
    reminder.setEmailBody(emailBody);
    reminder = reminderManager.save(reminder);
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRules(org.olat.modules.reminder.model.ReminderRules)

Example 33 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project openolat by klemens.

the class CourseHandler method cloneReminders.

private void cloneReminders(Identity author, CourseEnvironmentMapper envMapper, RepositoryEntry source, RepositoryEntry target) {
    ReminderModule reminderModule = CoreSpringFactory.getImpl(ReminderModule.class);
    ReminderService reminderService = CoreSpringFactory.getImpl(ReminderService.class);
    List<Reminder> reminders = reminderService.getReminders(source);
    for (Reminder reminder : reminders) {
        String configuration = reminder.getConfiguration();
        ReminderRules rules = reminderService.toRules(configuration);
        ReminderRules clonedRules = new ReminderRules();
        for (ReminderRule rule : rules.getRules()) {
            RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
            if (ruleSpi != null) {
                ReminderRule clonedRule = ruleSpi.clone(rule, envMapper);
                if (clonedRule != null)
                    clonedRules.getRules().add(clonedRule);
            }
        }
        Reminder clonedReminder = reminderService.createReminder(target, author);
        clonedReminder.setDescription(reminder.getDescription());
        clonedReminder.setEmailSubject(reminder.getEmailSubject());
        clonedReminder.setEmailBody(reminder.getEmailBody());
        clonedReminder.setConfiguration(reminderService.toXML(clonedRules));
        reminderService.save(clonedReminder);
    }
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) Reminder(org.olat.modules.reminder.Reminder) ReminderService(org.olat.modules.reminder.ReminderService) ReminderRules(org.olat.modules.reminder.model.ReminderRules) RuleSPI(org.olat.modules.reminder.RuleSPI) ReminderModule(org.olat.modules.reminder.ReminderModule)

Example 34 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project openolat by klemens.

the class CourseHandler method importReminders.

private void importReminders(RepositoryEntry re, File fImportBaseDirectory, CourseEnvironmentMapper envMapper, Identity initialAuthor) {
    ReminderModule reminderModule = CoreSpringFactory.getImpl(ReminderModule.class);
    ReminderService reminderService = CoreSpringFactory.getImpl(ReminderService.class);
    List<Reminder> reminders = reminderService.importRawReminders(initialAuthor, re, fImportBaseDirectory);
    if (reminders.size() > 0) {
        for (Reminder reminder : reminders) {
            ReminderRules clonedRules = new ReminderRules();
            String configuration = reminder.getConfiguration();
            ReminderRules rules = reminderService.toRules(configuration);
            for (ReminderRule rule : rules.getRules()) {
                RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
                if (ruleSpi != null) {
                    ReminderRule clonedRule = ruleSpi.clone(rule, envMapper);
                    clonedRules.getRules().add(clonedRule);
                }
            }
            String convertedConfiguration = reminderService.toXML(clonedRules);
            reminder.setConfiguration(convertedConfiguration);
            reminderService.save(reminder);
        }
    }
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) Reminder(org.olat.modules.reminder.Reminder) ReminderService(org.olat.modules.reminder.ReminderService) ReminderRules(org.olat.modules.reminder.model.ReminderRules) RuleSPI(org.olat.modules.reminder.RuleSPI) ReminderModule(org.olat.modules.reminder.ReminderModule)

Example 35 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project openolat by klemens.

the class ReminderRuleEngineTest method getPassedRules.

private List<ReminderRule> getPassedRules(String status, String nodeIdent) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(PassedRuleSPI.class.getSimpleName());
    rule.setLeftOperand(nodeIdent);
    rule.setOperator("=");
    rule.setRightOperand(status);
    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) PassedRuleSPI(org.olat.course.reminder.rule.PassedRuleSPI) ArrayList(java.util.ArrayList)

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