Search in sources :

Example 1 with IdentitiesProviderRuleSPI

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;
}
Also used : IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) FilterRuleSPI(org.olat.modules.reminder.FilterRuleSPI) RepositoryEntryRoleRuleSPI(org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI) UserPropertyRuleSPI(org.olat.modules.reminder.rule.UserPropertyRuleSPI) IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) RuleSPI(org.olat.modules.reminder.RuleSPI) RepositoryEntryRuleSPI(org.olat.modules.reminder.RepositoryEntryRuleSPI) BusinessGroupRoleRuleSPI(org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Example 2 with IdentitiesProviderRuleSPI

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;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) ArrayList(java.util.ArrayList) FilterRuleSPI(org.olat.modules.reminder.FilterRuleSPI) RepositoryEntryRoleRuleSPI(org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI) UserPropertyRuleSPI(org.olat.modules.reminder.rule.UserPropertyRuleSPI) IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) RuleSPI(org.olat.modules.reminder.RuleSPI) RepositoryEntryRuleSPI(org.olat.modules.reminder.RepositoryEntryRuleSPI) BusinessGroupRoleRuleSPI(org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 3 with IdentitiesProviderRuleSPI

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;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) ArrayList(java.util.ArrayList) FilterRuleSPI(org.olat.modules.reminder.FilterRuleSPI) RepositoryEntryRoleRuleSPI(org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI) UserPropertyRuleSPI(org.olat.modules.reminder.rule.UserPropertyRuleSPI) IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) RuleSPI(org.olat.modules.reminder.RuleSPI) RepositoryEntryRuleSPI(org.olat.modules.reminder.RepositoryEntryRuleSPI) BusinessGroupRoleRuleSPI(org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 4 with IdentitiesProviderRuleSPI

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;
}
Also used : IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) FilterRuleSPI(org.olat.modules.reminder.FilterRuleSPI) RepositoryEntryRoleRuleSPI(org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI) UserPropertyRuleSPI(org.olat.modules.reminder.rule.UserPropertyRuleSPI) IdentitiesProviderRuleSPI(org.olat.modules.reminder.IdentitiesProviderRuleSPI) RuleSPI(org.olat.modules.reminder.RuleSPI) RepositoryEntryRuleSPI(org.olat.modules.reminder.RepositoryEntryRuleSPI) BusinessGroupRoleRuleSPI(org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Aggregations

ArrayList (java.util.ArrayList)4 Identity (org.olat.core.id.Identity)4 FilterRuleSPI (org.olat.modules.reminder.FilterRuleSPI)4 IdentitiesProviderRuleSPI (org.olat.modules.reminder.IdentitiesProviderRuleSPI)4 RepositoryEntryRuleSPI (org.olat.modules.reminder.RepositoryEntryRuleSPI)4 RuleSPI (org.olat.modules.reminder.RuleSPI)4 BusinessGroupRoleRuleSPI (org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI)4 DateRuleSPI (org.olat.modules.reminder.rule.DateRuleSPI)4 RepositoryEntryRoleRuleSPI (org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI)4 UserPropertyRuleSPI (org.olat.modules.reminder.rule.UserPropertyRuleSPI)4 HashSet (java.util.HashSet)2 ReminderRule (org.olat.modules.reminder.ReminderRule)2