Search in sources :

Example 16 with RuleSPI

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

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

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 18 with RuleSPI

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

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 19 with RuleSPI

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

the class ReminderRuleEngine method getMembers.

public List<Identity> getMembers(RepositoryEntry entry, ReminderRule rule) {
    List<Identity> members = new ArrayList<>();
    try {
        RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
        IdentitiesProviderRuleSPI identitiesProviderRuleSpi = (IdentitiesProviderRuleSPI) ruleSpi;
        members = identitiesProviderRuleSpi.evaluate(entry, rule);
    } catch (Exception e) {
        log.error("", e);
    }
    return members;
}
Also used : IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) 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) Identity(org.olat.core.id.Identity)

Example 20 with RuleSPI

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

the class CourseReminderEditController method doInitDefaultRule.

private void doInitDefaultRule(UserRequest ureq) {
    RuleSPI ruleSpi = reminderModule.getRuleSPIByType(DateRuleSPI.class.getSimpleName());
    RuleElement ruleEl = initRuleForm(ureq, ruleSpi, null);
    ruleEls.add(ruleEl);
}
Also used : DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) RuleSPI(org.olat.modules.reminder.RuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI)

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