Beispiel #1
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;
 }
  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;
  }
Beispiel #3
0
  public Map<String, Map> updateItemsToDocstore(List<Item> itemList) {
    org.kuali.ole.docstore.common.document.BibTrees bibTrees =
        new org.kuali.ole.docstore.common.document.BibTrees();

    org.kuali.ole.docstore.common.document.BibTree bibTree =
        new org.kuali.ole.docstore.common.document.BibTree();
    org.kuali.ole.docstore.common.document.Bib bib =
        new org.kuali.ole.docstore.common.document.Bib();
    bibTree.setBib(bib);
    bib.setId("");

    org.kuali.ole.docstore.common.document.HoldingsTree holdingsTree =
        new org.kuali.ole.docstore.common.document.HoldingsTree();
    org.kuali.ole.docstore.common.document.Holdings holdings =
        new org.kuali.ole.docstore.common.document.Holdings();
    holdings.setId("");
    holdingsTree.setHoldings(holdings);

    List<String> locationLevel = BatchBibImportUtil.getLocationLevel();

    for (Iterator<Item> iterator = itemList.iterator(); iterator.hasNext(); ) {
      Item item = iterator.next();
      if (CollectionUtils.isNotEmpty(locationLevel)) {
        populateLocationLevels(item, locationLevel);
      }
      item.buildLocationLevels(
          (org.kuali.ole.docstore.common.document.content.instance.Item) item.getContentObject());
      item.setOperation(
          org.kuali.ole.docstore.common.document.DocstoreDocument.OperationType.UPDATE);
      item.serializeContent();
      holdingsTree.getItems().add(item);
    }

    bibTree.getHoldingsTrees().add(holdingsTree);

    bibTrees.getBibTrees().add(bibTree);
    BibTrees responseBibTree = null;
    try {
      responseBibTree = getDocstoreClientLocator().getDocstoreClient().processBibTrees(bibTrees);
    } catch (Exception e) {
      e.printStackTrace();
    }
    Map<String, Map> statusMap =
        generateResultMapForBibTreeWithItemUuidAndResultType(responseBibTree);
    return statusMap;
  }