use of org.syncany.database.DatabaseVersionHeader in project syncany by syncany.
the class DatabaseVersionSqlDao method createDatabaseVersionFromRow.
protected DatabaseVersion createDatabaseVersionFromRow(ResultSet resultSet, boolean excludeChunkData, int fileHistoryMaxCount) throws SQLException {
DatabaseVersionHeader databaseVersionHeader = createDatabaseVersionHeaderFromRow(resultSet);
DatabaseVersion databaseVersion = new DatabaseVersion();
databaseVersion.setHeader(databaseVersionHeader);
// Add chunk/multichunk/filecontent data
if (!excludeChunkData) {
Map<ChunkChecksum, ChunkEntry> chunks = chunkDao.getChunks(databaseVersionHeader.getVectorClock());
Map<MultiChunkId, MultiChunkEntry> multiChunks = multiChunkDao.getMultiChunks(databaseVersionHeader.getVectorClock());
Map<FileChecksum, FileContent> fileContents = fileContentDao.getFileContents(databaseVersionHeader.getVectorClock());
for (ChunkEntry chunk : chunks.values()) {
databaseVersion.addChunk(chunk);
}
for (MultiChunkEntry multiChunk : multiChunks.values()) {
databaseVersion.addMultiChunk(multiChunk);
}
for (FileContent fileContent : fileContents.values()) {
databaseVersion.addFileContent(fileContent);
}
}
// Add file histories
Map<FileHistoryId, PartialFileHistory> fileHistories = fileHistoryDao.getFileHistoriesWithFileVersions(databaseVersionHeader.getVectorClock(), fileHistoryMaxCount);
for (PartialFileHistory fileHistory : fileHistories.values()) {
databaseVersion.addFileHistory(fileHistory);
}
return databaseVersion;
}
use of org.syncany.database.DatabaseVersionHeader in project syncany by syncany.
the class DatabaseVersionSqlDao method getNonEmptyDatabaseVersionHeaders.
public List<DatabaseVersionHeader> getNonEmptyDatabaseVersionHeaders() {
List<DatabaseVersionHeader> databaseVersionHeaders = new ArrayList<>();
try (PreparedStatement preparedStatement = getStatement("databaseversion.select.master.getNonEmptyDatabaseVersionHeaders.sql")) {
try (ResultSet resultSet = preparedStatement.executeQuery()) {
while (resultSet.next()) {
DatabaseVersionHeader databaseVersionHeader = createDatabaseVersionHeaderFromRow(resultSet);
databaseVersionHeaders.add(databaseVersionHeader);
}
}
return databaseVersionHeaders;
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
use of org.syncany.database.DatabaseVersionHeader in project syncany by syncany.
the class TestDatabaseUtil method createBranch.
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;
}
use of org.syncany.database.DatabaseVersionHeader in project syncany by syncany.
the class TestDatabaseUtil method createFromString.
public static DatabaseVersionHeader createFromString(String databaseVersionHeaderString) throws Exception {
Matcher databaseVersionHeaderMatcher = databaseVersionHeaderPattern.matcher(databaseVersionHeaderString);
if (!databaseVersionHeaderMatcher.matches()) {
throw new Exception("Invalid database version header string: " + databaseVersionHeaderString);
}
String client = databaseVersionHeaderMatcher.group(1);
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;
}
use of org.syncany.database.DatabaseVersionHeader in project syncany by syncany.
the class DatabaseVersionSqlDao method createDatabaseVersionHeaderFromRow.
private DatabaseVersionHeader createDatabaseVersionHeaderFromRow(ResultSet resultSet) throws SQLException {
DatabaseVersionHeader databaseVersionHeader = new DatabaseVersionHeader();
databaseVersionHeader.setClient(resultSet.getString("client"));
databaseVersionHeader.setDate(new Date(resultSet.getTimestamp("localtime").getTime()));
databaseVersionHeader.setVectorClock(getVectorClockByDatabaseVersionId(resultSet.getInt("id")));
return databaseVersionHeader;
}
Aggregations