use of org.olat.modules.reminder.RuleSPI in project OpenOLAT by OpenOLAT.
the class CourseReminderEditController method doInitDefaultRule.
private void doInitDefaultRule(UserRequest ureq) {
RuleSPI ruleSpi = reminderModule.getRuleSPIByType(DateRuleSPI.class.getSimpleName());
RuleElement ruleEl = initRuleForm(ureq, ruleSpi, null);
ruleEls.add(ruleEl);
}
use of org.olat.modules.reminder.RuleSPI in project OpenOLAT by OpenOLAT.
the class CourseReminderEditController method doAddRule.
private void doAddRule(UserRequest ureq, RuleElement ruleElement) {
int index = ruleEls.indexOf(ruleElement) + 1;
RuleSPI ruleSpi = reminderModule.getRuleSPIByType(DateRuleSPI.class.getSimpleName());
RuleElement ruleEl = initRuleForm(ureq, ruleSpi, null);
if (index >= 0 && index < ruleEls.size()) {
ruleEls.add(index, ruleEl);
} else {
ruleEls.add(ruleEl);
}
}
use of org.olat.modules.reminder.RuleSPI in project openolat by klemens.
the class ReminderRuleEngine method getIdentities.
protected List<Identity> getIdentities(RepositoryEntry entry, Reminder reminder, List<ReminderRule> ruleList, boolean resend) {
List<ReminderRule> identitiesProviderRules = new ArrayList<>();
for (Iterator<ReminderRule> ruleIt = ruleList.iterator(); ruleIt.hasNext(); ) {
ReminderRule rule = ruleIt.next();
RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
if (ruleSpi instanceof IdentitiesProviderRuleSPI) {
identitiesProviderRules.add(rule);
ruleIt.remove();
}
}
List<Identity> identities;
if (identitiesProviderRules.isEmpty()) {
// all members of repository entry
List<Identity> duplicatedIdentities = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.both, GroupRoles.owner.name(), GroupRoles.coach.name(), GroupRoles.participant.name());
identities = new ArrayList<>(new HashSet<>(duplicatedIdentities));
} else {
identities = null;
for (ReminderRule rule : identitiesProviderRules) {
List<Identity> members = getMembers(entry, rule);
if (identities == null) {
identities = members;
} else {
identities.retainAll(members);
}
}
}
// filter by user property
filterIdentitiesByProperty(identities, ruleList);
// deduplicated the list
identities = new ArrayList<>(new HashSet<>(identities));
if (!resend) {
List<Long> alreadySendKeys = reminderDao.getReminderRecipientKeys(reminder);
Set<Long> alreadySendKeySet = new HashSet<>(alreadySendKeys);
for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
if (alreadySendKeySet.contains(identityIt.next().getKey())) {
identityIt.remove();
}
}
}
return identities;
}
use of org.olat.modules.reminder.RuleSPI in project openolat by klemens.
the class ReminderRuleEngine method filterByRules.
protected void filterByRules(RepositoryEntry entry, List<Identity> identities, List<ReminderRule> ruleList) {
List<ReminderRule> filterRules = new ArrayList<>(3);
for (Iterator<ReminderRule> ruleIt = ruleList.iterator(); ruleIt.hasNext(); ) {
ReminderRule rule = ruleIt.next();
RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
if (ruleSpi instanceof FilterRuleSPI) {
filterRules.add(rule);
ruleIt.remove();
}
}
for (ReminderRule rule : filterRules) {
filterByRule(entry, identities, rule);
}
}
use of org.olat.modules.reminder.RuleSPI in project openolat by klemens.
the class CourseReminderEditController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source instanceof SingleSelection) {
RuleElement panelToUpdate = null;
for (RuleElement ruleEl : ruleEls) {
if (source == ruleEl.getTypeEl()) {
panelToUpdate = ruleEl;
}
}
if (panelToUpdate != null) {
SingleSelection typeEl = (SingleSelection) source;
RuleSPI type = reminderModule.getRuleSPIByType(typeEl.getSelectedKey());
doUpdateRuleForm(ureq, panelToUpdate, type);
}
} else if (source instanceof FormLink) {
FormLink button = (FormLink) source;
String cmd = button.getCmd();
if ("add".equals(cmd)) {
doAddRule(ureq, (RuleElement) button.getUserObject());
} else if ("delete".equals(cmd)) {
doDeleteRule(ureq, (RuleElement) button.getUserObject());
}
}
super.formInnerEvent(ureq, source, event);
}
Aggregations