use of org.olat.modules.reminder.IdentitiesProviderRuleSPI in project OpenOLAT by OpenOLAT.
the class ReminderRuleEngine method getMembers.
public List<Identity> getMembers(RepositoryEntry entry, ReminderRule rule) {
List<Identity> members = new ArrayList<>();
try {
RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
IdentitiesProviderRuleSPI identitiesProviderRuleSpi = (IdentitiesProviderRuleSPI) ruleSpi;
members = identitiesProviderRuleSpi.evaluate(entry, rule);
} catch (Exception e) {
log.error("", e);
}
return members;
}
use of org.olat.modules.reminder.IdentitiesProviderRuleSPI in project OpenOLAT by OpenOLAT.
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.IdentitiesProviderRuleSPI 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.IdentitiesProviderRuleSPI in project openolat by klemens.
the class ReminderRuleEngine method getMembers.
public List<Identity> getMembers(RepositoryEntry entry, ReminderRule rule) {
List<Identity> members = new ArrayList<>();
try {
RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
IdentitiesProviderRuleSPI identitiesProviderRuleSpi = (IdentitiesProviderRuleSPI) ruleSpi;
members = identitiesProviderRuleSpi.evaluate(entry, rule);
} catch (Exception e) {
log.error("", e);
}
return members;
}
Aggregations