use of org.olat.modules.reminder.ReminderRule in project openolat by klemens.
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.ReminderRule in project openolat by klemens.
the class ReminderServiceImpl method optimizeStartDate.
private void optimizeStartDate(Reminder reminder) {
Date startDate = null;
String configuration = reminder.getConfiguration();
if (StringHelper.containsNonWhitespace(configuration)) {
ReminderRules rules = toRules(configuration);
for (ReminderRule rule : rules.getRules()) {
if (rule instanceof ReminderRuleImpl && ReminderRuleEngine.DATE_RULE_TYPE.equals(rule.getType())) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
if (DateRuleSPI.AFTER.equals(r.getOperator()) && StringHelper.containsNonWhitespace(r.getRightOperand())) {
try {
Date date = Formatter.parseDatetime(r.getRightOperand());
if (startDate == null) {
startDate = date;
} else if (startDate.compareTo(date) > 0) {
startDate = date;
}
} catch (ParseException e) {
log.error("", e);
}
}
}
}
}
((ReminderImpl) reminder).setStartDate(startDate);
}
use of org.olat.modules.reminder.ReminderRule in project OpenOLAT by OpenOLAT.
the class ReminderRuleEngine method evaluateDateRule.
/**
* @param reminder
*/
protected boolean evaluateDateRule(List<ReminderRule> ruleList) {
boolean allOk = true;
for (Iterator<ReminderRule> ruleIt = ruleList.iterator(); ruleIt.hasNext(); ) {
ReminderRule rule = ruleIt.next();
if (DATE_RULE_TYPE.equals(rule.getType())) {
allOk &= dateRuleSpi.evaluate(rule);
ruleIt.remove();
}
}
return allOk;
}
use of org.olat.modules.reminder.ReminderRule 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.ReminderRule 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);
}
}
Aggregations