Search in sources :

Example 41 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project openolat by klemens.

the class ReminderRuleEngineTest method getInitialLaunchRules.

private List<ReminderRule> getInitialLaunchRules(int amount, LaunchUnit unit) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(InitialCourseLaunchRuleSPI.class.getSimpleName());
    rule.setOperator(">");
    rule.setRightOperand(Integer.toString(amount));
    rule.setRightUnit(unit.name());
    List<ReminderRule> rules = new ArrayList<>(1);
    rules.add(rule);
    return rules;
}
Also used : InitialCourseLaunchRuleSPI(org.olat.modules.reminder.rule.InitialCourseLaunchRuleSPI) ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) ArrayList(java.util.ArrayList)

Example 42 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project openolat by klemens.

the class ReminderRuleEngineTest method getRecentLaunchRules.

private List<ReminderRule> getRecentLaunchRules(int amount, LaunchUnit unit) {
    ReminderRuleImpl rule = new ReminderRuleImpl();
    rule.setType(RecentCourseLaunchRuleSPI.class.getSimpleName());
    rule.setOperator(">");
    rule.setRightOperand(Integer.toString(amount));
    rule.setRightUnit(unit.name());
    List<ReminderRule> rules = new ArrayList<>(1);
    rules.add(rule);
    return rules;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) ArrayList(java.util.ArrayList) RecentCourseLaunchRuleSPI(org.olat.modules.reminder.rule.RecentCourseLaunchRuleSPI)

Example 43 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project openolat by klemens.

the class ReminderRuleEngine method evaluateRepositoryEntryRule.

/**
 * @param reminder
 */
protected boolean evaluateRepositoryEntryRule(RepositoryEntry entry, List<ReminderRule> ruleList) {
    boolean allOk = true;
    for (Iterator<ReminderRule> ruleIt = ruleList.iterator(); ruleIt.hasNext(); ) {
        ReminderRule rule = ruleIt.next();
        RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
        if (ruleSpi instanceof RepositoryEntryRuleSPI) {
            allOk &= ((RepositoryEntryRuleSPI) ruleSpi).evaluate(entry, rule);
            ruleIt.remove();
        }
    }
    return allOk;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) RepositoryEntryRuleSPI(org.olat.modules.reminder.RepositoryEntryRuleSPI) 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)

Example 44 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project openolat by klemens.

the class ReminderRuleEngine method evaluate.

