/**
   * This method gets the list of update candidates, validates it, removes any failed candidates
   * from the update list, then updates the database with the [validated] update candidate list.
   *
   * @return The number of records updated
   */
  public int validateAndUpdateCandidates() {
    int updateCount = 0;
    List<BibliosDAO> bibliosList =
        bibliosManager.getUpdateCandidateBiblios(); // Get update candidates.
    Map<Integer, BibliosDAO> errorMap = validator.validate(bibliosList); // Validate the list.

    if (!bibliosList.isEmpty()) { // If there are update candidates ...
      if (!errorMap.isEmpty()) { //     If there were validation errors ...
        Iterator<BibliosDAO> iterator = bibliosList.iterator();
        while (iterator.hasNext()) { //     ... remove the failed candidates from the update list.
          BibliosDAO biblio = iterator.next();
          int pk = biblio.getId_biblio();
          if (errorMap.containsKey(pk)) {
            Object[] parms = new Object[] {biblio.getId_biblio()};
            String logMsg = messages.getMessage("Biblios.RemoveFailedCandidate", parms, Locale.UK);
            logger.warn(logMsg);
            iterator.remove();
          }
        }
      }

      bibliosList =
          updateBibliosFromWebService(
              bibliosList); // Update any biblios with valid pubmed_ids from web service.
      updateCount = save(bibliosList); // Save the changes.
    }

    return updateCount;
  }
  /**
   * Validates update candidate biblios (biblios whose <code>update</code> database field is either
   * null or is not equal to 'Y')
   *
   * @return 0 if there are no validation errors; 1 otherwise.
   */
  public int validateUpdateCandidates() {
    String logMsg = messages.getMessage("Biblios.ValidateUpdateCandidates", BEGIN, Locale.UK);
    logger.info(logMsg);

    List<BibliosDAO> bibliosList = bibliosManager.getUpdateCandidateBiblios();
    Map<Integer, BibliosDAO> errorMap = validator.validate(bibliosList);

    logMsg = messages.getMessage("Biblios.ValidateUpdateCandidates", END, Locale.UK);
    logger.info(logMsg);

    return (errorMap.isEmpty() ? 0 : 1);
  }