Search in sources :

Example 1 with RoomConverter

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());
    }
}
Also used : UserConverter(org.apache.openmeetings.backup.converter.UserConverter) RoomConverter(org.apache.openmeetings.backup.converter.RoomConverter) ChatMessage(org.apache.openmeetings.db.entity.basic.ChatMessage) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 2 with RoomConverter

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());
    }
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) OmCalendarConverter(org.apache.openmeetings.backup.converter.OmCalendarConverter) UserConverter(org.apache.openmeetings.backup.converter.UserConverter) RoomConverter(org.apache.openmeetings.backup.converter.RoomConverter) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 3 with RoomConverter

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);
    }
}
Also used : UserConverter(org.apache.openmeetings.backup.converter.UserConverter) RoomConverter(org.apache.openmeetings.backup.converter.RoomConverter) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) PrivateMessage(org.apache.openmeetings.db.entity.user.PrivateMessage) Serializer(org.simpleframework.xml.Serializer)

Example 4 with RoomConverter

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);
    }
}
Also used : UserConverter(org.apache.openmeetings.backup.converter.UserConverter) RoomConverter(org.apache.openmeetings.backup.converter.RoomConverter) RoomPollAnswer(org.apache.openmeetings.db.entity.room.RoomPollAnswer) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) RegistryMatcher(org.simpleframework.xml.transform.RegistryMatcher) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) RoomPoll(org.apache.openmeetings.db.entity.room.RoomPoll) Serializer(org.simpleframework.xml.Serializer)

Example 5 with RoomConverter

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);
    }
}
Also used : GroupConverter(org.apache.openmeetings.backup.converter.GroupConverter) RoomConverter(org.apache.openmeetings.backup.converter.RoomConverter) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup) Room(org.apache.openmeetings.db.entity.room.Room) Serializer(org.simpleframework.xml.Serializer)

Aggregations

RoomConverter (org.apache.openmeetings.backup.converter.RoomConverter)5 Serializer (org.simpleframework.xml.Serializer)5 Registry (org.simpleframework.xml.convert.Registry)5 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)5 Persister (org.simpleframework.xml.core.Persister)5 Strategy (org.simpleframework.xml.strategy.Strategy)5 UserConverter (org.apache.openmeetings.backup.converter.UserConverter)4 GroupConverter (org.apache.openmeetings.backup.converter.GroupConverter)1 OmCalendarConverter (org.apache.openmeetings.backup.converter.OmCalendarConverter)1 ChatMessage (org.apache.openmeetings.db.entity.basic.ChatMessage)1 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)1 Room (org.apache.openmeetings.db.entity.room.Room)1 RoomGroup (org.apache.openmeetings.db.entity.room.RoomGroup)1 RoomPoll (org.apache.openmeetings.db.entity.room.RoomPoll)1 RoomPollAnswer (org.apache.openmeetings.db.entity.room.RoomPollAnswer)1 PrivateMessage (org.apache.openmeetings.db.entity.user.PrivateMessage)1 RegistryMatcher (org.simpleframework.xml.transform.RegistryMatcher)1