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