コード例 #1
0
ファイル: BulkItemUpdateUtil.java プロジェクト: peris/ole
 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;
 }
コード例 #2
0
ファイル: BulkItemUpdateUtil.java プロジェクト: peris/ole
 private void populateLocationLevels(Item item, List<String> locationLevel) {
   item.setLevel1Location(locationLevel.get(0));
   item.setLevel2Location(locationLevel.get(1));
   item.setLevel3Location(locationLevel.get(2));
   item.setLevel4Location(locationLevel.get(3));
   item.setLevel5Location(locationLevel.get(4));
 }
コード例 #3
0
ファイル: BulkItemUpdateUtil.java プロジェクト: peris/ole
  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;
  }
  public List<Item> fetchItemForHoldings(int holdingsId) throws Exception {
    List<Item> itemList = new ArrayList<Item>();
    Map<String, Item> itemHashMap = new HashMap<>();
    itemPreparedStatement.setInt(1, holdingsId);
    ResultSet resultSet = itemPreparedStatement.executeQuery();
    Set<String> highDensityStorageSet = null;
    Set<String> donorNoteSet = null;
    Set<String> itemNoteSet = null;
    Set<String> statisticalSearchSet = null;
    org.kuali.ole.docstore.common.document.content.instance.Item itemObj = null;

    while (resultSet.next()) {
      String id = resultSet.getString("ITEM_ID");
      if (itemHashMap.containsKey(id)) {
        itemObj =
            (org.kuali.ole.docstore.common.document.content.instance.Item)
                itemHashMap.get(id).getContentObject();
      } else {
        itemObj = new org.kuali.ole.docstore.common.document.content.instance.Item();
        Item item = new Item();
        itemList.add(item);
        item.setId("wio-" + resultSet.getString("ITEM_ID"));
        item.setContentObject(itemObj);
        Location location =
            getLocationDetails(
                resultSet.getString("LOCATION"), resultSet.getString("LOCATION_LEVEL"));
        itemObj.setLocation(location);
        CallNumber callNumber = new CallNumber();
        callNumber.setNumber(resultSet.getString("CALL_NUMBER"));
        callNumber.setPrefix(resultSet.getString("CALL_NUMBER_PREFIX"));
        ShelvingOrder shelvingOrder = new ShelvingOrder();
        if (resultSet.getString("SHELVING_ORDER") != null
            && !"null".equals(resultSet.getString("SHELVING_ORDER"))) {
          shelvingOrder.setCodeValue(resultSet.getString("SHELVING_ORDER"));
          shelvingOrder.setFullValue(resultSet.getString("SHELVING_ORDER"));
        }
        callNumber.setShelvingOrder(shelvingOrder);
        ShelvingScheme shelvingScheme = new ShelvingScheme();
        if (callNumberType.get(resultSet.getString("CALL_NUMBER_TYPE_ID")) != null) {
          String[] strings =
              callNumberType.get(resultSet.getString("CALL_NUMBER_TYPE_ID")).split("[|]");
          shelvingScheme.setCodeValue(strings[0]);
          shelvingScheme.setFullValue(strings[1]);
        }
        callNumber.setShelvingScheme(shelvingScheme);
        itemObj.setCallNumber(callNumber);
        itemObj.setBarcodeARSL(resultSet.getString("BARCODE_ARSL"));
        itemObj.setEnumeration(resultSet.getString("ENUMERATION"));
        itemObj.setChronology(resultSet.getString("CHRONOLOGY"));
        itemObj.setCopyNumber(resultSet.getString("COPY_NUMBER"));
        AccessInformation accessInformation = new AccessInformation();
        accessInformation.setBarcode(resultSet.getString("BARCODE"));
        Uri uri = new Uri();
        uri.setValue(resultSet.getString("URI"));
        accessInformation.setUri(uri);
        itemObj.setAccessInformation(accessInformation);
        itemObj.setPurchaseOrderLineItemIdentifier(
            resultSet.getString("PURCHASE_ORDER_LINE_ITEM_ID"));
        itemObj.setVendorLineItemIdentifier(resultSet.getString("VENDOR_LINE_ITEM_ID"));
        itemObj.setFund(resultSet.getString("FUND"));
        itemObj.setPrice(resultSet.getString("PRICE"));
        itemObj.setItemStatusEffectiveDate(
            convertDateFormat(resultSet.getString("ITEM_STATUS_DATE_UPDATED")));
        if (resultSet.getString("FAST_ADD") != null) {
          itemObj.setFastAddFlag(
              resultSet.getString("FAST_ADD").equalsIgnoreCase("Y") ? Boolean.TRUE : Boolean.FALSE);
        }
        itemObj.setCheckinNote(resultSet.getString("CHECK_IN_NOTE"));
        if (resultSet.getString("CLAIMS_RETURNED") != null) {
          itemObj.setClaimsReturnedFlag(
              resultSet.getString("CLAIMS_RETURNED").equalsIgnoreCase("Y")
                  ? Boolean.TRUE
                  : Boolean.FALSE);
        }
        String claimsReturnFlagCreatedDate = resultSet.getString("CLAIMS_RETURNED_DATE_CREATED");
        itemObj.setClaimsReturnedFlagCreateDate(convertDateFormat(claimsReturnFlagCreatedDate));
        itemObj.setClaimsReturnedNote(resultSet.getString("CLAIMS_RETURNED_NOTE"));
        itemObj.setCurrentBorrower(resultSet.getString("CURRENT_BORROWER"));
        itemObj.setProxyBorrower(resultSet.getString("PROXY_BORROWER"));
        String dueDateTime = resultSet.getString("DUE_DATE_TIME");
        itemObj.setDueDateTime(convertDateFormat(dueDateTime));
        String originalDueDate = resultSet.getString("ORG_DUE_DATE_TIME");
        itemObj.setOriginalDueDate(convertDateFormat(originalDueDate));
        String checkOutDateTime = resultSet.getString("CHECK_OUT_DATE_TIME");
        itemObj.setCheckOutDateTime(convertDateFormat(checkOutDateTime));
        itemObj.setDamagedItemNote(resultSet.getString("ITEM_DAMAGED_NOTE"));
        if (resultSet.getString("ITEM_DAMAGED_STATUS") != null) {
          itemObj.setItemDamagedStatus(
              resultSet.getString("ITEM_DAMAGED_STATUS").equalsIgnoreCase("Y")
                  ? Boolean.TRUE
                  : Boolean.FALSE);
        }
        if (resultSet.getString("MISSING_PIECES") != null) {
          itemObj.setMissingPieceFlag(
              resultSet.getString("MISSING_PIECES").equalsIgnoreCase("Y")
                  ? Boolean.TRUE
                  : Boolean.FALSE);
        }
        itemObj.setMissingPiecesCount(resultSet.getString("MISSING_PIECES_COUNT"));
        itemObj.setMissingPieceFlagNote(resultSet.getString("MISSING_PIECES_NOTE"));
        itemObj.setMissingPieceEffectiveDate(resultSet.getString("MISSING_PIECES_EFFECTIVE_DATE"));
        itemObj.setNumberOfPieces(resultSet.getString("NUM_PIECES"));
        itemObj.setDescriptionOfPieces(resultSet.getString("DESC_OF_PIECES"));
        itemObj.setNumberOfRenew(resultSet.getInt("NUM_OF_RENEW"));
        highDensityStorageSet = new HashSet<>();
        itemNoteSet = new HashSet<>();
        statisticalSearchSet = new HashSet<>();
        donorNoteSet = new HashSet<>();

        ItemStatus itemStatus = new ItemStatus();
        if (itemStatusMap.containsKey(resultSet.getString("ITEM_STATUS_ID"))) {
          String[] strings = itemStatusMap.get(resultSet.getString("ITEM_STATUS_ID")).split("[|]");
          itemStatus.setCodeValue(strings[0]);
          itemStatus.setFullValue(strings[1]);
        }

        itemObj.setItemStatus(itemStatus);
        ItemType itemType = new ItemType();
        if (itemTypeMap.containsKey(resultSet.getString("ITEM_TYPE_ID"))) {
          String[] strings = itemTypeMap.get(resultSet.getString("ITEM_TYPE_ID")).split("[|]");
          itemType.setCodeValue(strings[0]);
          itemType.setFullValue(strings[1]);
        }
        itemObj.setItemType(itemType);
        ItemType tempItemType = new ItemType();
        if (itemTypeMap.containsKey(resultSet.getString("TEMP_ITEM_TYPE_ID"))) {
          String[] strings = itemTypeMap.get(resultSet.getString("TEMP_ITEM_TYPE_ID")).split("[|]");
          tempItemType.setCodeValue(strings[0]);
          tempItemType.setFullValue(strings[1]);
        }
        itemObj.setTemporaryItemType(tempItemType);
        item.setContentObject(itemObj);
        item.setCreatedBy(resultSet.getString("CREATED_BY"));
        item.setCreatedOn(resultSet.getString("DATE_CREATED"));
        if (resultSet.getString("STAFF_ONLY") != null) {
          item.setStaffOnly(
              (resultSet.getString("STAFF_ONLY").equalsIgnoreCase("Y")
                  ? Boolean.TRUE
                  : Boolean.FALSE));
        }
        item.setUpdatedBy(resultSet.getString("UPDATED_BY"));
        item.setUpdatedOn(resultSet.getString("DATE_UPDATED"));
        item.setLastUpdated(resultSet.getString("DATE_UPDATED"));
      }
      if (itemNoteSet.add(resultSet.getString("ITEM_NOTE_ID"))) {
        Note note = new Note();
        note.setValue(resultSet.getString("NOTE"));
        note.setType(resultSet.getString("TYPE"));
        itemObj.getNote().add(note);
      }
      if (resultSet.getString("STAT_SEARCH_CODE_ID") != null
          && statisticalSearchSet.add(resultSet.getString("STAT_SEARCH_CODE_ID"))) {
        String[] strings =
            statisticalSearchCodeMap.get(resultSet.getString("STAT_SEARCH_CODE_ID")).split("[|]");
        StatisticalSearchingCode statisticalSearchingCode = new StatisticalSearchingCode();
        statisticalSearchingCode.setCodeValue(strings[0]);
        statisticalSearchingCode.setFullValue(strings[1]);
        itemObj.getStatisticalSearchingCode().add(statisticalSearchingCode);
      }
      if (donorNoteSet.add(resultSet.getString("ITEM_DONOR_ID"))) {
        DonorInfo donorInfo = new DonorInfo();
        donorInfo.setDonorCode(resultSet.getString("DONOR_CODE"));
        donorInfo.setDonorNote(resultSet.getString("DONOR_NOTE"));
        donorInfo.setDonorPublicDisplay(resultSet.getString("DONOR_DISPLAY_NOTE"));
        itemObj.getDonorInfo().add(donorInfo);
      }
      if (highDensityStorageSet.add(resultSet.getString("ITEM_DONOR_ID"))) {
        HighDensityStorage highDensityStorage = new HighDensityStorage();
        highDensityStorage.setRow(resultSet.getString("HIGH_DENSITY_ROW"));
        itemObj.setHighDensityStorage(highDensityStorage);
      }
    }
    resultSet.close();
    return itemList;
  }
