Package org.syncany.database

Examples of org.syncany.database.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);
View Full Code Here


    String vectorClockString = databaseVersionHeaderMatcher.group(2);
    long databaseVersionHeaderTime = Long.parseLong(databaseVersionHeaderMatcher.group(3));
   
    VectorClock vectorClock = createVectorClock(vectorClockString);   
   
    DatabaseVersionHeader newDatabaseVersionHeader = new DatabaseVersionHeader();
   
    newDatabaseVersionHeader.setDate(new Date(databaseVersionHeaderTime));
    newDatabaseVersionHeader.setVectorClock(vectorClock);
    newDatabaseVersionHeader.setClient(client)
   
    return newDatabaseVersionHeader;
  }
View Full Code Here

  public static TreeMap<String, DatabaseVersionHeader> createMapWithMachineKey(String[] keysAndDatabaseVersionHeaderStrings) throws Exception {
    TreeMap<String, DatabaseVersionHeader> databaseVersionHeaderMap = new TreeMap<String, DatabaseVersionHeader>();
   
    for (int i=0; i<keysAndDatabaseVersionHeaderStrings.length; i+=2) {     
      String machineName = keysAndDatabaseVersionHeaderStrings[i];
      DatabaseVersionHeader databaseVersionHeader = createFromString(keysAndDatabaseVersionHeaderStrings[i+1]);

      databaseVersionHeaderMap.put(machineName, databaseVersionHeader);
    }

    return databaseVersionHeaderMap;
View Full Code Here

  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.database.DatabaseVersionHeader

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.