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;
}
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);
}
}
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);
}
}
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);
}
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);
}
}
Aggregations