use of org.olat.modules.reminder.model.ReminderInfos in project OpenOLAT by OpenOLAT.
the class CourseReminderListController method updateModel.
private void updateModel() {
List<ReminderInfos> reminders = reminderManager.getReminderInfos(repositoryEntry);
List<ReminderRow> rows = new ArrayList<>(reminders.size());
for (ReminderInfos reminder : reminders) {
FormLink toolsLink = uifactory.addFormLink("tools_" + counter.incrementAndGet(), "tools", "", null, null, Link.NONTRANSLATED);
toolsLink.setIconLeftCSS("o_icon o_icon_actions o_icon-lg");
toolsLink.setElementCssClass("o_sel_course_reminder_tools");
toolsLink.setTitle(translate("tools"));
ReminderRow row = new ReminderRow(reminder, toolsLink);
toolsLink.setUserObject(row);
rows.add(row);
}
tableModel.setObjects(rows);
tableEl.reset();
tableEl.setVisible(rows.size() > 0);
}
use of org.olat.modules.reminder.model.ReminderInfos in project OpenOLAT by OpenOLAT.
the class ReminderDAO method getReminderInfos.
public List<ReminderInfos> getReminderInfos(RepositoryEntryRef entry) {
StringBuilder sb = new StringBuilder();
sb.append("select rem.key, rem.description, rem.sendTime, rem.creationDate, rem.lastModified, rem.creator.key,").append(" (select count(sentrem.key) from sentreminder sentrem").append(" where sentrem.reminder.key=rem.key").append(" ) as numOfRemindersSent ").append(" from reminder rem").append(" where rem.entry.key=:entryKey");
List<Object[]> results = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("entryKey", entry.getKey()).getResultList();
List<ReminderInfos> infos = new ArrayList<>(results.size());
for (Object[] result : results) {
Long key = (Long) result[0];
String desc = (String) result[1];
String sendTime = (String) result[2];
Date creationDate = (Date) result[3];
Date lastModified = (Date) result[4];
Long creatorKey = (Long) result[5];
String creator = userManager.getUserDisplayName(creatorKey);
int numOfRemindersSent = 0;
if (result[6] != null) {
numOfRemindersSent = ((Number) result[6]).intValue();
}
infos.add(new ReminderInfos(key, creationDate, lastModified, desc, sendTime, creatorKey, creator, numOfRemindersSent));
}
return infos;
}
use of org.olat.modules.reminder.model.ReminderInfos in project openolat by klemens.
the class CourseReminderListController method updateModel.
private void updateModel() {
List<ReminderInfos> reminders = reminderManager.getReminderInfos(repositoryEntry);
List<ReminderRow> rows = new ArrayList<>(reminders.size());
for (ReminderInfos reminder : reminders) {
FormLink toolsLink = uifactory.addFormLink("tools_" + counter.incrementAndGet(), "tools", "", null, null, Link.NONTRANSLATED);
toolsLink.setIconLeftCSS("o_icon o_icon_actions o_icon-lg");
toolsLink.setElementCssClass("o_sel_course_reminder_tools");
toolsLink.setTitle(translate("tools"));
ReminderRow row = new ReminderRow(reminder, toolsLink);
toolsLink.setUserObject(row);
rows.add(row);
}
tableModel.setObjects(rows);
tableEl.reset();
tableEl.setVisible(rows.size() > 0);
}
use of org.olat.modules.reminder.model.ReminderInfos in project OpenOLAT by OpenOLAT.
the class ReminderDAOTest method getReminderInfos.
@Test
public void getReminderInfos() {
// create and reminder and an identity
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-6");
Identity recepient1 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-6a");
Identity recepient2 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-6b");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder savedReminder = createAndSaveReminder(entry, creator, 6);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(savedReminder);
// send 2 reminders
SentReminderImpl sentReminder1 = reminderDao.markAsSend(savedReminder, recepient1, "ok");
SentReminderImpl sentReminder2 = reminderDao.markAsSend(savedReminder, recepient2, "error");
dbInstance.commitAndCloseSession();
Assert.assertNotNull(sentReminder1);
Assert.assertNotNull(sentReminder2);
// check reminder infos
List<ReminderInfos> reminderInfos = reminderDao.getReminderInfos(entry);
Assert.assertNotNull(reminderInfos);
Assert.assertEquals(1, reminderInfos.size());
ReminderInfos reminderInfo = reminderInfos.get(0);
Assert.assertNotNull(reminderInfo);
Assert.assertEquals(savedReminder.getKey(), reminderInfo.getKey());
Assert.assertEquals(2, reminderInfo.getNumOfRemindersSent());
Assert.assertEquals(creator.getKey(), reminderInfo.getCreatorKey());
Assert.assertEquals("Reminder - 6", reminderInfo.getDescription());
}
use of org.olat.modules.reminder.model.ReminderInfos in project openolat by klemens.
the class ReminderDAOTest method getReminderInfos.
@Test
public void getReminderInfos() {
// create and reminder and an identity
Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-6");
Identity recepient1 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-6a");
Identity recepient2 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-6b");
RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
Reminder savedReminder = createAndSaveReminder(entry, creator, 6);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(savedReminder);
// send 2 reminders
SentReminderImpl sentReminder1 = reminderDao.markAsSend(savedReminder, recepient1, "ok");
SentReminderImpl sentReminder2 = reminderDao.markAsSend(savedReminder, recepient2, "error");
dbInstance.commitAndCloseSession();
Assert.assertNotNull(sentReminder1);
Assert.assertNotNull(sentReminder2);
// check reminder infos
List<ReminderInfos> reminderInfos = reminderDao.getReminderInfos(entry);
Assert.assertNotNull(reminderInfos);
Assert.assertEquals(1, reminderInfos.size());
ReminderInfos reminderInfo = reminderInfos.get(0);
Assert.assertNotNull(reminderInfo);
Assert.assertEquals(savedReminder.getKey(), reminderInfo.getKey());
Assert.assertEquals(2, reminderInfo.getNumOfRemindersSent());
Assert.assertEquals(creator.getKey(), reminderInfo.getCreatorKey());
Assert.assertEquals("Reminder - 6", reminderInfo.getDescription());
}
Aggregations