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;
}
}