use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class RepositoryEntryRoleRuleSPI method evaluate.
@Override
public List<Identity> evaluate(RepositoryEntry entry, ReminderRule rule) {
List<Identity> identities = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
String roles = r.getRightOperand();
if (StringHelper.containsNonWhitespace(roles)) {
switch(Roles.valueOf(roles)) {
case owner:
identities = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.defaultGroup, GroupRoles.owner.name());
break;
case coach:
identities = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.both, GroupRoles.coach.name());
break;
case participant:
identities = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.both, GroupRoles.participant.name());
break;
case participantAndCoach:
identities = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.both, GroupRoles.coach.name(), GroupRoles.participant.name());
break;
case ownerAndCoach:
identities = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.both, GroupRoles.coach.name(), GroupRoles.owner.name());
break;
case all:
identities = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.both, GroupRoles.owner.name(), GroupRoles.coach.name(), GroupRoles.participant.name());
break;
}
}
}
return identities == null ? Collections.<Identity>emptyList() : identities;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
the class DateRuleEditor 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);
Date after = null;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl ruleImpl = (ReminderRuleImpl) rule;
try {
after = Formatter.parseDatetime(ruleImpl.getRightOperand());
} catch (ParseException e) {
log.error("", e);
}
}
afterEl = uifactory.addDateChooser("ruleElement.".concat(id), null, after, ruleCont);
afterEl.setDateChooserTimeEnabled(true);
return ruleCont;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class DateRuleEditor method getConfiguration.
@Override
public ReminderRule getConfiguration() {
ReminderRuleImpl configuredRule = new ReminderRuleImpl();
configuredRule.setType(DateRuleSPI.class.getSimpleName());
configuredRule.setOperator(DateRuleSPI.AFTER);
if (afterEl.getDate() != null) {
configuredRule.setRightOperand(Formatter.formatDatetime(afterEl.getDate()));
}
return configuredRule;
}
Aggregations