use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class RepositoryEntryRoleEditor method initForm.
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
Translator translator = formLayout.getTranslator();
String[] values = new String[] { translator.translate("course.role.owner"), translator.translate("course.role.coach"), translator.translate("course.role.participant"), translator.translate("course.role.participantAndCoach"), translator.translate("course.role.ownerAndCoach"), translator.translate("course.role.all") };
roleEl = uifactory.addDropdownSingleselect("role." + CodeHelper.getRAMUniqueID(), null, formLayout, keys, values, null);
boolean selected = false;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl roleRule = (ReminderRuleImpl) rule;
String role = roleRule.getRightOperand();
for (String key : keys) {
if (key.equals(role)) {
roleEl.select(key, true);
selected = true;
}
}
}
if (!selected) {
roleEl.select(keys[0], true);
}
return roleEl;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
the class UserPropertyEditor method initForm.
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
String page = Util.getPackageVelocityRoot(this.getClass()) + "/user_prop.html";
String id = Long.toString(CodeHelper.getRAMUniqueID());
FormLayoutContainer userPropCont = FormLayoutContainer.createCustomFormLayout("user.prop.".concat(id), formLayout.getTranslator(), page);
userPropCont.setRootForm(formLayout.getRootForm());
formLayout.add(userPropCont);
userPropCont.getFormItemComponent().contextPut("id", id);
Translator trans = Util.createPackageTranslator(UserPropertyHandler.class, ureq.getLocale(), formLayout.getTranslator());
int numOfProperties = userPropertyHandlers.size();
String[] propKeys = new String[numOfProperties];
String[] propValues = new String[numOfProperties];
for (int i = 0; i < numOfProperties; i++) {
UserPropertyHandler handler = userPropertyHandlers.get(i);
propKeys[i] = handler.getName();
propValues[i] = trans.translate(handler.i18nFormElementLabelKey());
}
String currentPropertyName = null;
String currentPropertyValue = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
currentPropertyName = r.getLeftOperand();
currentPropertyValue = r.getRightOperand();
}
propEl = uifactory.addDropdownSingleselect("user.prop.".concat(id), null, userPropCont, propKeys, propValues, null);
propEl.setDomReplacementWrapperRequired(false);
if (currentPropertyName != null) {
for (String propKey : propKeys) {
if (currentPropertyName.equals(propKey)) {
propEl.select(propKey, true);
}
}
}
valueEl = uifactory.addTextElement("user.value.".concat(id), null, 128, currentPropertyValue, userPropCont);
valueEl.setDomReplacementWrapperRequired(false);
return userPropCont;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl 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.model.ReminderRuleImpl in project openolat by klemens.
the class AbstractLaunchDateRuleSPI method filter.
@Override
public void filter(RepositoryEntry entry, List<Identity> identities, ReminderRule rule) {
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
Date now = new Date();
int distance = Integer.parseInt(r.getRightOperand());
LaunchUnit unit = LaunchUnit.valueOf(r.getRightUnit());
Map<Long, Date> initialLaunchDates = getLaunchDates(rule, entry, identities);
for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
Identity identity = identityIt.next();
Date initialLaunchDate = initialLaunchDates.get(identity.getKey());
if (initialLaunchDate == null) {
identityIt.remove();
} else if (!after(initialLaunchDate, now, distance, unit)) {
identityIt.remove();
}
}
}
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project openolat by klemens.
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;
}
Aggregations