Search in sources :

Example 31 with Strategy

use of org.simpleframework.xml.strategy.Strategy 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 32 with Strategy

use of org.simpleframework.xml.strategy.Strategy 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)

Example 33 with Strategy

use of org.simpleframework.xml.strategy.Strategy 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)

Example 34 with Strategy

use of org.simpleframework.xml.strategy.Strategy in project openmeetings by apache.

the class BackupImport method importRoomFiles.

/*
	 * ##################### Import Room Files
	 */
private void importRoomFiles(File f) throws Exception {
    log.info("Poll import complete, starting room files import");
    Registry registry = new Registry();
    Strategy strategy = new RegistryStrategy(registry);
    Serializer serializer = new Persister(strategy);
    registry.bind(BaseFileItem.class, new BaseFileItemConverter(fileItemDao, fileItemMap));
    List<RoomFile> list = readList(serializer, f, "roomFiles.xml", "RoomFiles", RoomFile.class, true);
    for (RoomFile rf : list) {
        Room r = roomDao.get(roomMap.get(rf.getRoomId()));
        if (r == null || rf.getFile() == null || rf.getFile().getId() == null) {
            continue;
        }
        if (r.getFiles() == null) {
            r.setFiles(new ArrayList<>());
        }
        rf.setId(null);
        rf.setRoomId(r.getId());
        r.getFiles().add(rf);
        roomDao.update(r, null);
    }
}
Also used : BaseFileItemConverter(org.apache.openmeetings.backup.converter.BaseFileItemConverter) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) RoomFile(org.apache.openmeetings.db.entity.room.RoomFile) RegistryStrategy(org.simpleframework.xml.convert.RegistryStrategy) Strategy(org.simpleframework.xml.strategy.Strategy) Registry(org.simpleframework.xml.convert.Registry) Persister(org.simpleframework.xml.core.Persister) Room(org.apache.openmeetings.db.entity.room.Room) Serializer(org.simpleframework.xml.Serializer)

Aggregations

Persister (org.simpleframework.xml.core.Persister)34 Strategy (org.simpleframework.xml.strategy.Strategy)34 Registry (org.simpleframework.xml.convert.Registry)33 RegistryStrategy (org.simpleframework.xml.convert.RegistryStrategy)33 Serializer (org.simpleframework.xml.Serializer)31 UserConverter (org.apache.openmeetings.backup.converter.UserConverter)9 RegistryMatcher (org.simpleframework.xml.transform.RegistryMatcher)7 RoomConverter (org.apache.openmeetings.backup.converter.RoomConverter)5 Room (org.apache.openmeetings.db.entity.room.Room)4 FileItem (org.apache.openmeetings.db.entity.file.FileItem)3 IOException (java.io.IOException)2 GroupConverter (org.apache.openmeetings.backup.converter.GroupConverter)2 ChatMessage (org.apache.openmeetings.db.entity.basic.ChatMessage)2 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)2 OmCalendar (org.apache.openmeetings.db.entity.calendar.OmCalendar)2 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)2 Recording (org.apache.openmeetings.db.entity.record.Recording)2 RoomFile (org.apache.openmeetings.db.entity.room.RoomFile)2 RoomPoll (org.apache.openmeetings.db.entity.room.RoomPoll)2 PrivateMessage (org.apache.openmeetings.db.entity.user.PrivateMessage)2