Search in sources :

Example 36 with Reminder

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

the class ReminderDAOTest method duplicateReminder.

@Test
public void duplicateReminder() {
    Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-12");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Reminder reminderToCopy = createAndSaveReminder(entry, creator, 12);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(reminderToCopy);
    Reminder duplicate = reminderDao.duplicate(reminderToCopy, creator);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(duplicate);
    Assert.assertNotNull(duplicate.getKey());
    ReminderImpl reloadedDuplicate = (ReminderImpl) reminderDao.loadByKey(duplicate.getKey());
    Assert.assertNotNull(reloadedDuplicate);
    Assert.assertEquals(creator, reloadedDuplicate.getCreator());
    Assert.assertEquals(entry, reloadedDuplicate.getEntry());
    Assert.assertEquals(reminderToCopy.getEmailBody(), reloadedDuplicate.getEmailBody());
    Assert.assertEquals(reminderToCopy.getEmailSubject(), reloadedDuplicate.getEmailSubject());
    Assert.assertTrue(reloadedDuplicate.getDescription().startsWith(reminderToCopy.getDescription()));
    Assert.assertEquals(reminderToCopy.getConfiguration(), reloadedDuplicate.getConfiguration());
}
Also used : Reminder(org.olat.modules.reminder.Reminder) SentReminder(org.olat.modules.reminder.SentReminder) ReminderImpl(org.olat.modules.reminder.model.ReminderImpl) SentReminderImpl(org.olat.modules.reminder.model.SentReminderImpl) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 37 with Reminder

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

the class ReminderDAOTest method createAndPersistSendReminder.

@Test
public void createAndPersistSendReminder() {
    // create and reminder and an identity
    Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-2");
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("mind-1");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Reminder reminder = reminderDao.createReminder(entry, creator);
    reminder.setConfiguration("<rules></rules>");
    reminder.setDescription("Reminder - 2");
    reminder.setEmailSubject("This is a subject");
    reminder.setEmailBody("Hello world");
    Reminder savedReminder = reminderDao.save(reminder);
    Assert.assertNotNull(savedReminder);
    dbInstance.commitAndCloseSession();
    // mark as sent
    reminderDao.markAsSend(reminder, id, "ok");
    dbInstance.commitAndCloseSession();
    // reload
    List<SentReminder> sentReminders = reminderDao.getSendReminders(savedReminder);
    Assert.assertNotNull(sentReminders);
    Assert.assertEquals(1, sentReminders.size());
    SentReminder sentReminder = sentReminders.get(0);
    Assert.assertNotNull(sentReminder);
    Assert.assertNotNull(sentReminder.getCreationDate());
    Assert.assertEquals(id, sentReminder.getIdentity());
    Assert.assertEquals(savedReminder, sentReminder.getReminder());
}
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 38 with Reminder

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

the class ReminderDAOTest method markAsSend.

@Test
public void markAsSend() {
    // create and reminder and an identity
    Identity creator = JunitTestHelper.createAndPersistIdentityAsRndUser("creator-rem-5");
    Identity recepient = JunitTestHelper.createAndPersistIdentityAsRndUser("recepient-rem-5");
    RepositoryEntry entry = JunitTestHelper.createAndPersistRepositoryEntry();
    Reminder savedReminder = createAndSaveReminder(entry, creator, 5);
    Assert.assertNotNull(savedReminder);
    dbInstance.commitAndCloseSession();
    SentReminderImpl sentReminder = reminderDao.markAsSend(savedReminder, recepient, "ok");
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(sentReminder);
    Assert.assertNotNull(sentReminder.getKey());
    Assert.assertEquals("ok", sentReminder.getStatus());
    Assert.assertEquals(savedReminder, sentReminder.getReminder());
    Assert.assertEquals(recepient, sentReminder.getIdentity());
}
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) Test(org.junit.Test)

Example 39 with Reminder

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

the class CourseReminderListController method doDelete.

private void doDelete(ReminderRow row) {
    Reminder reminder = reminderManager.loadByKey(row.getKey());
    reminderManager.delete(reminder);
    updateModel();
}
Also used : Reminder(org.olat.modules.reminder.Reminder)

Example 40 with Reminder

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

the class CourseReminderListController method doSendReminderList.

private void doSendReminderList(UserRequest ureq, Long reminderKey) {
    removeAsListenerAndDispose(sendReminderListCtrl);
    OLATResourceable ores = OresHelper.createOLATResourceableInstance("SentReminders", reminderKey);
    ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
    WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, getWindowControl());
    Reminder reminder = reminderManager.loadByKey(reminderKey);
    sendReminderListCtrl = new CourseSendReminderListController(ureq, bwControl, reminder);
    listenTo(sendReminderListCtrl);
    addToHistory(ureq, sendReminderListCtrl);
    toolbarPanel.pushController(translate("send.reminder"), sendReminderListCtrl);
}
Also used : Reminder(org.olat.modules.reminder.Reminder) OLATResourceable(org.olat.core.id.OLATResourceable) WindowControl(org.olat.core.gui.control.WindowControl)

Aggregations

Reminder (org.olat.modules.reminder.Reminder)62 SentReminder (org.olat.modules.reminder.SentReminder)46 Identity (org.olat.core.id.Identity)32 Test (org.junit.Test)26 RepositoryEntry (org.olat.repository.RepositoryEntry)26 SentReminderImpl (org.olat.modules.reminder.model.SentReminderImpl)10 Date (java.util.Date)8 ImportExportReminder (org.olat.modules.reminder.model.ImportExportReminder)6 File (java.io.File)4 ParseException (java.text.ParseException)4 ArrayList (java.util.ArrayList)4 MailerResult (org.olat.core.util.mail.MailerResult)4 ReminderModule (org.olat.modules.reminder.ReminderModule)4 ReminderRule (org.olat.modules.reminder.ReminderRule)4 ReminderService (org.olat.modules.reminder.ReminderService)4 RuleSPI (org.olat.modules.reminder.RuleSPI)4 ImportExportReminders (org.olat.modules.reminder.model.ImportExportReminders)4 ReminderRules (org.olat.modules.reminder.model.ReminderRules)4 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2