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;
  }
Exemplo n.º 2
0
 private Map<String, Map> generateResultMapForBibTreeWithItemUuidAndResultType(BibTrees bibTrees) {
   Map<String, Map> resultTypeMap = new HashMap<>();
   if (null != bibTrees) {
     List<BibTree> bibTreeList = bibTrees.getBibTrees();
     if (CollectionUtils.isNotEmpty(bibTreeList)) {
       for (Iterator<BibTree> bibTreeIterator = bibTreeList.iterator();
           bibTreeIterator.hasNext(); ) {
         BibTree bibTree = bibTreeIterator.next();
         List<HoldingsTree> holdingsTrees = bibTree.getHoldingsTrees();
         if (CollectionUtils.isNotEmpty(holdingsTrees)) {
           for (Iterator<HoldingsTree> holdingsTreeIterator = holdingsTrees.iterator();
               holdingsTreeIterator.hasNext(); ) {
             HoldingsTree holdingsTree = holdingsTreeIterator.next();
             List<Item> items = holdingsTree.getItems();
             if (CollectionUtils.isNotEmpty(items)) {
               for (Iterator<Item> itemIterator = items.iterator(); itemIterator.hasNext(); ) {
                 Item item = itemIterator.next();
                 Map statusMap = new HashMap();
                 statusMap.put("result", item.getResult());
                 statusMap.put("message", item.getMessage());
                 statusMap.put("barcode", item.getBarcode());
                 resultTypeMap.put(item.getId(), statusMap);
               }
             }
           }
         }
       }
     }
   }
   return resultTypeMap;
 }
Exemplo n.º 3
0
 @Test
 public void deserializeAndSerialize() {
   String input = "";
   File file = null;
   try {
     file = new File(getClass().getResource("/documents/BibTrees1.xml").toURI());
     input = FileUtils.readFileToString(file);
   } catch (Exception e) {
     LOG.error("Exception ", e);
   }
   BibTrees.deserialize(input);
 }