/**
   * Given a <code>List&lt;BibliosDAO&gt;</code>, this method returns a new list, which is a copy of
   * the original list, with updates applied from the biblios web service for valid pubmed_id
   * values.
   *
   * @param oldBiblioList the original list of biblios
   * @return a new list, which is a copy of the original list, with updates applied from the biblios
   *     web service for valid pubmed_id values
   */
  private List<BibliosDAO> createNewBiblioListFromWebService(List<BibliosDAO> oldBiblioList) {
    String volume;
    List<BibliosDAO> newBiblioList = new ArrayList<>();
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String last_change = dateFormat.format(new Date());

    for (BibliosDAO oldBiblio : oldBiblioList) {
      BibliosDAO newBiblio = new BibliosDAO(); // Clone the original BibliosDAO.
      newBiblio.setAuthor1(oldBiblio.getAuthor1());
      newBiblio.setAuthor2(oldBiblio.getAuthor2());
      newBiblio.setId_biblio(oldBiblio.getId_biblio());
      newBiblio.setJournal(oldBiblio.getJournal());
      newBiblio.setLast_change(last_change);
      newBiblio.setNotes(oldBiblio.getNotes());
      newBiblio.setPages(oldBiblio.getPages());
      newBiblio.setPubmed_id(oldBiblio.getPubmed_id());
      newBiblio.setTitle(oldBiblio.getTitle());
      newBiblio.setUpdated(oldBiblio.getUpdated());
      newBiblio.setUsername(oldBiblio.getUsername());
      newBiblio.setVolume(oldBiblio.getVolume());
      newBiblio.setYear(oldBiblio.getYear());

      Integer pubmed_id =
          Utils.tryParseInt(
              oldBiblio
                  .getPubmed_id()); // If we have a valid pubmed_id, load the new BibliosDAO with
      // the paper data.
      if (pubmed_id != null) {
        FetchBiblio paperFromWs = fetchPaper(pubmed_id);
        if (paperFromWs != null) {
          if (!paperFromWs.issue.isEmpty()) {
            volume = paperFromWs.volume + "(" + paperFromWs.issue + ")";
          } else {
            volume = paperFromWs.volume;
          }

          newBiblio.setTitle(paperFromWs.title);
          newBiblio.setAuthor1(paperFromWs.author1);
          newBiblio.setAuthor2(paperFromWs.author2);
          newBiblio.setYear("" + paperFromWs.year);
          newBiblio.setJournal(paperFromWs.journal);
          newBiblio.setVolume(volume);
          newBiblio.setPages(paperFromWs.pages);
          newBiblio.setUsername("EMMA");
          newBiblio.setUpdated("Y");

          newBiblioList.add(newBiblio);
        }
      }
    }

    return newBiblioList;
  }
  /**
   * This method replaces any null <code>BibliosDAO</code> fields with the string '&lt;null&gt;' so
   * that proper length computations and display can be performed against null fields. A throw-away
   * copy of the biblio is returned and may be used for field length computations and display
   * without fear of null pointer exceptions.
   *
   * @param biblio the biblio record to be patched
   * @return a new <code>BibliosDAO</code> instance with any null fields replaced by the string
   *     '&lt;null&gt;'
   */
  private BibliosDAO patchNullFields(BibliosDAO biblio) {
    BibliosDAO newBiblio = new BibliosDAO();

    newBiblio.setId_biblio(biblio.getId_biblio());
    newBiblio.setPubmed_id(biblio.getPubmed_id() == null ? "<null>" : biblio.getPubmed_id());
    newBiblio.setYear(biblio.getYear() == null ? "<null>" : biblio.getYear());
    newBiblio.setJournal(biblio.getJournal() == null ? "<null>" : biblio.getJournal());
    newBiblio.setVolume(biblio.getVolume() == null ? "<null>" : biblio.getVolume());
    newBiblio.setPages(biblio.getPages() == null ? "<null>" : biblio.getPages());
    newBiblio.setUsername(biblio.getUsername() == null ? "<null>" : biblio.getUsername());
    newBiblio.setUpdated(biblio.getUpdated() == null ? "<null>" : biblio.getUpdated());
    newBiblio.setLast_change(biblio.getLast_change() == null ? "<null>" : biblio.getLast_change());
    newBiblio.setTitle(biblio.getTitle() == null ? "<null>" : biblio.getTitle());
    newBiblio.setAuthor1(biblio.getAuthor1() == null ? "<null>" : biblio.getAuthor1());
    newBiblio.setAuthor2(biblio.getAuthor2() == null ? "<null>" : biblio.getAuthor2());

    return newBiblio;
  }