public List<Identity> evaluate(Reminder reminder, boolean resend) {
    String config = reminder.getConfiguration();
    ReminderRules rules = reminderManager.toRules(config);
    if (rules == null || rules.getRules() == null || rules.getRules().isEmpty()) {
        return Collections.emptyList();
    }
    List<ReminderRule> ruleList = new ArrayList<>(rules.getRules());
    boolean allOk = evaluate(reminder, ruleList);
    List<Identity> identities;
    if (allOk) {
        identities = getIdentities(reminder.getEntry(), reminder, ruleList, resend);
        if (identities.size() > 0 && ruleList.size() > 0) {
            filterByRules(reminder.getEntry(), identities, ruleList);
        }
    } else {
        identities = Collections.emptyList();
    }
    return identities;
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRules(org.olat.modules.reminder.model.ReminderRules) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Example 45 with ReminderRule

use of org.olat.modules.reminder.ReminderRule in project openolat by klemens.

the class CourseReminderEditController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    FormLayoutContainer generalCont = FormLayoutContainer.createVerticalFormLayout("general", getTranslator());
    generalCont.setRootForm(mainForm);
    generalCont.setFormContextHelp("Course Reminders");
    formLayout.add(generalCont);
    String key = reminder.getKey() == null ? "" : reminder.getKey().toString();
    uifactory.addStaticTextElement("reminder.id", key, generalCont);
    String desc = reminder.getDescription();
    descriptionEl = uifactory.addTextElement("reminder.description", "reminder.description", 128, desc, generalCont);
    descriptionEl.setMandatory(true);
    descriptionEl.setElementCssClass("o_sel_course_reminder_desc");
    String sendTime = getSendTimeDescription();
    uifactory.addStaticTextElement("send.time.description.label", sendTime, generalCont);
    // rules
    String rulePage = velocity_root + "/edit_rules.html";
    rulesCont = FormLayoutContainer.createCustomFormLayout("rules", getTranslator(), rulePage);
    rulesCont.setRootForm(mainForm);
    formLayout.add(rulesCont);
    rulesCont.contextPut("rules", ruleEls);
    String configuration = reminder.getConfiguration();
    if (StringHelper.containsNonWhitespace(configuration)) {
        ReminderRules rules = reminderManager.toRules(configuration);
        if (rules.getRules() != null) {
            for (ReminderRule rule : rules.getRules()) {
                if (rule != null) {
                    RuleSPI ruleSpy = reminderModule.getRuleSPIByType(rule.getType());
                    RuleElement ruleEl = initRuleForm(ureq, ruleSpy, rule);
                    ruleEls.add(ruleEl);
                }
            }
        }
    }
    if (ruleEls.isEmpty()) {
        doInitDefaultRule(ureq);
    }
    // email content
    FormLayoutContainer contentCont = FormLayoutContainer.createVerticalFormLayout("contents", getTranslator());
    contentCont.setRootForm(mainForm);
    formLayout.add(contentCont);
    // email subject
    String subject = reminder.getEmailSubject();
    subjectEl = uifactory.addTextElement("reminder.subject", "reminder.subject", 128, subject, contentCont);
    subjectEl.setMandatory(true);
    subjectEl.setElementCssClass("o_sel_course_reminder_subject");
    String emailContent = reminder == null ? null : reminder.getEmailBody();
    if (!StringHelper.containsNonWhitespace(emailContent)) {
        emailContent = translate("reminder.def.body");
    }
    emailEl = uifactory.addRichTextElementForStringDataMinimalistic("email.content", "email.content", emailContent, 10, 60, contentCont, getWindowControl());
    emailEl.setMandatory(true);
    String buttonPage = velocity_root + "/edit_rules_buttons.html";
    FormLayoutContainer buttonLayout = FormLayoutContainer.createCustomFormLayout("buttons", getTranslator(), buttonPage);
    buttonLayout.setRootForm(mainForm);
    formLayout.add(buttonLayout);
    uifactory.addFormSubmitButton("save", buttonLayout);
    uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) ReminderRules(org.olat.modules.reminder.model.ReminderRules) RuleSPI(org.olat.modules.reminder.RuleSPI) DateRuleSPI(org.olat.modules.reminder.rule.DateRuleSPI) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Aggregations

ReminderRule (org.olat.modules.reminder.ReminderRule)46 ArrayList (java.util.ArrayList)32 ReminderRuleImpl (org.olat.modules.reminder.model.ReminderRuleImpl)26 RuleSPI (org.olat.modules.reminder.RuleSPI)12 ReminderRules (org.olat.modules.reminder.model.ReminderRules)12 DateRuleSPI (org.olat.modules.reminder.rule.DateRuleSPI)10 RepositoryEntryRoleRuleSPI (org.olat.modules.reminder.rule.RepositoryEntryRoleRuleSPI)8 UserPropertyRuleSPI (org.olat.modules.reminder.rule.UserPropertyRuleSPI)8 Identity (org.olat.core.id.Identity)6 FilterRuleSPI (org.olat.modules.reminder.FilterRuleSPI)6 IdentitiesProviderRuleSPI (org.olat.modules.reminder.IdentitiesProviderRuleSPI)6 RepositoryEntryRuleSPI (org.olat.modules.reminder.RepositoryEntryRuleSPI)6 BusinessGroupRoleRuleSPI (org.olat.modules.reminder.rule.BusinessGroupRoleRuleSPI)6 InitialAttemptsRuleSPI (org.olat.course.reminder.rule.InitialAttemptsRuleSPI)4 Reminder (org.olat.modules.reminder.Reminder)4 ReminderModule (org.olat.modules.reminder.ReminderModule)4 ReminderService (org.olat.modules.reminder.ReminderService)4 CourseEnrollmentDateRuleSPI (org.olat.modules.reminder.rule.CourseEnrollmentDateRuleSPI)4 ParseException (java.text.ParseException)2 Calendar (java.util.Calendar)2