コード例 #5
0
ファイル: CheckinItemServiceImpl.java プロジェクト: peris/ole
  public String checkinItem(Map checkinParameters) {

    CheckInAPIController checkInAPIController = new CheckInAPIController();

    setOleCheckInItem(new OLECheckInItem());
    setOleCirculationDesk(null);

    String operatorId = getOperatorId((String) checkinParameters.get("operatorId"));
    String itemBarcode = (String) checkinParameters.get("itemBarcode");
    String deleteIndicator = (String) checkinParameters.get("deleteIndicator");
    setResponseFormatType(checkinParameters);

    boolean isValid = validate(operatorId, itemBarcode);
    if (!isValid) {
      return prepareResponse();
    }

    DroolsExchange droolsExchange = new DroolsExchange();
    droolsExchange.addToContext("itemBarcode", itemBarcode);
    droolsExchange.addToContext(
        "selectedCirculationDesk", getOleCirculationDesk().getCirculationDeskId());
    droolsExchange.addToContext("operatorId", operatorId);
    OLEForm oleAPIForm = new OLEForm();
    oleAPIForm.setDroolsExchange(droolsExchange);

    try {
      DroolsResponse droolsResponse = checkInAPIController.checkin(oleAPIForm);
      if (droolsResponse != null
          && StringUtils.isNotBlank(droolsResponse.getErrorMessage().getErrorMessage())) {
        String checkinErrorMessage = droolsResponse.getErrorMessage().getErrorMessage();
        String responseMessage = null;
        if (droolsResponse.retriveErrorCode() != null) {
          if (droolsResponse
              .retriveErrorCode()
              .equalsIgnoreCase(DroolsConstants.ITEM_CLAIMS_RETURNED)) {
            responseMessage = "Item is Claims Returned";
          } else if (droolsResponse
              .retriveErrorCode()
              .equalsIgnoreCase(DroolsConstants.ITEM_MISSING_PIECE)) {
            responseMessage = "Item has missing pieces";
          } else if (droolsResponse
              .retriveErrorCode()
              .equalsIgnoreCase(DroolsConstants.ITEM_DAMAGED)) {
            responseMessage = "Item is Damaged.";
          } else if (droolsResponse
              .retriveErrorCode()
              .equalsIgnoreCase(DroolsConstants.CHECKIN_REQUEST_EXITS_FOR_THIS_ITEM)) {
            responseMessage = "Requests exists for this item";
          }
        }
        if (StringUtils.isNotBlank(responseMessage)) {
          getOleCheckInItem().setCode("500");
          getOleCheckInItem().setMessage(responseMessage);
          return prepareResponse();
        } else if (checkinErrorMessage.equalsIgnoreCase("Invalid item barcode!")) {
          getOleCheckInItem().setCode("014");
          getOleCheckInItem().setMessage(checkinErrorMessage);
          return prepareResponse();
        }
        getOleCheckInItem().setCode("500");
        getOleCheckInItem().setMessage(checkinErrorMessage);
        return prepareResponse();
      } else {
        CheckedInItem checkedInItem =
            (CheckedInItem) droolsExchange.getFromContext("checkedInItem");
        if (checkedInItem != null) {
          getOleCheckInItem().setAuthor(checkedInItem.getAuthor());
          getOleCheckInItem().setTitle(checkedInItem.getTitle());
          getOleCheckInItem().setCallNumber(checkedInItem.getCallNumber());
          getOleCheckInItem().setBarcode(checkedInItem.getItemBarcode());
          getOleCheckInItem().setUserId(checkedInItem.getPatronId());
          getOleCheckInItem().setUserType(checkedInItem.getBorrowerType());
          getOleCheckInItem().setItemType(checkedInItem.getItemType());
          getOleCheckInItem().setCode("024");
          getOleCheckInItem()
              .setMessage(
                  ConfigContext.getCurrentContextConfig()
                      .getProperty(OLEConstants.SUCCESSFULLEY_CHECKED_IN));

          if (StringUtils.isNotBlank(deleteIndicator) && deleteIndicator.equalsIgnoreCase("y")) {
            try {
              org.kuali.ole.docstore.common.document.Item item =
                  getDocstoreClientLocator()
                      .getDocstoreClient()
                      .retrieveItem(checkedInItem.getItemUuid());
              String bibId = item.getHolding().getBib().getId();
              getDocstoreClientLocator().getDocstoreClient().deleteBib(bibId);
            } catch (Exception e) {
              LOG.error("Exception while deleting bib" + e);
              getOleCheckInItem()
                  .setMessage(
                      "Item "
                          + ConfigContext.getCurrentContextConfig()
                              .getProperty(OLEConstants.SUCCESSFULLEY_CHECKED_IN)
                          + " but Deletion is failed");
              return prepareResponse();
            }
          }
          return prepareResponse();
        } else {
          getOleCheckInItem().setCode("025");
          getOleCheckInItem()
              .setMessage(
                  ConfigContext.getCurrentContextConfig()
                      .getProperty(OLEConstants.CHECK_IN_FAILED));
          return prepareResponse();
        }
      }
    } catch (Exception e) {
      LOG.error("Exception " + e);
      getOleCheckInItem().setCode("025");
      getOleCheckInItem()
          .setMessage(
              ConfigContext.getCurrentContextConfig().getProperty(OLEConstants.CHECK_IN_FAILED));
      return prepareResponse();
    }
  }