Search in sources :

Example 6 with RuleSPI

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);
}
Also used : DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) RuleSPI(org.olat.modules.reminder.RuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI)

Example 7 with RuleSPI

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);
    }
}
Also used : DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) RuleSPI(org.olat.modules.reminder.RuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI)

Example 8 with RuleSPI

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;
}
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 9 with RuleSPI

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);
    }
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) 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) FilterRuleSPI(org.olat.modules.reminder.FilterRuleSPI)

Example 10 with RuleSPI

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);
}
Also used : SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) RuleSPI(org.olat.modules.reminder.RuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Aggregations

RuleSPI (org.olat.modules.reminder.RuleSPI)22 DateRuleSPI (org.olat.modules.reminder.rule.DateRuleSPI)18 ReminderRule (org.olat.modules.reminder.ReminderRule)12 FilterRuleSPI (org.olat.modules.reminder.FilterRuleSPI)10 IdentitiesProviderRuleSPI (org.olat.modules.reminder.IdentitiesProviderRuleSPI)10 RepositoryEntryRuleSPI (org.olat.modules.reminder.RepositoryEntryRuleSPI)10 BusinessGroupRoleRuleSPI (org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI)10 RepositoryEntryRoleRuleSPI (org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI)10 UserPropertyRuleSPI (org.olat.modules.reminder.rule.UserPropertyRuleSPI)10 ArrayList (java.util.ArrayList)6 ReminderRules (org.olat.modules.reminder.model.ReminderRules)6 Identity (org.olat.core.id.Identity)4 Reminder (org.olat.modules.reminder.Reminder)4 ReminderModule (org.olat.modules.reminder.ReminderModule)4 ReminderService (org.olat.modules.reminder.ReminderService)4 HashSet (java.util.HashSet)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2