use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class RepositoryEntryRoleEditor method initForm.
@Override
public FormItem initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
Translator translator = formLayout.getTranslator();
String[] values = new String[] { translator.translate("course.role.owner"), translator.translate("course.role.coach"), translator.translate("course.role.participant"), translator.translate("course.role.participantAndCoach"), translator.translate("course.role.ownerAndCoach"), translator.translate("course.role.all") };
roleEl = uifactory.addDropdownSingleselect("role." + CodeHelper.getRAMUniqueID(), null, formLayout, keys, values, null);
boolean selected = false;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl roleRule = (ReminderRuleImpl) rule;
String role = roleRule.getRightOperand();
for (String key : keys) {
if (key.equals(role)) {
roleEl.select(key, true);
selected = true;
}
}
}
if (!selected) {
roleEl.select(keys[0], true);
}
return roleEl;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class RepositoryEntryRoleEditor method getConfiguration.
@Override
public ReminderRule getConfiguration() {
ReminderRuleImpl configuredRule = null;
if (roleEl.isOneSelected()) {
configuredRule = new ReminderRuleImpl();
configuredRule.setType(RepositoryEntryRoleRuleSPI.class.getSimpleName());
configuredRule.setOperator("=");
configuredRule.setRightOperand(roleEl.getSelectedKey());
}
return configuredRule;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class AbstractLaunchDateRuleSPI method filter.
@Override
public void filter(RepositoryEntry entry, List<Identity> identities, ReminderRule rule) {
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
Date now = new Date();
int distance = Integer.parseInt(r.getRightOperand());
LaunchUnit unit = LaunchUnit.valueOf(r.getRightUnit());
Map<Long, Date> initialLaunchDates = getLaunchDates(rule, entry, identities);
for (Iterator<Identity> identityIt = identities.iterator(); identityIt.hasNext(); ) {
Identity identity = identityIt.next();
Date initialLaunchDate = initialLaunchDates.get(identity.getKey());
if (initialLaunchDate == null) {
identityIt.remove();
} else if (!after(initialLaunchDate, now, distance, unit)) {
identityIt.remove();
}
}
}
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class UserPropertyRuleSPI method accept.
public boolean accept(ReminderRule rule, Identity identity) {
boolean allOk = false;
if (rule instanceof ReminderRuleImpl) {
ReminderRuleImpl r = (ReminderRuleImpl) rule;
String propertyName = r.getLeftOperand();
String reference = r.getRightOperand();
String value = identity.getUser().getProperty(propertyName, null);
if (reference != null && reference.equalsIgnoreCase(value)) {
allOk = true;
}
}
return allOk;
}
use of org.olat.modules.reminder.model.ReminderRuleImpl in project OpenOLAT by OpenOLAT.
the class GTAReminderRuleTest method assignTask_relativeToInitialLaunchDate.
@Test
public void assignTask_relativeToInitialLaunchDate() {
// create a course with 3 members
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("initial-launch-1");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("initial-launch-2");
Identity id3 = JunitTestHelper.createAndPersistIdentityAsRndUser("initial-launch-3");
ICourse course = CoursesWebService.createEmptyCourse(null, "initial-launch-dates", "course long name", null);
RepositoryEntry re = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
repositoryEntryRelationDao.addRole(id1, re, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(id2, re, GroupRoles.participant.name());
repositoryEntryRelationDao.addRole(id3, re, GroupRoles.participant.name());
dbInstance.commit();
// create user course infos
userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id1);
userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id2);
userCourseInformationsManager.updateUserCourseInformations(re.getOlatResource(), id3);
dbInstance.commit();
// fake the date
updateInitialLaunchDate(re.getOlatResource(), id1, -5, Calendar.DATE);
updateInitialLaunchDate(re.getOlatResource(), id2, -35, Calendar.DATE);
updateInitialLaunchDate(re.getOlatResource(), id3, -75, Calendar.DATE);
dbInstance.commitAndCloseSession();
// create a fake node
GTACourseNode node = new GTACourseNode();
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_TYPE, GTAType.individual.name());
node.getModuleConfiguration().setBooleanEntry(GTACourseNode.GTASK_RELATIVE_DATES, true);
node.getModuleConfiguration().setIntValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE_RELATIVE, 40);
node.getModuleConfiguration().setStringValue(GTACourseNode.GTASK_ASSIGNMENT_DEADLINE_RELATIVE_TO, GTARelativeToDates.courseLaunch.name());
// need the task list
TaskList tasks = gtaManager.createIfNotExists(re, node);
Assert.assertNotNull(tasks);
dbInstance.commit();
{
// check 3 days
ReminderRuleImpl rule = getAssignedTaskRules(3, LaunchUnit.day);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(1, all.size());
Assert.assertTrue(all.contains(id3));
}
{
// check 5 days
ReminderRuleImpl rule = getAssignedTaskRules(5, LaunchUnit.day);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(id2));
Assert.assertTrue(all.contains(id3));
}
{
// check 1 week
ReminderRuleImpl rule = getAssignedTaskRules(1, LaunchUnit.week);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(id2));
Assert.assertTrue(all.contains(id3));
}
{
// check 1 month
ReminderRuleImpl rule = getAssignedTaskRules(1, LaunchUnit.month);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(2, all.size());
Assert.assertTrue(all.contains(id2));
Assert.assertTrue(all.contains(id3));
}
{
// check 2 month
ReminderRuleImpl rule = getAssignedTaskRules(2, LaunchUnit.month);
List<Identity> all = assignTaskRuleSPI.evaluateRule(re, node, rule);
Assert.assertEquals(3, all.size());
Assert.assertTrue(all.contains(id1));
Assert.assertTrue(all.contains(id2));
Assert.assertTrue(all.contains(id3));
}
}
Aggregations