use of org.apache.openmeetings.backup.converter.RoomConverter in project openmeetings by apache.
the class BackupImport method importChat.
/*
* ##################### Import Chat messages
*/
private void importChat(File f) throws Exception {
log.info("Room groups import complete, starting chat messages 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(Room.class, new RoomConverter(roomDao, roomMap));
registry.bind(Date.class, DateConverter.class);
List<ChatMessage> list = readList(serializer, f, "chat_messages.xml", "chat_messages", ChatMessage.class);
for (ChatMessage m : list) {
m.setId(null);
if (m.getFromUser() == null || m.getFromUser().getId() == null) {
continue;
}
chatDao.update(m, m.getSent());
}
}
use of org.apache.openmeetings.backup.converter.RoomConverter 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());
}
}
use of org.apache.openmeetings.backup.converter.RoomConverter in project openmeetings by apache.
the class BackupImport method importPrivateMsgs.
/*
* ##################### Import Private Messages
*/
private void importPrivateMsgs(File f) throws Exception {
log.info("Usercontact import complete, starting private messages item 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(Room.class, new RoomConverter(roomDao, roomMap));
registry.bind(Date.class, DateConverter.class);
List<PrivateMessage> list = readList(serializer, f, "privateMessages.xml", "privatemessages", PrivateMessage.class);
boolean oldBackup = true;
for (PrivateMessage p : list) {
if (p.getFolderId() == null || p.getFolderId().longValue() < 0) {
oldBackup = false;
break;
}
}
for (PrivateMessage p : list) {
p.setId(null);
p.setFolderId(messageFolderMap.get(p.getFolderId()));
p.setUserContactId(userContactMap.get(p.getUserContactId()));
if (p.getRoom() != null && p.getRoom().getId() == null) {
p.setRoom(null);
}
if (p.getTo() != null && p.getTo().getId() == null) {
p.setTo(null);
}
if (p.getFrom() != null && p.getFrom().getId() == null) {
p.setFrom(null);
}
if (p.getOwner() != null && p.getOwner().getId() == null) {
p.setOwner(null);
}
if (oldBackup && p.getOwner() != null && p.getOwner().getId() != null && p.getFrom() != null && p.getFrom().getId() != null && p.getOwner().getId() == p.getFrom().getId()) {
p.setFolderId(SENT_FOLDER_ID);
}
privateMessageDao.update(p, null);
}
}
use of org.apache.openmeetings.backup.converter.RoomConverter in project openmeetings by apache.
the class BackupImport method importPolls.
/*
* ##################### Import Room Polls
*/
private void importPolls(File f) throws Exception {
log.info("File explorer item import complete, starting room poll import");
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
RegistryMatcher matcher = new RegistryMatcher();
Serializer serializer = new Persister(strategy, matcher);
matcher.bind(Integer.class, IntegerTransform.class);
registry.bind(User.class, new UserConverter(userDao, userMap));
registry.bind(Room.class, new RoomConverter(roomDao, roomMap));
registry.bind(RoomPoll.Type.class, PollTypeConverter.class);
registry.bind(Date.class, DateConverter.class);
List<RoomPoll> list = readList(serializer, f, "roompolls.xml", "roompolls", RoomPoll.class);
for (RoomPoll rp : list) {
rp.setId(null);
if (rp.getRoom() == null || rp.getRoom().getId() == null) {
// room was deleted
continue;
}
if (rp.getCreator() == null || rp.getCreator().getId() == null) {
rp.setCreator(null);
}
for (RoomPollAnswer rpa : rp.getAnswers()) {
if (rpa.getVotedUser() == null || rpa.getVotedUser().getId() == null) {
rpa.setVotedUser(null);
}
}
pollDao.update(rp);
}
}
use of org.apache.openmeetings.backup.converter.RoomConverter in project openmeetings by apache.
the class BackupImport method importRoomGroups.
/*
* ##################### Import Room Groups
*/
private void importRoomGroups(File f) throws Exception {
log.info("Room import complete, starting room groups import");
Registry registry = new Registry();
Strategy strategy = new RegistryStrategy(registry);
Serializer serializer = new Persister(strategy);
registry.bind(Group.class, new GroupConverter(groupDao, groupMap));
registry.bind(Room.class, new RoomConverter(roomDao, roomMap));
List<RoomGroup> list = readList(serializer, f, "rooms_organisation.xml", "room_organisations", RoomGroup.class);
for (RoomGroup ro : list) {
Room r = roomDao.get(ro.getRoom().getId());
if (r == null || ro.getGroup() == null || ro.getGroup().getId() == null) {
continue;
}
if (r.getGroups() == null) {
r.setGroups(new ArrayList<>());
}
ro.setId(null);
ro.setRoom(r);
r.getGroups().add(ro);
roomDao.update(r, null);
}
}
Aggregations