Search in sources :

Example 1 with SentReminder

use of org.olat.modules.reminder.SentReminder in project OpenOLAT by OpenOLAT.

the class ReminderDAOTest method deleteReminder.

@Test
public void deleteReminder() {
    // create and reminder and an identity
    Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-9");
    Identity recepient1 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-9a");
    Identity recepient2 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-9b");
    Identity recepient3 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-9c");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Reminder reminderToDelete = createAndSaveReminder(entry, creator, 8);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(reminderToDelete);
    // send 4 reminders
    reminderDao.markAsSend(reminderToDelete, recepient1, "ok");
    reminderDao.markAsSend(reminderToDelete, recepient2, "error");
    reminderDao.markAsSend(reminderToDelete, recepient3, "error");
    reminderDao.markAsSend(reminderToDelete, recepient2, "error");
    dbInstance.commitAndCloseSession();
    // check
    List<SentReminder> sentReminders = reminderDao.getSendReminders(reminderToDelete);
    Assert.assertNotNull(sentReminders);
    Assert.assertEquals(4, sentReminders.size());
    reminderDao.delete(reminderToDelete);
    dbInstance.commit();
    // check that the reminder is missing
    List<Reminder> deletedReminders = reminderDao.getReminders(entry);
    Assert.assertNotNull(deletedReminders);
    Assert.assertEquals(0, deletedReminders.size());
}
Also used : Reminder(org.olat.modules.reminder.Reminder) SentReminder(org.olat.modules.reminder.SentReminder) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) SentReminder(org.olat.modules.reminder.SentReminder) Test(org.junit.Test)

Example 2 with SentReminder

use of org.olat.modules.reminder.SentReminder in project OpenOLAT by OpenOLAT.

the class ReminderDAOTest method getSendReminders_byRepositoryEntry.

@Test
public void getSendReminders_byRepositoryEntry() {
    // create and reminder and an identity
    Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-8");
    Identity recepient1 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-8a");
    Identity recepient2 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-8b");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Reminder savedReminder = createAndSaveReminder(entry, creator, 8);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(savedReminder);
    // send 3 reminders
    SentReminderImpl sentReminder1 = reminderDao.markAsSend(savedReminder, recepient1, "ok");
    SentReminderImpl sentReminder2 = reminderDao.markAsSend(savedReminder, recepient2, "error");
    SentReminderImpl sentReminder3 = reminderDao.markAsSend(savedReminder, recepient2, "error");
    dbInstance.commitAndCloseSession();
    // load the sent reminder log
    List<SentReminder> sentReminders = reminderDao.getSendReminders(entry);
    Assert.assertNotNull(sentReminders);
    Assert.assertEquals(3, sentReminders.size());
    Assert.assertTrue(sentReminders.contains(sentReminder1));
    Assert.assertTrue(sentReminders.contains(sentReminder2));
    Assert.assertTrue(sentReminders.contains(sentReminder3));
}
Also used : 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) SentReminder(org.olat.modules.reminder.SentReminder) Test(org.junit.Test)

Example 3 with SentReminder

use of org.olat.modules.reminder.SentReminder in project OpenOLAT by OpenOLAT.

the class ReminderDAOTest method getSendReminders_byReminder.

@Test
public void getSendReminders_byReminder() {
    // create and reminder and an identity
    Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-7");
    Identity recepient1 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-7a");
    Identity recepient2 = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-7b");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Reminder savedReminder = createAndSaveReminder(entry, creator, 7);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(savedReminder);
    // send 3 reminders
    SentReminderImpl sentReminder1 = reminderDao.markAsSend(savedReminder, recepient1, "ok");
    SentReminderImpl sentReminder2 = reminderDao.markAsSend(savedReminder, recepient2, "error");
    SentReminderImpl sentReminder3 = reminderDao.markAsSend(savedReminder, recepient1, "error");
    dbInstance.commitAndCloseSession();
    // load the sent reminder log
    List<SentReminder> sentReminders = reminderDao.getSendReminders(savedReminder);
    Assert.assertNotNull(sentReminders);
    Assert.assertEquals(3, sentReminders.size());
    Assert.assertTrue(sentReminders.contains(sentReminder1));
    Assert.assertTrue(sentReminders.contains(sentReminder2));
    Assert.assertTrue(sentReminders.contains(sentReminder3));
}
Also used : 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) SentReminder(org.olat.modules.reminder.SentReminder) Test(org.junit.Test)

Example 4 with SentReminder

use of org.olat.modules.reminder.SentReminder in project OpenOLAT by OpenOLAT.

the class CourseReminderLogsController method updateModel.

protected void updateModel() {
    List<SentReminder> sentReminders = reminderService.getSentReminders(repositoryEntry);
    List<SentReminderRow> rows = new ArrayList<>(sentReminders.size());
    for (SentReminder sentReminder : sentReminders) {
        Identity identity = sentReminder.getIdentity();
        Reminder reminder = sentReminder.getReminder();
        SentReminderRow row = new SentReminderRow(reminder, sentReminder, identity, userPropertyHandlers, getLocale());
        rows.add(row);
    }
    tableModel.setObjects(rows);
    tableEl.reset();
    tableEl.setVisible(rows.size() > 0);
}
Also used : Reminder(org.olat.modules.reminder.Reminder) SentReminder(org.olat.modules.reminder.SentReminder) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) SentReminder(org.olat.modules.reminder.SentReminder) SentReminderRow(org.olat.course.reminder.model.SentReminderRow)

Example 5 with SentReminder

use of org.olat.modules.reminder.SentReminder in project OpenOLAT by OpenOLAT.

the class CourseSendReminderListController method updateModel.

private void updateModel() {
    List<SentReminder> sentReminders = reminderService.getSentReminders(reminder);
    List<SentReminderRow> rows = new ArrayList<>(sentReminders.size());
    for (SentReminder sentReminder : sentReminders) {
        Identity identity = sentReminder.getIdentity();
        SentReminderRow row = new SentReminderRow(reminder, sentReminder, identity, userPropertyHandlers, getLocale());
        rows.add(row);
    }
    tableModel.setObjects(rows);
    tableEl.reset();
}
Also used : ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) SentReminder(org.olat.modules.reminder.SentReminder) SentReminderRow(org.olat.course.reminder.model.SentReminderRow)

Aggregations

Identity (org.olat.core.id.Identity)16 SentReminder (org.olat.modules.reminder.SentReminder)16 Reminder (org.olat.modules.reminder.Reminder)14 Test (org.junit.Test)12 RepositoryEntry (org.olat.repository.RepositoryEntry)12 SentReminderImpl (org.olat.modules.reminder.model.SentReminderImpl)6 ArrayList (java.util.ArrayList)4 SentReminderRow (org.olat.course.reminder.model.SentReminderRow)4