Search in sources :

Example 1 with ReminderInfos

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);
}
Also used : ReminderInfos(org.olat.modules.reminder.model.ReminderInfos) ReminderRow(org.olat.course.reminder.model.ReminderRow) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 2 with ReminderInfos

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;
}
Also used : ReminderInfos(org.olat.modules.reminder.model.ReminderInfos) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 3 with ReminderInfos

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);
}
Also used : ReminderInfos(org.olat.modules.reminder.model.ReminderInfos) ReminderRow(org.olat.course.reminder.model.ReminderRow) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink)

Example 4 with ReminderInfos

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());
}
Also used : ReminderInfos(org.olat.modules.reminder.model.ReminderInfos) Reminder(org.olat.modules.reminder.Reminder) SentReminder(org.olat.modules.reminder.SentReminder) SentReminderImpl(org.olat.modules.reminder.model.SentReminderImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 5 with ReminderInfos

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());
}
Also used : ReminderInfos(org.olat.modules.reminder.model.ReminderInfos) Reminder(org.olat.modules.reminder.Reminder) SentReminder(org.olat.modules.reminder.SentReminder) SentReminderImpl(org.olat.modules.reminder.model.SentReminderImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

ReminderInfos (org.olat.modules.reminder.model.ReminderInfos)6 ArrayList (java.util.ArrayList)4 Date (java.util.Date)2 Test (org.junit.Test)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 Identity (org.olat.core.id.Identity)2 ReminderRow (org.olat.course.reminder.model.ReminderRow)2 Reminder (org.olat.modules.reminder.Reminder)2 SentReminder (org.olat.modules.reminder.SentReminder)2 SentReminderImpl (org.olat.modules.reminder.model.SentReminderImpl)2 RepositoryEntry (org.olat.repository.RepositoryEntry)2