use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class UserPropertyRuleSPI method accept.
public boolean accept(ReminderRule rule, Identity identity) {
boolean allOk = false;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
String propertyName = r.getLeftOperand();
String reference = r.getRightOperand();
String value = identity.getUser().getProperty(propertyName, null);
if (reference != null && reference.equalsIgnoreCase(value)) {
allOk = true;
}
}
return allOk;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class BusinessGroupRoleEditor method initForm.
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String id = Long.toString(CodeHelper.getRAMUniqueID());
String page = Util.getPackageVelocityRoot(this.getClass()) + "/rule_1_element.html";
FormLayoutContainer ruleCont = FormLayoutContainer.createCustomFormLayout(".".concat(id), formLayout.getTranslator(), page);
ruleCont.setRootForm(formLayout.getRootForm());
formLayout.add(ruleCont);
ruleCont.getFormItemComponent().contextPut("id", id);
String currentKey = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl roleRule = (ReminderRuleImpl) rule;
currentKey = roleRule.getRightOperand();
}
String[] keys = new String[businessGroups.size()];
String[] values = new String[businessGroups.size()];
int count = 0;
String selectedKey = null;
for (BusinessGroup businessGroup : businessGroups) {
String key = Integer.toString(count);
if (currentKey != null && businessGroup.getKey().toString().equals(currentKey)) {
selectedKey = key;
}
keys[count] = key;
values[count++] = businessGroup.getName();
}
groupEl = uifactory.addDropdownSingleselect("ruleElement.".concat(id), null, ruleCont, keys, values, null);
if (selectedKey != null) {
groupEl.select(selectedKey, true);
}
if (StringHelper.containsNonWhitespace(currentKey) && selectedKey == null) {
groupEl.setErrorKey("error.group.not.found", null);
}
return ruleCont;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class BusinessGroupRoleEditor method getConfiguration.
@Override
public ReminderRule getConfiguration() {
ReminderRuleImpl configuredRule = null;
if (groupEl.isOneSelected()) {
String selectedKey = groupEl.getSelectedKey();
int index = Integer.parseInt(selectedKey);
if (index >= 0 && index < businessGroups.size()) {
BusinessGroup businessGroup = businessGroups.get(index);
configuredRule = new ReminderRuleImpl();
configuredRule.setType(BusinessGroupRoleRuleSPI.class.getSimpleName());
configuredRule.setOperator("=");
configuredRule.setRightOperand(businessGroup.getKey().toString());
}
}
return configuredRule;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
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 klemens.
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;
}
Aggregations