public static DatabaseVersion createDatabaseVersion(DatabaseVersion basedOnDatabaseVersion) {
   if (basedOnDatabaseVersion == null) {
     return createDatabaseVersion(null, new Date());
   } else {
     return createDatabaseVersion(basedOnDatabaseVersion.getHeader(), new Date());
   }
 }
Beispiel #2
0
  private Branches readUnknownDatabaseVersionHeaders(List<File> remoteDatabases)
      throws IOException {
    logger.log(Level.INFO, "Loading database headers, creating branches ...");
    // Sort files (db-a-1 must be before db-a-2 !)
    Collections.sort(
        remoteDatabases); // TODO [medium] natural sort is a workaround, database file names should
    // be centrally managed, db-name-0000000009 avoids natural sort

    // Read database files
    Branches unknownRemoteBranches = new Branches();
    DatabaseDAO dbDAO = new XmlDatabaseDAO(config.getTransformer());

    for (File remoteDatabaseFileInCache : remoteDatabases) {
      Database remoteDatabase =
          new Database(); // Database cannot be reused, since these might be different clients

      RemoteDatabaseFile remoteDatabaseFile = new RemoteDatabaseFile(remoteDatabaseFileInCache);
      dbDAO.load(
          remoteDatabase,
          remoteDatabaseFile
              .getFile()); // TODO [medium] Performance: This is very, very, very inefficient, DB is
      // loaded and then discarded
      List<DatabaseVersion> remoteDatabaseVersions = remoteDatabase.getDatabaseVersions();

      // Populate branches
      Branch remoteClientBranch =
          unknownRemoteBranches.getBranch(remoteDatabaseFile.getClientName(), true);

      for (DatabaseVersion remoteDatabaseVersion : remoteDatabaseVersions) {
        DatabaseVersionHeader header = remoteDatabaseVersion.getHeader();
        remoteClientBranch.add(header);
      }
    }

    return unknownRemoteBranches;
  }