use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class ReminderRuleEngineTest method getAttemptsRules.
private List<ReminderRule> getAttemptsRules(String operator, int value, String nodeIdent) {
ReminderRuleImpl rule = new ReminderRuleImpl();
rule.setType(AttemptsRuleSPI.class.getSimpleName());
rule.setLeftOperand(nodeIdent);
rule.setOperator(operator);
rule.setRightOperand(Integer.toString(value));
List<ReminderRule> rules = new ArrayList<>(1);
rules.add(rule);
return rules;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class BusinessGroupRoleRuleSPI method clone.
@Override
public ReminderRule clone(ReminderRule rule, CourseEnvironmentMapper envMapper) {
ReminderRuleImpl clone = (ReminderRuleImpl) rule.clone();
String groupKey = clone.getRightOperand();
boolean found = false;
if (StringHelper.isLong(groupKey)) {
Long key = Long.parseLong(groupKey);
for (BusinessGroupReference ref : envMapper.getGroups()) {
if (key.equals(ref.getOriginalKey()) && ref.getKey() != null) {
clone.setRightOperand(ref.getKey().toString());
found = true;
}
}
}
return found ? clone : null;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class RepositoryEntryLifecycleAfterValidFromRuleSPI method evaluate.
public boolean evaluate(RepositoryEntryLifecycle lifecycle, ReminderRule rule) {
Date now = cleanNow();
Date validTo = lifecycle.getValidTo();
if (validTo != null && now.compareTo(validTo) >= 0) {
// the course is at the end
return false;
}
ReminderRuleImpl r = (ReminderRuleImpl) rule;
int distance = Integer.parseInt(r.getRightOperand());
LaunchUnit unit = LaunchUnit.valueOf(r.getRightUnit());
Date referenceDate = getDate(lifecycle.getValidFrom(), distance, unit);
return now.compareTo(referenceDate) >= 0;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class CourseLaunchRuleEditor method getConfiguration.
@Override
public ReminderRule getConfiguration() {
ReminderRuleImpl configuredRule = new ReminderRuleImpl();
configuredRule.setType(ruleType);
configuredRule.setOperator(">");
configuredRule.setRightOperand(valueEl.getValue());
configuredRule.setRightUnit(unitEl.getSelectedKey());
return configuredRule;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
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);
}
Aggregations