Package org.syncany.operations.down

Examples of org.syncany.operations.down.DatabaseBranch


    FileVersionSqlDao fileVersionDao = new FileVersionSqlDao(databaseConnection);
    FileHistorySqlDao fileHistoryDao = new FileHistorySqlDao(databaseConnection, fileVersionDao);
    FileContentSqlDao fileContentDao = new FileContentSqlDao(databaseConnection);
    DatabaseVersionSqlDao databaseVersionDao = new DatabaseVersionSqlDao(databaseConnection, chunkDao, fileContentDao, fileVersionDao, fileHistoryDao, multiChunkDao);
   
    DatabaseBranch localDatabaseBranch = databaseVersionDao.getLocalDatabaseBranch();
   
    // Test
    assertNotNull(localDatabaseBranch);
    assertEquals(11, localDatabaseBranch.size());
    assertEquals(11, localDatabaseBranch.getAll().size());
    
    assertEquals(TestDatabaseUtil.createBranch(
      new String[] {
        "A/(A1)/T=1389977166000",
        "A/(A2)/T=1389977199000",
View Full Code Here


    FileVersionSqlDao fileVersionDao = new FileVersionSqlDao(databaseConnection);
    FileHistorySqlDao fileHistoryDao = new FileHistorySqlDao(databaseConnection, fileVersionDao);
    FileContentSqlDao fileContentDao = new FileContentSqlDao(databaseConnection);
    DatabaseVersionSqlDao databaseVersionDao = new DatabaseVersionSqlDao(databaseConnection, chunkDao, fileContentDao, fileVersionDao, fileHistoryDao, multiChunkDao);
   
    DatabaseBranch localDatabaseBranch = databaseVersionDao.getLocalDatabaseBranch();
   
    // Test
    assertNotNull(localDatabaseBranch);
    assertEquals(5, localDatabaseBranch.size());
    assertEquals(5, localDatabaseBranch.getAll().size());
    
    assertEquals(TestDatabaseUtil.createBranch(
      new String[] {
        "A/(A1)/T=1388589969000",
        "A/(A2)/T=1388676369000",
View Full Code Here

      "C/(C2)/T=1376074225399",
      "C/(C3)/T=1376074225416",
    }));   
   
    DatabaseReconciliator databaseVersionUpdateDetector = new DatabaseReconciliator();
    DatabaseBranches actualStitchedRemoteBranches = databaseVersionUpdateDetector.stitchBranches(allBranches, "D", new DatabaseBranch());
   
    DatabaseBranches expectedStitchedBranches = new DatabaseBranches();
   
    expectedStitchedBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
      "A/(A1)/T=1376074225169",
View Full Code Here

      // --> B
      "C/(A5,B2,C3)/T=10",
    }));   
   
    DatabaseReconciliator databaseVersionUpdateDetector = new DatabaseReconciliator();
    DatabaseBranches actualStitchedRemoteBranches = databaseVersionUpdateDetector.stitchBranches(allBranches, "D", new DatabaseBranch());
   
    DatabaseBranches expectedStitchedBranches = new DatabaseBranches();
   
    expectedStitchedBranches.put("A", TestDatabaseUtil.createBranch(new String[] {
        "A/(A1)/T=1",
View Full Code Here

   
    DatabaseReconciliator databaseReconciliator = new DatabaseReconciliator();
    TestResult actualTestResult = new TestResult();
   
    // Get 'local' branch
    DatabaseBranch localBranch = allBranches.getBranch(localMachineName);
   
    // Get all the other ones (clone 'all', and remove local)
    DatabaseBranches unstitchedRemoteBranches = allBranches.clone();
    unstitchedRemoteBranches.remove(localMachineName);
View Full Code Here

    return databaseVersionHeader;
  }

  public DatabaseBranch getLocalDatabaseBranch() {
    DatabaseBranch databaseBranch = new DatabaseBranch();

    try (PreparedStatement preparedStatement = getStatement("databaseversion.select.master.getLocalDatabaseBranch.sql")) {
      try (ResultSet resultSet = preparedStatement.executeQuery()) {
        DatabaseVersionHeader currentDatabaseVersionHeader = null;
        int currentDatabaseVersionHeaderId = -1;
 
        while (resultSet.next()) {
          int databaseVersionHeaderId = resultSet.getInt("id");
 
          // Row does NOT belong to the current database version
          if (currentDatabaseVersionHeader == null || currentDatabaseVersionHeaderId != databaseVersionHeaderId) {
            // Add to database branch
            if (currentDatabaseVersionHeader != null) {
              databaseBranch.add(currentDatabaseVersionHeader);
            }
 
            // Make a new database version header
            currentDatabaseVersionHeader = new DatabaseVersionHeader();
            currentDatabaseVersionHeader.setType(DatabaseVersionType.valueOf(resultSet.getString("type")));
            currentDatabaseVersionHeader.setClient(resultSet.getString("client"));
            currentDatabaseVersionHeader.setDate(new Date(resultSet.getTimestamp("localtime").getTime()));
 
            currentDatabaseVersionHeaderId = databaseVersionHeaderId;
          }
 
          currentDatabaseVersionHeader.getVectorClock().setClock(resultSet.getString("vc_client"), resultSet.getLong("vc_logicaltime"));
        }
 
        // Add to database branch
        if (currentDatabaseVersionHeader != null) {
          databaseBranch.add(currentDatabaseVersionHeader);
        }
 
        return databaseBranch;
      }
    }
View Full Code Here

    return databaseVersionHeaderMap;
  }

  public static DatabaseBranch createBranch(String[] databaseVersionHeaderStrings) throws Exception {
    DatabaseBranch branch = new DatabaseBranch();
   
    for (String databaseVersionHeaderString : databaseVersionHeaderStrings) {
      DatabaseVersionHeader databaseVersionHeader = createFromString(databaseVersionHeaderString);
      branch.add(databaseVersionHeader);
    }

    return branch;
  }
View Full Code Here

TOP

Related Classes of org.syncany.operations.down.DatabaseBranch

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.