Search in sources :

Example 41 with Reminder

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

the class CourseSendReminderListController method doResend.

private void doResend(SentReminderRow row) {
    Reminder reloadedReminder = reminderService.loadByKey(row.getReminderKey());
    Identity id = securityManager.loadIdentityByKey(row.getIdentityKey());
    List<Identity> identitiesToRemind = Collections.singletonList(id);
    MailerResult result = reminderService.sendReminder(reloadedReminder, identitiesToRemind);
    if (result.getReturnCode() != MailerResult.OK) {
        MailHelper.printErrorsAndWarnings(result, getWindowControl(), false, getLocale());
    } else {
        showInfo("reminder.resend");
    }
    updateModel();
}
Also used : Reminder(org.olat.modules.reminder.Reminder) SentReminder(org.olat.modules.reminder.SentReminder) MailerResult(org.olat.core.util.mail.MailerResult) Identity(org.olat.core.id.Identity)

Example 42 with Reminder

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

the class CourseReminderLogsController method doResend.

private void doResend(SentReminderRow row) {
    Reminder reloadedReminder = reminderService.loadByKey(row.getReminderKey());
    Identity id = securityManager.loadIdentityByKey(row.getIdentityKey());
    List<Identity> identitiesToRemind = Collections.singletonList(id);
    MailerResult result = reminderService.sendReminder(reloadedReminder, identitiesToRemind);
    if (result.getReturnCode() != MailerResult.OK) {
        MailHelper.printErrorsAndWarnings(result, getWindowControl(), false, getLocale());
    } else {
        showInfo("reminder.resend");
    }
}
Also used : Reminder(org.olat.modules.reminder.Reminder) SentReminder(org.olat.modules.reminder.SentReminder) MailerResult(org.olat.core.util.mail.MailerResult) Identity(org.olat.core.id.Identity)

Example 43 with Reminder

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

the class CourseReminderLogsController method doOpenReminder.

private void doOpenReminder(UserRequest ureq, SentReminderRow row) {
    removeAsListenerAndDispose(reminderEditCtrl);
    Reminder reminder = reminderService.loadByKey(row.getReminderKey());
    reminderEditCtrl = new CourseReminderEditController(ureq, getWindowControl(), reminder);
    listenTo(reminderEditCtrl);
    toolbarPanel.pushController(translate("edit.reminder"), reminderEditCtrl);
}
Also used : Reminder(org.olat.modules.reminder.Reminder) SentReminder(org.olat.modules.reminder.SentReminder)

Example 44 with Reminder

use of org.olat.modules.reminder.Reminder in project openolat by klemens.

the class CourseHandler method cloneReminders.

private void cloneReminders(Identity author, CourseEnvironmentMapper envMapper, RepositoryEntry source, RepositoryEntry target) {
    ReminderModule reminderModule = CoreSpringFactory.getImpl(ReminderModule.class);
    ReminderService reminderService = CoreSpringFactory.getImpl(ReminderService.class);
    List<Reminder> reminders = reminderService.getReminders(source);
    for (Reminder reminder : reminders) {
        String configuration = reminder.getConfiguration();
        ReminderRules rules = reminderService.toRules(configuration);
        ReminderRules clonedRules = new ReminderRules();
        for (ReminderRule rule : rules.getRules()) {
            RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
            if (ruleSpi != null) {
                ReminderRule clonedRule = ruleSpi.clone(rule, envMapper);
                if (clonedRule != null)
                    clonedRules.getRules().add(clonedRule);
            }
        }
        Reminder clonedReminder = reminderService.createReminder(target, author);
        clonedReminder.setDescription(reminder.getDescription());
        clonedReminder.setEmailSubject(reminder.getEmailSubject());
        clonedReminder.setEmailBody(reminder.getEmailBody());
        clonedReminder.setConfiguration(reminderService.toXML(clonedRules));
        reminderService.save(clonedReminder);
    }
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) Reminder(org.olat.modules.reminder.Reminder) ReminderService(org.olat.modules.reminder.ReminderService) ReminderRules(org.olat.modules.reminder.model.ReminderRules) RuleSPI(org.olat.modules.reminder.RuleSPI) ReminderModule(org.olat.modules.reminder.ReminderModule)

Example 45 with Reminder

use of org.olat.modules.reminder.Reminder in project openolat by klemens.

the class CourseHandler method importReminders.

private void importReminders(RepositoryEntry re, File fImportBaseDirectory, CourseEnvironmentMapper envMapper, Identity initialAuthor) {
    ReminderModule reminderModule = CoreSpringFactory.getImpl(ReminderModule.class);
    ReminderService reminderService = CoreSpringFactory.getImpl(ReminderService.class);
    List<Reminder> reminders = reminderService.importRawReminders(initialAuthor, re, fImportBaseDirectory);
    if (reminders.size() > 0) {
        for (Reminder reminder : reminders) {
            ReminderRules clonedRules = new ReminderRules();
            String configuration = reminder.getConfiguration();
            ReminderRules rules = reminderService.toRules(configuration);
            for (ReminderRule rule : rules.getRules()) {
                RuleSPI ruleSpi = reminderModule.getRuleSPIByType(rule.getType());
                if (ruleSpi != null) {
                    ReminderRule clonedRule = ruleSpi.clone(rule, envMapper);
                    clonedRules.getRules().add(clonedRule);
                }
            }
            String convertedConfiguration = reminderService.toXML(clonedRules);
            reminder.setConfiguration(convertedConfiguration);
            reminderService.save(reminder);
        }
    }
}
Also used : ReminderRule(org.olat.modules.reminder.ReminderRule) Reminder(org.olat.modules.reminder.Reminder) ReminderService(org.olat.modules.reminder.ReminderService) ReminderRules(org.olat.modules.reminder.model.ReminderRules) RuleSPI(org.olat.modules.reminder.RuleSPI) ReminderModule(org.olat.modules.reminder.ReminderModule)

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