/** * Gets the {@link ReferenceLibrary} for the {@code network}. * * @throws IOException The contents of reference library file cannot be converted to {@link * ReferenceLibrary} */ public ReferenceLibrary getReferenceLibrary(String network) throws IOException { return ReferenceLibrary.read(getReferenceLibraryPath(network)); }
/** * From the {@link ReferenceLibrary} at {@code dataPath}, get the {@link ReferenceBook} with name * {@code bookName}. * * @throws IOException If the contents of the file could not be cast to {@link ReferenceLibrary} */ public static Optional<ReferenceBook> getReferenceBook( @Nonnull Path dataPath, @Nonnull String bookName) throws IOException { ReferenceLibrary data = read(dataPath); return data.getReferenceBook(bookName); }
/** * Adds the reference books in {@code newBooks} to the ReferenceLibrary at {@code path}. Books * with the same name are overwritten */ public static void mergeReferenceBooks( @Nonnull Path path, @Nonnull SortedSet<ReferenceBook> newBooks) throws IOException { ReferenceLibrary originalLibrary = read(path); List<ReferenceBook> booksToKeep = originalLibrary._books.stream() .filter( originalBook -> !newBooks.stream() .anyMatch(newBook -> newBook.getName().equals(originalBook.getName()))) .collect(Collectors.toList()); booksToKeep.addAll(newBooks); ReferenceLibrary newLibrary = new ReferenceLibrary(booksToKeep); write(newLibrary, path); }
/** Gets the {@link ReferenceLibrary} for the network */ @Override public ReferenceLibrary getReferenceLibraryData() { Path libraryPath = _settings .getStorageBase() .resolve(_settings.getContainer().getId()) .resolve(BfConsts.RELPATH_REFERENCE_LIBRARY_PATH); try { return ReferenceLibrary.read(libraryPath); } catch (IOException e) { _logger.errorf("Could not read reference library data from %s: %s", libraryPath, e); return null; } }
referenceLibraryData = true; try { ReferenceLibrary testrigData = ReferenceLibrary.read(subFile); Path path = networkDir.resolve(BfConsts.RELPATH_REFERENCE_LIBRARY_PATH); ReferenceLibrary.mergeReferenceBooks(path, testrigData.getReferenceBooks());
ReferenceLibrary.read(tempPath).getReferenceBooks(), equalTo( ImmutableSortedSet.of(