use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class RepositoryEntryLifecycleAfterValidRuleEditor 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 RepositoryEntryLifecycleAfterValidRuleEditor method initForm.
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String page = Util.getPackageVelocityRoot(this.getClass()) + templateName;
String id = Long.toString(CodeHelper.getRAMUniqueID());
Translator trans = formLayout.getTranslator();
FormLayoutContainer ruleCont = FormLayoutContainer.createCustomFormLayout("repo.valid.".concat(id), formLayout.getTranslator(), page);
ruleCont.setRootForm(formLayout.getRootForm());
formLayout.add(ruleCont);
ruleCont.contextPut("id", id);
String currentValue = null;
String currentUnit = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
currentValue = r.getRightOperand();
currentUnit = r.getRightUnit();
}
valueEl = uifactory.addTextElement("launchvalue".concat(id), null, 128, currentValue, ruleCont);
valueEl.setDomReplacementWrapperRequired(false);
valueEl.setDisplaySize(3);
String[] unitValues = new String[] { trans.translate(LaunchUnit.day.name()), trans.translate(LaunchUnit.week.name()), trans.translate(LaunchUnit.month.name()), trans.translate(LaunchUnit.year.name()) };
unitEl = uifactory.addDropdownSingleselect("launchunit".concat(id), null, ruleCont, unitKeys, unitValues, null);
unitEl.setDomReplacementWrapperRequired(false);
boolean unitSelected = false;
if (currentUnit != null) {
for (String unitKey : unitKeys) {
if (currentUnit.equals(unitKey)) {
unitEl.select(unitKey, true);
unitSelected = true;
}
}
}
if (!unitSelected) {
unitEl.select(unitKeys[1], true);
}
return ruleCont;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class UserPropertyEditor method getConfiguration.
@Override
public ReminderRule getConfiguration() {
ReminderRuleImpl configuredRule = null;
if (propEl.isOneSelected() && StringHelper.containsNonWhitespace(valueEl.getValue())) {
configuredRule = new ReminderRuleImpl();
configuredRule.setType(UserPropertyRuleSPI.class.getSimpleName());
configuredRule.setLeftOperand(propEl.getSelectedKey());
configuredRule.setOperator("=");
configuredRule.setRightOperand(valueEl.getValue());
}
return configuredRule;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class BusinessGroupRoleRuleSPI method evaluate.
@Override
public List<Identity> evaluate(RepositoryEntry entry, ReminderRule rule) {
List<Identity> identities = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
String groupKey = r.getRightOperand();
if (StringHelper.isLong(groupKey)) {
Long key = Long.parseLong(groupKey);
BusinessGroupRef groupRef = new BusinessGroupRefImpl(key);
identities = businessGroupRelationDao.getMembers(groupRef, GroupRoles.coach.name(), GroupRoles.participant.name());
}
}
return identities == null ? Collections.<Identity>emptyList() : identities;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class DateRuleSPI method evaluate.
public boolean evaluate(ReminderRule rule) {
boolean allOk = true;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
String operator = r.getOperator();
if (AFTER.equals(operator) && StringHelper.containsNonWhitespace(r.getRightOperand())) {
try {
Date date = Formatter.parseDatetime(r.getRightOperand());
Date now = new Date();
allOk &= now.compareTo(date) >= 0;
} catch (ParseException e) {
log.error("", e);
}
}
}
return allOk;
}
Aggregations