Search in sources :

Example 11 with RuleSPI

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

the class ReminderRuleEngine method evaluateRepositoryEntryRule.

/**
 * @param reminder
 */
protected boolean evaluateRepositoryEntryRule(RepositoryEntry entry, List<ReminderRule> ruleList) {
    boolean allOk = true;
    for (Iterator<ReminderRule> ruleIt = ruleList.iterator(); ruleIt.hasNext(); ) {
        ReminderRule rule = ruleIt.next();
        RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
        if (ruleSpi instanceof RepositoryEntryRuleSPI) {
            allOk &= ((RepositoryEntryRuleSPI) ruleSpi).evaluate(entry, rule);
            ruleIt.remove();
        }
    }
    return allOk;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) RepositoryEntryRuleSPI(org.olat.modules.reminder.RepositoryEntryRuleSPI) FilterRuleSPI(org.olat.modules.reminder.FilterRuleSPI) RepositoryEntryRoleRuleSPI(org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI) UserPropertyRuleSPI(org.olat.modules.reminder.rule.UserPropertyRuleSPI) IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) RuleSPI(org.olat.modules.reminder.RuleSPI) RepositoryEntryRuleSPI(org.olat.modules.reminder.RepositoryEntryRuleSPI) BusinessGroupRoleRuleSPI(org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI)

Example 12 with RuleSPI

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

the class ReminderRuleEngine method filterByRules.

protected void filterByRules(RepositoryEntry entry, List<Identity> identities, List<ReminderRule> ruleList) {
    List<ReminderRule> filterRules = new ArrayList<>(3);
    for (Iterator<ReminderRule> ruleIt = ruleList.iterator(); ruleIt.hasNext(); ) {
        ReminderRule rule = ruleIt.next();
        RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
        if (ruleSpi instanceof FilterRuleSPI) {
            filterRules.add(rule);
            ruleIt.remove();
        }
    }
    for (ReminderRule rule : filterRules) {
        filterByRule(entry, identities, rule);
    }
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) FilterRuleSPI(org.olat.modules.reminder.FilterRuleSPI) RepositoryEntryRoleRuleSPI(org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI) UserPropertyRuleSPI(org.olat.modules.reminder.rule.UserPropertyRuleSPI) IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) RuleSPI(org.olat.modules.reminder.RuleSPI) RepositoryEntryRuleSPI(org.olat.modules.reminder.RepositoryEntryRuleSPI) BusinessGroupRoleRuleSPI(org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) ArrayList(java.util.ArrayList) FilterRuleSPI(org.olat.modules.reminder.FilterRuleSPI)

Example 13 with RuleSPI

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

the class ReminderRuleEngine method filterByRule.

public void filterByRule(RepositoryEntry entry, List<Identity> identities, ReminderRule rule) {
    try {
        RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
        if (ruleSpi instanceof FilterRuleSPI) {
            FilterRuleSPI filter = (FilterRuleSPI) ruleSpi;
            filter.filter(entry, identities, rule);
        }
    } catch (Exception e) {
        log.error("", e);
    }
}
Also used : FilterRuleSPI(org.olat.modules.reminder.FilterRuleSPI) RepositoryEntryRoleRuleSPI(org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI) UserPropertyRuleSPI(org.olat.modules.reminder.rule.UserPropertyRuleSPI) IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) RuleSPI(org.olat.modules.reminder.RuleSPI) RepositoryEntryRuleSPI(org.olat.modules.reminder.RepositoryEntryRuleSPI) BusinessGroupRoleRuleSPI(org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) FilterRuleSPI(org.olat.modules.reminder.FilterRuleSPI)

Example 14 with RuleSPI

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

the class CourseReminderEditController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source instanceof SingleSelection) {
        RuleElement panelToUpdate = null;
        for (RuleElement ruleEl : ruleEls) {
            if (source == ruleEl.getTypeEl()) {
                panelToUpdate = ruleEl;
            }
        }
        if (panelToUpdate != null) {
            SingleSelection typeEl = (SingleSelection) source;
            RuleSPI type = reminderModule.getRuleSPIByType(typeEl.getSelectedKey());
            doUpdateRuleForm(ureq, panelToUpdate, type);
        }
    } else if (source instanceof FormLink) {
        FormLink button = (FormLink) source;
        String cmd = button.getCmd();
        if ("add".equals(cmd)) {
            doAddRule(ureq, (RuleElement) button.getUserObject());
        } else if ("delete".equals(cmd)) {
            doDeleteRule(ureq, (RuleElement) button.getUserObject());
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) RuleSPI(org.olat.modules.reminder.RuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 15 with RuleSPI

use of org.olat.modules.reminder.RuleSPI 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)

Aggregations

RuleSPI (org.olat.modules.reminder.RuleSPI)22 DateRuleSPI (org.olat.modules.reminder.rule.DateRuleSPI)18 ReminderRule (org.olat.modules.reminder.ReminderRule)12 FilterRuleSPI (org.olat.modules.reminder.FilterRuleSPI)10 IdentitiesProviderRuleSPI (org.olat.modules.reminder.IdentitiesProviderRuleSPI)10 RepositoryEntryRuleSPI (org.olat.modules.reminder.RepositoryEntryRuleSPI)10 BusinessGroupRoleRuleSPI (org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI)10 RepositoryEntryRoleRuleSPI (org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI)10 UserPropertyRuleSPI (org.olat.modules.reminder.rule.UserPropertyRuleSPI)10 ArrayList (java.util.ArrayList)6 ReminderRules (org.olat.modules.reminder.model.ReminderRules)6 Identity (org.olat.core.id.Identity)4 Reminder (org.olat.modules.reminder.Reminder)4 ReminderModule (org.olat.modules.reminder.ReminderModule)4 ReminderService (org.olat.modules.reminder.ReminderService)4 HashSet (java.util.HashSet)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2