public DatabaseBranch getBranch(String client) { return getBranch(client, false); }
private List<DatabaseVersionHeader> sortBranches(DatabaseBranches allBranches) { List<DatabaseVersionHeader> databaseVersionHeaders = new ArrayList<DatabaseVersionHeader>(); for (String client : allBranches.getClients()) { databaseVersionHeaders.addAll(allBranches.getBranch(client).getAll()); } Collections.sort(databaseVersionHeaders, new DatabaseVersionHeaderComparator(true)); return databaseVersionHeaders; } }
DatabaseBranch otherClientBranch = allStitchedBranches.getBranch(otherClientName); Set<DatabaseVersionHeader> otherClientDatabaseVersionHeaders = Sets.newHashSet(otherClientBranch.getAll());
/** * This methods takes a Map containing DatabaseVersions (headers only) and loads these headers into {@link DatabaseBranches}. * In addition, the local branch is added to this. The resulting DatabaseBranches will contain all headers exactly once, * for the client that created that version. * * @param localBranch {@link DatabaseBranch} containing the locally known headers. * @param remoteDatabaseHeaders Map from {@link DatabaseRemoteFile}s (important for client names) to the {@link DatabaseVersion}s that are * contained in these files. * * @return DatabaseBranches filled with all the headers that originated from either of the parameters. */ private DatabaseBranches populateDatabaseBranches(DatabaseBranch localBranch, SortedMap<DatabaseRemoteFile, List<DatabaseVersion>> remoteDatabaseHeaders) { DatabaseBranches allBranches = new DatabaseBranches(); allBranches.put(config.getMachineName(), localBranch.clone()); for (DatabaseRemoteFile remoteDatabaseFile : remoteDatabaseHeaders.keySet()) { // Populate branches DatabaseBranch remoteClientBranch = allBranches.getBranch(remoteDatabaseFile.getClientName(), true); for (DatabaseVersion remoteDatabaseVersion : remoteDatabaseHeaders.get(remoteDatabaseFile)) { DatabaseVersionHeader header = remoteDatabaseVersion.getHeader(); remoteClientBranch.add(header); } } logger.log(Level.INFO, "Populated unknown branches: " + allBranches); return allBranches; }
DatabaseBranch currentBranch = allBranches.getBranch(currentClient); DatabaseVersionHeader currentBranchLastDatabaseVersionHeader = currentBranch.getLast();