/**
  * Returns a list of BibliographicItems from the metadata database.
  *
  * @return a list of BibliobraphicItems from the metadata database.
  */
 public static List<BibliographicItem> getBibliographicItems() {
   List<BibliographicItem> items = Collections.<BibliographicItem>emptyList();
   Connection conn = null;
   try {
     DbManager dbManager = getDaemon().getDbManager();
     conn = dbManager.getConnection();
     items = getBibliographicItems(dbManager, conn);
   } catch (DbException ex) {
     log.warning(ex.getMessage());
     log.warning("bibliographicItemsQuery = " + bibliographicItemsQuery);
   } finally {
     DbManager.safeRollbackAndClose(conn);
   }
   return items;
 }
  /**
   * Returns a list of BibliographicItems from the metadata database.
   *
   * @param dbManager the database manager
   * @param conn the database connection
   * @return a list of BibliobraphicItems from the metadata database.
   */
  public static List<BibliographicItem> getBibliographicItems(
      DbManager dbManager, Connection conn) {
    final String DEBUG_HEADER = "getBibliographicItems(): ";
    BibliographicItem previousItem = null;
    List<BibliographicItem> items = new ArrayList<BibliographicItem>();
    PreparedStatement statement = null;
    ResultSet resultSet = null;

    try {
      if (log.isDebug3())
        log.debug3(DEBUG_HEADER + "bibliographicItemsQuery = " + bibliographicItemsQuery);
      statement = dbManager.prepareStatement(conn, bibliographicItemsQuery);
      resultSet = dbManager.executeQuery(statement);

      while (resultSet.next()) {
        BibliographicItem item = new BibliographicDatabaseItem(resultSet);
        // Avoid adding items that differ only in some proprietary identifier.
        if (!item.sameInNonProprietaryIdProperties(previousItem)) {
          items.add(item);
        }
      }
    } catch (IllegalArgumentException ex) {
      log.warning(ex.getMessage());
      log.warning("bibliographicItemsQuery = " + bibliographicItemsQuery);
    } catch (SQLException ex) {
      log.warning(ex.getMessage());
      log.warning("bibliographicItemsQuery = " + bibliographicItemsQuery);
    } catch (DbException ex) {
      log.warning(ex.getMessage());
      log.warning("bibliographicItemsQuery = " + bibliographicItemsQuery);
    } finally {
      DbManager.safeCloseResultSet(resultSet);
      DbManager.safeCloseStatement(statement);
    }
    return items;
  }