Search in sources :

Example 1 with ImportExportReminders

use of org.olat.modules.reminder.model.ImportExportReminders in project OpenOLAT by OpenOLAT.

the class ReminderServiceImpl method exportReminders.

@Override
public void exportReminders(RepositoryEntry entry, File fExportedDataDir) {
    List<Reminder> reminders = reminderDao.getReminders(entry);
    if (reminders.size() > 0) {
        try (OutputStream fOut = new FileOutputStream(new File(fExportedDataDir, REMINDERS_XML))) {
            ImportExportReminders exportReminders = new ImportExportReminders();
            for (Reminder reminder : reminders) {
                ImportExportReminder exportReminder = new ImportExportReminder(reminder);
                exportReminders.getReminders().add(exportReminder);
            }
            ruleXStream.toXML(exportReminders, fOut);
        } catch (Exception e) {
            log.error("", e);
        }
    }
}
Also used : ImportExportReminder(org.olat.modules.reminder.model.ImportExportReminder) SentReminder(org.olat.modules.reminder.SentReminder) Reminder(org.olat.modules.reminder.Reminder) ImportExportReminder(org.olat.modules.reminder.model.ImportExportReminder) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) ImportExportReminders(org.olat.modules.reminder.model.ImportExportReminders) ParseException(java.text.ParseException)

Example 2 with ImportExportReminders

use of org.olat.modules.reminder.model.ImportExportReminders in project OpenOLAT by OpenOLAT.

the class ReminderServiceImpl method importRawReminders.

@Override
public List<Reminder> importRawReminders(Identity creator, RepositoryEntry newEntry, File fExportedDataDir) {
    File reminderFile = new File(fExportedDataDir, REMINDERS_XML);
    List<Reminder> reminders = new ArrayList<>();
    if (reminderFile.exists()) {
        try (InputStream in = new FileInputStream(reminderFile)) {
            ImportExportReminders importReminders = (ImportExportReminders) ruleXStream.fromXML(in);
            List<ImportExportReminder> importReminderList = importReminders.getReminders();
            for (ImportExportReminder importReminder : importReminderList) {
                Reminder reminder = reminderDao.createReminder(newEntry, creator);
                reminder.setDescription(importReminder.getDescription());
                reminder.setEmailBody(importReminder.getEmailBody());
                reminder.setEmailSubject(importReminder.getEmailSubject() == null ? importReminder.getDescription() : importReminder.getEmailSubject());
                reminder.setConfiguration(importReminder.getConfiguration());
                reminders.add(reminder);
            }
        } catch (Exception e) {
            log.error("", e);
        }
    }
    return reminders;
}
Also used : ImportExportReminder(org.olat.modules.reminder.model.ImportExportReminder) SentReminder(org.olat.modules.reminder.SentReminder) Reminder(org.olat.modules.reminder.Reminder) ImportExportReminder(org.olat.modules.reminder.model.ImportExportReminder) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) File(java.io.File) ImportExportReminders(org.olat.modules.reminder.model.ImportExportReminders) FileInputStream(java.io.FileInputStream) ParseException(java.text.ParseException)

Example 3 with ImportExportReminders

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

the class ReminderServiceImpl method exportReminders.

@Override
public void exportReminders(RepositoryEntry entry, File fExportedDataDir) {
    List<Reminder> reminders = reminderDao.getReminders(entry);
    if (reminders.size() > 0) {
        try (OutputStream fOut = new FileOutputStream(new File(fExportedDataDir, REMINDERS_XML))) {
            ImportExportReminders exportReminders = new ImportExportReminders();
            for (Reminder reminder : reminders) {
                ImportExportReminder exportReminder = new ImportExportReminder(reminder);
                exportReminders.getReminders().add(exportReminder);
            }
            ruleXStream.toXML(exportReminders, fOut);
        } catch (Exception e) {
            log.error("", e);
        }
    }
}
Also used : ImportExportReminder(org.olat.modules.reminder.model.ImportExportReminder) SentReminder(org.olat.modules.reminder.SentReminder) Reminder(org.olat.modules.reminder.Reminder) ImportExportReminder(org.olat.modules.reminder.model.ImportExportReminder) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) ImportExportReminders(org.olat.modules.reminder.model.ImportExportReminders) ParseException(java.text.ParseException)

Example 4 with ImportExportReminders

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

the class ReminderServiceImpl method importRawReminders.

@Override
public List<Reminder> importRawReminders(Identity creator, RepositoryEntry newEntry, File fExportedDataDir) {
    File reminderFile = new File(fExportedDataDir, REMINDERS_XML);
    List<Reminder> reminders = new ArrayList<>();
    if (reminderFile.exists()) {
        try (InputStream in = new FileInputStream(reminderFile)) {
            ImportExportReminders importReminders = (ImportExportReminders) ruleXStream.fromXML(in);
            List<ImportExportReminder> importReminderList = importReminders.getReminders();
            for (ImportExportReminder importReminder : importReminderList) {
                Reminder reminder = reminderDao.createReminder(newEntry, creator);
                reminder.setDescription(importReminder.getDescription());
                reminder.setEmailBody(importReminder.getEmailBody());
                reminder.setEmailSubject(importReminder.getEmailSubject() == null ? importReminder.getDescription() : importReminder.getEmailSubject());
                reminder.setConfiguration(importReminder.getConfiguration());
                reminders.add(reminder);
            }
        } catch (Exception e) {
            log.error("", e);
        }
    }
    return reminders;
}
Also used : ImportExportReminder(org.olat.modules.reminder.model.ImportExportReminder) SentReminder(org.olat.modules.reminder.SentReminder) Reminder(org.olat.modules.reminder.Reminder) ImportExportReminder(org.olat.modules.reminder.model.ImportExportReminder) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) File(java.io.File) ImportExportReminders(org.olat.modules.reminder.model.ImportExportReminders) FileInputStream(java.io.FileInputStream) ParseException(java.text.ParseException)

Aggregations

File (java.io.File)4 ParseException (java.text.ParseException)4 Reminder (org.olat.modules.reminder.Reminder)4 SentReminder (org.olat.modules.reminder.SentReminder)4 ImportExportReminder (org.olat.modules.reminder.model.ImportExportReminder)4 ImportExportReminders (org.olat.modules.reminder.model.ImportExportReminders)4 FileInputStream (java.io.FileInputStream)2 FileOutputStream (java.io.FileOutputStream)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2