public Map<String, List> fetchHoldingItem(boolean cursor) throws SQLException {

    String holdingId = "";
    String tempHoldingId = "";
    List itemIds = new ArrayList();

    Map<String, List> map = null;
    if (cursor) {
      while (holdingItemResultSet.next()) {
        holdingId = "who-" + holdingItemResultSet.getString("HOLDINGS_ID");
        if (StringUtils.isNotEmpty(tempHoldingId) && !tempHoldingId.equals(holdingId)) {
          if (itemIds.size() > 0) {
            map = new HashMap<>();
            map.put(tempHoldingId, itemIds);
            return map;
          }
        }
        itemIds.add("wio-" + holdingItemResultSet.getString("ITEM_ID"));
        tempHoldingId = holdingId;
      }

    } else {
      holdingItemResultSet.previous();
      //           while(holdingItemResultSet.previous()) {
      //               break;
      //           }
      while (holdingItemResultSet.next()) {
        holdingId = "who-" + holdingItemResultSet.getString("HOLDINGS_ID");
        if (StringUtils.isNotEmpty(tempHoldingId) && !tempHoldingId.equals(holdingId)) {
          if (itemIds.size() > 0) {
            map = new HashMap<>();
            map.put(tempHoldingId, itemIds);
            return map;
          }
        }
        itemIds.add("wio-" + holdingItemResultSet.getString("ITEM_ID"));
        tempHoldingId = holdingId;
      }
    }

    if (itemIds.size() > 0) {
      map = new HashMap<>();
      map.put(tempHoldingId, itemIds);
      return map;
    } else {
      map = null;
    }
    holdingItemResultSet.close();
    return map;
  }
  public Map<String, List> fetchBibHolding(boolean cursor) throws SQLException {
    String holdingId = "";
    String tempHoldingId = "";
    List bibIds = new ArrayList();
    Map<String, List> map = null;

    if (cursor) {
      while (bibHoldingsResultSet.next()) {
        holdingId = "who-" + bibHoldingsResultSet.getString("HOLDINGS_ID");
        if (StringUtils.isNotEmpty(tempHoldingId) && !tempHoldingId.equals(holdingId)) {

          if (bibIds.size() > 0) {
            map = new HashMap<>();
            bibIds.remove(0);
            map.put(tempHoldingId, bibIds);
            return map;
          }
        }

        bibIds.add("wbm-" + bibHoldingsResultSet.getString("BIB_ID"));
        tempHoldingId = holdingId;
      }

    } else {
      while (bibHoldingsResultSet.next()) {
        holdingId = "who-" + bibHoldingsResultSet.getString("HOLDINGS_ID");
        if (StringUtils.isNotEmpty(tempHoldingId) && !tempHoldingId.equals(holdingId)) {

          map = new HashMap<>();
          map.put(tempHoldingId, bibIds);
          return map;
        }
        bibIds.add("wbm-" + bibHoldingsResultSet.getString("BIB_ID"));
        tempHoldingId = holdingId;
      }
    }

    if (bibIds.size() > 0) {
      map = new HashMap<>();
      bibIds.remove(0);
      map.put(tempHoldingId, bibIds);
      return map;
    } else {
      map = null;
    }
    bibHoldingsResultSet.close();
    return map;
  }
  private BibTrees fetchResultSet(int batchSize, BatchStatistics batchStatistics, Boolean isBibOnly)
      throws Exception {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    BibTrees bibTrees = new BibTrees();
    int count = 0;
    if (batchSize <= 0) {
      return bibTrees;
    }
    while (bibResultSet.next()) {
      count++;
      BibTree bibTree = new BibTree();
      Bib bib = fetchBibRecord();
      bibTree.setBib(bib);
      if (!isBibOnly) {
        List<HoldingsTree> holdingsList =
            fetchHoldingsTreeForBib(Integer.parseInt(bib.getLocalId()));
        bibTree.getHoldingsTrees().addAll(holdingsList);
        batchStatistics.addHoldingsCount(holdingsList.size());

        for (HoldingsTree holdingsTree : holdingsList) {
          batchStatistics.addItemCount(holdingsTree.getItems().size());
        }
      }

      bibTrees.getBibTrees().add(bibTree);
      if (count == batchSize) {
        break;
      }
    }
    stopWatch.stop();
    batchStatistics.addTimeTaken(stopWatch.getTotalTimeMillis());
    batchStatistics.addBibCount(bibTrees.getBibTrees().size());
    return bibTrees;
  }