use of org.apache.openmeetings.backup.converter.OmCalendarConverter in project openmeetings by apache.
the class BackupImport method importAppointments.
/*
* ##################### Import Appointements
*/
private void importAppointments(File f) throws Exception {
log.info("Calendar import complete, starting appointement import");
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
registry.bind(User.class, new UserConverter(userDao, userMap));
registry.bind(Appointment.Reminder.class, AppointmentReminderTypeConverter.class);
registry.bind(Room.class, new RoomConverter(roomDao, roomMap));
registry.bind(Date.class, DateConverter.class);
registry.bind(OmCalendar.class, new OmCalendarConverter(calendarDao, calendarMap));
List<Appointment> list = readList(serializer, f, "appointements.xml", "appointments", Appointment.class);
for (Appointment a : list) {
Long appId = a.getId();
// We need to reset this as openJPA reject to store them otherwise
a.setId(null);
if (a.getOwner() != null && a.getOwner().getId() == null) {
a.setOwner(null);
}
if (a.getRoom() == null || a.getRoom().getId() == null) {
log.warn("Appointment without room was found, skipping: {}", a);
continue;
}
if (a.getStart() == null || a.getEnd() == null) {
log.warn("Appointment without start/end time was found, skipping: {}", a);
continue;
}
a = appointmentDao.update(a, null, false);
appointmentMap.put(appId, a.getId());
}
}
Aggregations