Search in sources :

Example 6 with UserConverter

use of org.apache.openmeetings.backup.converter.UserConverter in project openmeetings by apache.

the class BackupImport method importCalendars.

/*
	 * ##################### Import Calendars
	 */
private void importCalendars(File f) throws Exception {
    log.info("Chat messages import complete, starting calendar import");
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer serializer = new Persister(strategy);
    registry.bind(User.class, new UserConverter(userDao, userMap));
    List<OmCalendar> list = readList(serializer, f, "calendars.xml", "calendars", OmCalendar.class, true);
    for (OmCalendar c : list) {
        Long id = c.getId();
        c.setId(null);
        c = calendarDao.update(c);
        calendarMap.put(id, c.getId());
    }
}
Also used : UserConverter(org.apache.openmeetings.backup.converter.UserConverter) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) OmCalendar(org.apache.openmeetings.db.entity.calendar.OmCalendar) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Serializer(org.simpleframework.xml.Serializer)

Example 7 with UserConverter

use of org.apache.openmeetings.backup.converter.UserConverter 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 8 with UserConverter

use of org.apache.openmeetings.backup.converter.UserConverter in project openmeetings by apache.

the class BackupImport method importMeetingMembers.

/*
	 * ##################### Import MeetingMembers
	 *
	 * Reminder Invitations will be NOT send!
	 */
private void importMeetingMembers(File f) throws Exception {
    log.info("Appointement import complete, starting meeting members import");
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer ser = new Persister(strategy);
    registry.bind(User.class, new UserConverter(userDao, userMap));
    registry.bind(Appointment.class, new AppointmentConverter(appointmentDao, appointmentMap));
    List<MeetingMember> list = readList(ser, f, "meetingmembers.xml", "meetingmembers", MeetingMember.class);
    for (MeetingMember ma : list) {
        ma.setId(null);
        meetingMemberDao.update(ma);
    }
}
Also used : UserConverter(org.apache.openmeetings.backup.converter.UserConverter) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) AppointmentConverter(org.apache.openmeetings.backup.converter.AppointmentConverter) Serializer(org.simpleframework.xml.Serializer)

Example 9 with UserConverter

use of org.apache.openmeetings.backup.converter.UserConverter in project openmeetings by apache.

the class BackupImport method importContacts.

/*
	 * ##################### Import User Contacts
	 */
private void importContacts(File f) throws Exception {
    log.info("Private message folder import complete, starting user contacts import");
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer serializer = new Persister(strategy);
    registry.bind(User.class, new UserConverter(userDao, userMap));
    List<UserContact> list = readList(serializer, f, "userContacts.xml", "usercontacts", UserContact.class);
    for (UserContact uc : list) {
        Long ucId = uc.getId();
        UserContact storedUC = userContactDao.get(ucId);
        if (storedUC == null && uc.getContact() != null && uc.getContact().getId() != null) {
            uc.setId(null);
            if (uc.getOwner() != null && uc.getOwner().getId() == null) {
                uc.setOwner(null);
            }
            uc = userContactDao.update(uc);
            userContactMap.put(ucId, uc.getId());
        }
    }
}
Also used : UserConverter(org.apache.openmeetings.backup.converter.UserConverter) UserContact(org.apache.openmeetings.db.entity.user.UserContact) 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)

Aggregations

UserConverter (org.apache.openmeetings.backup.converter.UserConverter)9 Serializer (org.simpleframework.xml.Serializer)9 Registry (org.simpleframework.xml.convert.Registry)9 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)9 Persister (org.simpleframework.xml.core.Persister)9 Strategy (org.simpleframework.xml.strategy.Strategy)9 RoomConverter (org.apache.openmeetings.backup.converter.RoomConverter)4 RegistryMatcher (org.simpleframework.xml.transform.RegistryMatcher)3 IOException (java.io.IOException)1 AppointmentConverter (org.apache.openmeetings.backup.converter.AppointmentConverter)1 OmCalendarConverter (org.apache.openmeetings.backup.converter.OmCalendarConverter)1 ChatMessage (org.apache.openmeetings.db.entity.basic.ChatMessage)1 Configuration (org.apache.openmeetings.db.entity.basic.Configuration)1 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)1 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)1 OmCalendar (org.apache.openmeetings.db.entity.calendar.OmCalendar)1 Room (org.apache.openmeetings.db.entity.room.Room)1 RoomModerator (org.apache.openmeetings.db.entity.room.RoomModerator)1 RoomPoll (org.apache.openmeetings.db.entity.room.RoomPoll)1 RoomPollAnswer (org.apache.openmeetings.db.entity.room.RoomPollAnswer)1