Package org.apache.openmeetings.backup

Examples of org.apache.openmeetings.backup.RoomConverter


      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(Organisation.class, new OrganisationConverter(orgDao, organisationsMap));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
     
      List<RoomOrganisation> list = readList(serializer, f, "rooms_organisation.xml", "room_organisations", RoomOrganisation.class);
      for (RoomOrganisation ro : list) {
        if (!ro.getDeleted()) {
          // We need to reset this as openJPA reject to store them otherwise
          ro.setRooms_organisation_id(null);
          roomManager.addRoomOrganisation(ro);
        }
      }
    }

    log.info("Room organizations import complete, starting appointement import");
    /*
     * ##################### Import Appointements
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(AppointmentCategory.class, new AppointmentCategoryConverter(appointmentCategoryDaoImpl));
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(AppointmentReminderTyps.class, new AppointmentReminderTypeConverter(appointmentReminderTypDaoImpl));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
      registry.bind(Date.class, DateConverter.class);
     
      List<Appointment> list = readList(serializer, f, "appointements.xml", "appointments", Appointment.class);
      for (Appointment a : list) {
        Long appId = a.getAppointmentId();

        // We need to reset this as openJPA reject to store them otherwise
        a.setAppointmentId(null);
        if (a.getUserId() != null && a.getUserId().getUser_id() == null) {
          a.setUserId(null);
        }
        Long newAppId = appointmentDao.addAppointmentObj(a);
        appointmentsMap.put(appId, newAppId);
      }
    }

    log.info("Appointement import complete, starting meeting members import");
    /*
     * ##################### Import MeetingMembers
     *
     * Reminder Invitations will be NOT send!
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(Appointment.class, new AppointmentConverter(appointmentDao, appointmentsMap));
     
      List<MeetingMember> list = readList(serializer, f, "meetingmembers.xml", "meetingmembers", MeetingMember.class);
      for (MeetingMember ma : list) {
        if (ma.getUserid() != null && ma.getUserid().getUser_id() == null) {
          ma.setUserid(null);
        }
        if (!ma.getDeleted()) {
          // We need to reset this as openJPA reject to store them otherwise
          ma.setMeetingMemberId(null);
          meetingMemberDao.addMeetingMemberByObject(ma);
        }
      }
    }

    log.info("Meeting members import complete, starting ldap config import");
    /*
     * ##################### Import LDAP Configs
     */
    {
      List<LdapConfig> list = readList(simpleSerializer, f, "ldapconfigs.xml", "ldapconfigs", LdapConfig.class, true);
      for (LdapConfig c : list) {
        ldapConfigDao.addLdapConfigByObject(c);
      }
    }

    log.info("Ldap config import complete, starting recordings import");
    /*
     * ##################### Import Recordings
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions
      Serializer serializer = new Persister(strategy, matcher);

      matcher.bind(Long.class, LongTransform.class);
      matcher.bind(Integer.class, IntegerTransform.class);
      registry.bind(Date.class, DateConverter.class);
     
      List<FlvRecording> list = readList(serializer, f, "flvRecordings.xml", "flvrecordings", FlvRecording.class, true);
      for (FlvRecording fr : list) {
        fr.setFlvRecordingId(0);
        if (fr.getRoom_id() != null) {
          fr.setRoom_id(roomsMap.get(fr.getRoom_id()));
        }
        if (fr.getOwnerId() != null) {
          fr.setOwnerId(usersMap.get(fr.getOwnerId()));
        }
        if (fr.getFlvRecordingMetaData() != null) {
          for (FlvRecordingMetaData meta : fr.getFlvRecordingMetaData()) {
            meta.setFlvRecordingMetaDataId(0);
            meta.setFlvRecording(fr);
          }
        }
        flvRecordingDao.addFlvRecordingObj(fr);
      }
    }

    log.info("FLVrecording import complete, starting private message folder import");
    /*
     * ##################### Import Private Message Folders
     */
    {
      List<PrivateMessageFolder> list = readList(simpleSerializer, f, "privateMessageFolder.xml"
        , "privatemessagefolders", PrivateMessageFolder.class, true);
      for (PrivateMessageFolder p : list) {
        Long folderId = p.getPrivateMessageFolderId();
        PrivateMessageFolder storedFolder = privateMessageFolderDao
            .getPrivateMessageFolderById(folderId);
        if (storedFolder == null) {
          p.setPrivateMessageFolderId(0);
          Long newFolderId = privateMessageFolderDao
              .addPrivateMessageFolderObj(p);
          messageFoldersMap.put(folderId, newFolderId);
        }
      }
    }

    log.info("Private message folder import complete, starting user contacts import");
    /*
     * ##################### Import User Contacts
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
     
      List<UserContact> list = readList(serializer, f, "userContacts.xml", "usercontacts", UserContact.class, true);
      for (UserContact uc : list) {
        Long ucId = uc.getUserContactId();
        UserContact storedUC = userContactsDao.getUserContacts(ucId);

        if (storedUC == null && uc.getContact() != null && uc.getContact().getUser_id() != null) {
          uc.setUserContactId(0);
          Long newId = userContactsDao.addUserContactObj(uc);
          userContactsMap.put(ucId, newId);
        }
      }
    }

    log.info("Usercontact import complete, starting private messages item import");
    /*
     * ##################### Import Private Messages
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
      registry.bind(Date.class, DateConverter.class);
     
      List<PrivateMessage> list = readList(serializer, f, "privateMessages.xml", "privatemessages", PrivateMessage.class, true);
      for (PrivateMessage p : list) {
        p.setPrivateMessageId(0);
        p.setPrivateMessageFolderId(
          getNewId(p.getPrivateMessageFolderId(), Maps.MESSAGEFOLDERS));
        p.setUserContactId(
          getNewId(p.getUserContactId(), Maps.USERCONTACTS));
        if (p.getRoom() != null && p.getRoom().getRooms_id() == null) {
          p.setRoom(null);
        }
        if (p.getTo() != null && p.getTo().getUser_id() == null) {
          p.setTo(null);
        }
        if (p.getFrom() != null && p.getFrom().getUser_id() == null) {
          p.setFrom(null);
        }
        if (p.getOwner() != null && p.getOwner().getUser_id() == null) {
          p.setOwner(null);
        }
        privateMessagesDao.addPrivateMessageObj(p);
      }
    }

    log.info("Private message import complete, starting file explorer item import");
    /*
     * ##################### Import File-Explorer Items
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions
      Serializer serializer = new Persister(strategy, matcher);

      matcher.bind(Long.class, LongTransform.class);
      matcher.bind(Integer.class, IntegerTransform.class);
      registry.bind(Date.class, DateConverter.class);
     
      List<FileExplorerItem> list = readList(serializer, f, "fileExplorerItems.xml", "fileExplorerItems", FileExplorerItem.class, true);
      for (FileExplorerItem file : list) {
        // We need to reset this as openJPA reject to store them otherwise
        file.setFileExplorerItemId(0);
        Long roomId = file.getRoom_id();
        file.setRoom_id(roomsMap.containsKey(roomId) ? roomsMap.get(roomId) : null);
        fileExplorerItemDao.addFileExplorerItem(file);
      }
    }

    log.info("File explorer item import complete, starting file poll import");
    /*
     * ##################### Import Room Polls
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions
      Serializer serializer = new Persister(strategy, matcher);
 
      matcher.bind(Integer.class, IntegerTransform.class);
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
      registry.bind(PollType.class, new PollTypeConverter(pollManager));
      registry.bind(Date.class, DateConverter.class);
     
      List<RoomPoll> list = readList(serializer, f, "roompolls.xml", "roompolls", RoomPoll.class, true);
      for (RoomPoll rp : list) {
View Full Code Here


      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(Organisation.class, new OrganisationConverter(orgDao, organisationsMap));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
     
      List<RoomOrganisation> list = readList(serializer, f, "rooms_organisation.xml", "room_organisations", RoomOrganisation.class);
      for (RoomOrganisation ro : list) {
        if (!ro.getDeleted()) {
          // We need to reset this as openJPA reject to store them otherwise
          ro.setRooms_organisation_id(null);
          roomManager.addRoomOrganisation(ro);
        }
      }
    }

    log.info("Room organizations import complete, starting appointement import");
    /*
     * ##################### Import Appointements
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(AppointmentCategory.class, new AppointmentCategoryConverter(appointmentCategoryDaoImpl));
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(AppointmentReminderTyps.class, new AppointmentReminderTypeConverter(appointmentReminderTypDaoImpl));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
      registry.bind(Date.class, DateConverter.class);
     
      List<Appointment> list = readList(serializer, f, "appointements.xml", "appointments", Appointment.class);
      for (Appointment a : list) {
        Long appId = a.getAppointmentId();

        // We need to reset this as openJPA reject to store them otherwise
        a.setAppointmentId(null);
        if (a.getUserId() != null && a.getUserId().getUser_id() == null) {
          a.setUserId(null);
        }
        Long newAppId = appointmentDao.addAppointmentObj(a);
        appointmentsMap.put(appId, newAppId);
      }
    }

    log.info("Appointement import complete, starting meeting members import");
    /*
     * ##################### Import MeetingMembers
     *
     * Reminder Invitations will be NOT send!
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(Appointment.class, new AppointmentConverter(appointmentDao, appointmentsMap));
     
      List<MeetingMember> list = readList(serializer, f, "meetingmembers.xml", "meetingmembers", MeetingMember.class);
      for (MeetingMember ma : list) {
        if (ma.getUserid() != null && ma.getUserid().getUser_id() == null) {
          ma.setUserid(null);
        }
        if (!ma.getDeleted()) {
          // We need to reset this as openJPA reject to store them otherwise
          ma.setMeetingMemberId(null);
          meetingMemberDao.addMeetingMemberByObject(ma);
        }
      }
    }

    log.info("Meeting members import complete, starting ldap config import");
    /*
     * ##################### Import LDAP Configs
     */
    {
      List<LdapConfig> list = readList(simpleSerializer, f, "ldapconfigs.xml", "ldapconfigs", LdapConfig.class, true);
      for (LdapConfig c : list) {
        ldapConfigDao.addLdapConfigByObject(c);
      }
    }

    log.info("Ldap config import complete, starting recordings import");
    /*
     * ##################### Import Recordings
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions
      Serializer serializer = new Persister(strategy, matcher);

      matcher.bind(Long.class, LongTransform.class);
      matcher.bind(Integer.class, IntegerTransform.class);
      registry.bind(Date.class, DateConverter.class);
     
      List<FlvRecording> list = readList(serializer, f, "flvRecordings.xml", "flvrecordings", FlvRecording.class, true);
      for (FlvRecording fr : list) {
        fr.setFlvRecordingId(0);
        if (fr.getRoom_id() != null) {
          fr.setRoom_id(roomsMap.get(fr.getRoom_id()));
        }
        if (fr.getOwnerId() != null) {
          fr.setOwnerId(usersMap.get(fr.getOwnerId()));
        }
        if (fr.getFlvRecordingMetaData() != null) {
          for (FlvRecordingMetaData meta : fr.getFlvRecordingMetaData()) {
            meta.setFlvRecordingMetaDataId(0);
            meta.setFlvRecording(fr);
          }
        }
        flvRecordingDao.addFlvRecordingObj(fr);
      }
    }

    log.info("FLVrecording import complete, starting private message folder import");
    /*
     * ##################### Import Private Message Folders
     */
    {
      List<PrivateMessageFolder> list = readList(simpleSerializer, f, "privateMessageFolder.xml"
        , "privatemessagefolders", PrivateMessageFolder.class, true);
      for (PrivateMessageFolder p : list) {
        Long folderId = p.getPrivateMessageFolderId();
        PrivateMessageFolder storedFolder = privateMessageFolderDao
            .getPrivateMessageFolderById(folderId);
        if (storedFolder == null) {
          p.setPrivateMessageFolderId(0);
          Long newFolderId = privateMessageFolderDao
              .addPrivateMessageFolderObj(p);
          messageFoldersMap.put(folderId, newFolderId);
        }
      }
    }

    log.info("Private message folder import complete, starting user contacts import");
    /*
     * ##################### Import User Contacts
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
     
      List<UserContact> list = readList(serializer, f, "userContacts.xml", "usercontacts", UserContact.class, true);
      for (UserContact uc : list) {
        Long ucId = uc.getUserContactId();
        UserContact storedUC = userContactsDao.getUserContacts(ucId);

        if (storedUC == null && uc.getContact() != null && uc.getContact().getUser_id() != null) {
          uc.setUserContactId(0);
          Long newId = userContactsDao.addUserContactObj(uc);
          userContactsMap.put(ucId, newId);
        }
      }
    }

    log.info("Usercontact import complete, starting private messages item import");
    /*
     * ##################### Import Private Messages
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
      registry.bind(Date.class, DateConverter.class);
     
      List<PrivateMessage> list = readList(serializer, f, "privateMessages.xml", "privatemessages", PrivateMessage.class, true);
      for (PrivateMessage p : list) {
        p.setPrivateMessageId(0);
        p.setPrivateMessageFolderId(
          getNewId(p.getPrivateMessageFolderId(), Maps.MESSAGEFOLDERS));
        p.setUserContactId(
          getNewId(p.getUserContactId(), Maps.USERCONTACTS));
        if (p.getRoom() != null && p.getRoom().getRooms_id() == null) {
          p.setRoom(null);
        }
        if (p.getTo() != null && p.getTo().getUser_id() == null) {
          p.setTo(null);
        }
        if (p.getFrom() != null && p.getFrom().getUser_id() == null) {
          p.setFrom(null);
        }
        if (p.getOwner() != null && p.getOwner().getUser_id() == null) {
          p.setOwner(null);
        }
        privateMessagesDao.addPrivateMessageObj(p);
      }
    }

    log.info("Private message import complete, starting file explorer item import");
    /*
     * ##################### Import File-Explorer Items
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions
      Serializer serializer = new Persister(strategy, matcher);

      matcher.bind(Long.class, LongTransform.class);
      matcher.bind(Integer.class, IntegerTransform.class);
      registry.bind(Date.class, DateConverter.class);
     
      List<FileExplorerItem> list = readList(serializer, f, "fileExplorerItems.xml", "fileExplorerItems", FileExplorerItem.class, true);
      for (FileExplorerItem file : list) {
        // We need to reset this as openJPA reject to store them otherwise
        file.setFileExplorerItemId(0);
        Long roomId = file.getRoom_id();
        file.setRoom_id(roomsMap.containsKey(roomId) ? roomsMap.get(roomId) : null);
        if (file.getOwnerId() != null) {
          file.setOwnerId(usersMap.get(file.getOwnerId()));
        }
        fileExplorerItemDao.addFileExplorerItem(file);
      }
    }

    log.info("File explorer item import complete, starting file poll import");
    /*
     * ##################### Import Room Polls
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions
      Serializer serializer = new Persister(strategy, matcher);
 
      matcher.bind(Integer.class, IntegerTransform.class);
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
      registry.bind(PollType.class, new PollTypeConverter(pollManager));
      registry.bind(Date.class, DateConverter.class);
     
      List<RoomPoll> list = readList(serializer, f, "roompolls.xml", "roompolls", RoomPoll.class, true);
      for (RoomPoll rp : list) {
View Full Code Here

      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(Organisation.class, new OrganisationConverter(orgDao, organisationsMap));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
     
      List<RoomOrganisation> list = readList(serializer, f, "rooms_organisation.xml", "room_organisations", RoomOrganisation.class);
      for (RoomOrganisation ro : list) {
        if (!ro.getDeleted()) {
          // We need to reset this as openJPA reject to store them otherwise
          ro.setRooms_organisation_id(null);
          roomManager.addRoomOrganisation(ro);
        }
      }
    }

    log.info("Room organizations import complete, starting appointement import");
    /*
     * ##################### Import Appointements
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(AppointmentCategory.class, new AppointmentCategoryConverter(appointmentCategoryDaoImpl));
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(AppointmentReminderTyps.class, new AppointmentReminderTypeConverter(appointmentReminderTypDaoImpl));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
      registry.bind(Date.class, DateConverter.class);
     
      List<Appointment> list = readList(serializer, f, "appointements.xml", "appointments", Appointment.class);
      for (Appointment a : list) {
        Long appId = a.getAppointmentId();

        // We need to reset this as openJPA reject to store them otherwise
        a.setAppointmentId(null);
        if (a.getUserId() != null && a.getUserId().getUser_id() == null) {
          a.setUserId(null);
        }
        Long newAppId = appointmentDao.addAppointmentObj(a);
        appointmentsMap.put(appId, newAppId);
      }
    }

    log.info("Appointement import complete, starting meeting members import");
    /*
     * ##################### Import MeetingMembers
     *
     * Reminder Invitations will be NOT send!
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(Appointment.class, new AppointmentConverter(appointmentDao, appointmentsMap));
     
      List<MeetingMember> list = readList(serializer, f, "meetingmembers.xml", "meetingmembers", MeetingMember.class);
      for (MeetingMember ma : list) {
        if (ma.getUserid() != null && ma.getUserid().getUser_id() == null) {
          ma.setUserid(null);
        }
        if (!ma.getDeleted()) {
          // We need to reset this as openJPA reject to store them otherwise
          ma.setMeetingMemberId(null);
          meetingMemberDao.addMeetingMemberByObject(ma);
        }
      }
    }

    log.info("Meeting members import complete, starting ldap config import");
    /*
     * ##################### Import LDAP Configs
     */
    {
      List<LdapConfig> list = readList(simpleSerializer, f, "ldapconfigs.xml", "ldapconfigs", LdapConfig.class, true);
      for (LdapConfig c : list) {
        ldapConfigDao.addLdapConfigByObject(c);
      }
    }

    log.info("Ldap config import complete, starting recordings import");
    /*
     * ##################### Import Recordings
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions
      Serializer serializer = new Persister(strategy, matcher);

      matcher.bind(Long.class, LongTransform.class);
      matcher.bind(Integer.class, IntegerTransform.class);
      registry.bind(Date.class, DateConverter.class);
     
      List<FlvRecording> list = readList(serializer, f, "flvRecordings.xml", "flvrecordings", FlvRecording.class, true);
      for (FlvRecording fr : list) {
        fr.setFlvRecordingId(0);
        if (fr.getRoom_id() != null) {
          fr.setRoom_id(roomsMap.get(fr.getRoom_id()));
        }
        if (fr.getOwnerId() != null) {
          fr.setOwnerId(usersMap.get(fr.getOwnerId()));
        }
        if (fr.getFlvRecordingMetaData() != null) {
          for (FlvRecordingMetaData meta : fr.getFlvRecordingMetaData()) {
            meta.setFlvRecordingMetaDataId(0);
            meta.setFlvRecording(fr);
          }
        }
        flvRecordingDao.addFlvRecordingObj(fr);
      }
    }

    log.info("FLVrecording import complete, starting private message folder import");
    /*
     * ##################### Import Private Message Folders
     */
    {
      List<PrivateMessageFolder> list = readList(simpleSerializer, f, "privateMessageFolder.xml"
        , "privatemessagefolders", PrivateMessageFolder.class, true);
      for (PrivateMessageFolder p : list) {
        Long folderId = p.getPrivateMessageFolderId();
        PrivateMessageFolder storedFolder = privateMessageFolderDao
            .getPrivateMessageFolderById(folderId);
        if (storedFolder == null) {
          p.setPrivateMessageFolderId(0);
          Long newFolderId = privateMessageFolderDao
              .addPrivateMessageFolderObj(p);
          messageFoldersMap.put(folderId, newFolderId);
        }
      }
    }

    log.info("Private message folder import complete, starting user contacts import");
    /*
     * ##################### Import User Contacts
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
     
      List<UserContact> list = readList(serializer, f, "userContacts.xml", "usercontacts", UserContact.class, true);
      for (UserContact uc : list) {
        Long ucId = uc.getUserContactId();
        UserContact storedUC = userContactsDao.getUserContacts(ucId);

        if (storedUC == null && uc.getContact() != null && uc.getContact().getUser_id() != null) {
          uc.setUserContactId(0);
          Long newId = userContactsDao.addUserContactObj(uc);
          userContactsMap.put(ucId, newId);
        }
      }
    }

    log.info("Usercontact import complete, starting private messages item import");
    /*
     * ##################### Import Private Messages
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      Serializer serializer = new Persister(strategy);
 
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
      registry.bind(Date.class, DateConverter.class);
     
      List<PrivateMessage> list = readList(serializer, f, "privateMessages.xml", "privatemessages", PrivateMessage.class, true);
      for (PrivateMessage p : list) {
        p.setPrivateMessageId(0);
        p.setPrivateMessageFolderId(
          getNewId(p.getPrivateMessageFolderId(), Maps.MESSAGEFOLDERS));
        p.setUserContactId(
          getNewId(p.getUserContactId(), Maps.USERCONTACTS));
        if (p.getRoom() != null && p.getRoom().getRooms_id() == null) {
          p.setRoom(null);
        }
        if (p.getTo() != null && p.getTo().getUser_id() == null) {
          p.setTo(null);
        }
        if (p.getFrom() != null && p.getFrom().getUser_id() == null) {
          p.setFrom(null);
        }
        if (p.getOwner() != null && p.getOwner().getUser_id() == null) {
          p.setOwner(null);
        }
        privateMessagesDao.addPrivateMessageObj(p);
      }
    }

    log.info("Private message import complete, starting file explorer item import");
    /*
     * ##################### Import File-Explorer Items
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions
      Serializer serializer = new Persister(strategy, matcher);

      matcher.bind(Long.class, LongTransform.class);
      matcher.bind(Integer.class, IntegerTransform.class);
      registry.bind(Date.class, DateConverter.class);
     
      List<FileExplorerItem> list = readList(serializer, f, "fileExplorerItems.xml", "fileExplorerItems", FileExplorerItem.class, true);
      for (FileExplorerItem file : list) {
        // We need to reset this as openJPA reject to store them otherwise
        file.setFileExplorerItemId(0);
        Long roomId = file.getRoom_id();
        file.setRoom_id(roomsMap.containsKey(roomId) ? roomsMap.get(roomId) : null);
        if (file.getOwnerId() != null) {
          file.setOwnerId(usersMap.get(file.getOwnerId()));
        }
        fileExplorerItemDao.addFileExplorerItem(file);
      }
    }

    log.info("File explorer item import complete, starting file poll import");
    /*
     * ##################### Import Room Polls
     */
    {
      Registry registry = new Registry();
      Strategy strategy = new RegistryStrategy(registry);
      RegistryMatcher matcher = new RegistryMatcher(); //TODO need to be removed in the later versions
      Serializer serializer = new Persister(strategy, matcher);
 
      matcher.bind(Integer.class, IntegerTransform.class);
      registry.bind(User.class, new UserConverter(usersDao, usersMap));
      registry.bind(Room.class, new RoomConverter(roomDao, roomsMap));
      registry.bind(PollType.class, new PollTypeConverter(pollManager));
      registry.bind(Date.class, DateConverter.class);
     
      List<RoomPoll> list = readList(serializer, f, "roompolls.xml", "roompolls", RoomPoll.class, true);
      for (RoomPoll rp : list) {
View Full Code Here

TOP

Related Classes of org.apache.openmeetings.backup.RoomConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.