Search in sources :

Example 71 with ReminderRuleImpl

use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.

the class RepositoryEntryLifecycleAfterValidRuleEditor method getConfiguration.

@Override
public ReminderRule getConfiguration() {
    ReminderRuleImpl configuredRule = new ReminderRuleImpl();
    configuredRule.setType(ruleType);
    configuredRule.setOperator(">");
    configuredRule.setRightOperand(valueEl.getValue());
    configuredRule.setRightUnit(unitEl.getSelectedKey());
    return configuredRule;
}
Also used : ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl)

Example 72 with ReminderRuleImpl

use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.

the class RepositoryEntryLifecycleAfterValidRuleEditor method initForm.

@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String page = Util.getPackageVelocityRoot(this.getClass()) + templateName;
    String id = Long.toString(CodeHelper.getRAMUniqueID());
    Translator trans = formLayout.getTranslator();
    FormLayoutContainer ruleCont = FormLayoutContainer.createCustomFormLayout("repo.valid.".concat(id), formLayout.getTranslator(), page);
    ruleCont.setRootForm(formLayout.getRootForm());
    formLayout.add(ruleCont);
    ruleCont.contextPut("id", id);
    String currentValue = null;
    String currentUnit = null;
    if (rule instanceof ReminderRuleImpl) {
        ReminderRuleImpl r = (ReminderRuleImpl) rule;
        currentValue = r.getRightOperand();
        currentUnit = r.getRightUnit();
    }
    valueEl = uifactory.addTextElement("launchvalue".concat(id), null, 128, currentValue, ruleCont);
    valueEl.setDomReplacementWrapperRequired(false);
    valueEl.setDisplaySize(3);
    String[] unitValues = new String[] { trans.translate(LaunchUnit.day.name()), trans.translate(LaunchUnit.week.name()), trans.translate(LaunchUnit.month.name()), trans.translate(LaunchUnit.year.name()) };
    unitEl = uifactory.addDropdownSingleselect("launchunit".concat(id), null, ruleCont, unitKeys, unitValues, null);
    unitEl.setDomReplacementWrapperRequired(false);
    boolean unitSelected = false;
    if (currentUnit != null) {
        for (String unitKey : unitKeys) {
            if (currentUnit.equals(unitKey)) {
                unitEl.select(unitKey, true);
                unitSelected = true;
            }
        }
    }
    if (!unitSelected) {
        unitEl.select(unitKeys[1], true);
    }
    return ruleCont;
}
Also used : Translator(org.olat.core.gui.translator.Translator) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 73 with ReminderRuleImpl

use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.

the class UserPropertyEditor method getConfiguration.

@Override
public ReminderRule getConfiguration() {
    ReminderRuleImpl configuredRule = null;
    if (propEl.isOneSelected() && StringHelper.containsNonWhitespace(valueEl.getValue())) {
        configuredRule = new ReminderRuleImpl();
        configuredRule.setType(UserPropertyRuleSPI.class.getSimpleName());
        configuredRule.setLeftOperand(propEl.getSelectedKey());
        configuredRule.setOperator("=");
        configuredRule.setRightOperand(valueEl.getValue());
    }
    return configuredRule;
}
Also used : ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) UserPropertyRuleSPI(org.olat.modules.reminder.rule.UserPropertyRuleSPI)

Example 74 with ReminderRuleImpl

use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.

the class BusinessGroupRoleRuleSPI method evaluate.

@Override
public List<Identity> evaluate(RepositoryEntry entry, ReminderRule rule) {
    List<Identity> identities = null;
    if (rule instanceof ReminderRuleImpl) {
        ReminderRuleImpl r = (ReminderRuleImpl) rule;
        String groupKey = r.getRightOperand();
        if (StringHelper.isLong(groupKey)) {
            Long key = Long.parseLong(groupKey);
            BusinessGroupRef groupRef = new BusinessGroupRefImpl(key);
            identities = businessGroupRelationDao.getMembers(groupRef, GroupRoles.coach.name(), GroupRoles.participant.name());
        }
    }
    return identities == null ? Collections.<Identity>emptyList() : identities;
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) BusinessGroupRefImpl(org.olat.group.model.BusinessGroupRefImpl) Identity(org.olat.core.id.Identity)

Example 75 with ReminderRuleImpl

use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.

the class DateRuleSPI method evaluate.

public boolean evaluate(ReminderRule rule) {
    boolean allOk = true;
    if (rule instanceof ReminderRuleImpl) {
        ReminderRuleImpl r = (ReminderRuleImpl) rule;
        String operator = r.getOperator();
        if (AFTER.equals(operator) && StringHelper.containsNonWhitespace(r.getRightOperand())) {
            try {
                Date date = Formatter.parseDatetime(r.getRightOperand());
                Date now = new Date();
                allOk &= now.compareTo(date) >= 0;
            } catch (ParseException e) {
                log.error("", e);
            }
        }
    }
    return allOk;
}
Also used : ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) ParseException(java.text.ParseException) Date(java.util.Date)

Aggregations

ReminderRuleImpl (org.olat.modules.reminder.model.ReminderRuleImpl)114 ArrayList (java.util.ArrayList)46 Identity (org.olat.core.id.Identity)26 ReminderRule (org.olat.modules.reminder.ReminderRule)26 ICourse (org.olat.course.ICourse)22 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)20 CourseNode (org.olat.course.nodes.CourseNode)20 Test (org.junit.Test)16 Date (java.util.Date)14 Translator (org.olat.core.gui.translator.Translator)14 GTACourseNode (org.olat.course.nodes.GTACourseNode)14 List (java.util.List)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 TaskList (org.olat.course.nodes.gta.TaskList)10 Calendar (java.util.Calendar)8 AssessableCourseNode (org.olat.course.nodes.AssessableCourseNode)8 ParseException (java.text.ParseException)6 InitialAttemptsRuleSPI (org.olat.course.reminder.rule.InitialAttemptsRuleSPI)6 ScoreRuleSPI (org.olat.course.reminder.rule.ScoreRuleSPI)6 File (java.io.File)4