use of org.folio.service.inventory.InventoryManager.ITEM_HOLDINGS_RECORD_ID in project mod-orders by folio-org.
the class CheckinReceivePiecesHelper method processItemsUpdate.
protected CompletableFuture<Map<String, List<Piece>>> processItemsUpdate(Map<String, Map<String, Location>> pieceLocationsGroupedByPoLine, Map<String, List<Piece>> piecesGroupedByPoLine, List<JsonObject> items, PoLineAndTitleById poLinesAndTitlesById, RequestContext requestContext) {
List<CompletableFuture<Boolean>> futuresForItemsUpdates = new ArrayList<>();
Map<String, Piece> piecesWithItems = collectPiecesWithItemId(piecesGroupedByPoLine);
// If there are no pieces with ItemId, continue
if (piecesWithItems.isEmpty()) {
return completedFuture(piecesGroupedByPoLine);
}
for (JsonObject item : items) {
String itemId = item.getString(ID);
Piece piece = piecesWithItems.get(itemId);
CompositePoLine poLine = poLinesAndTitlesById.poLineById.get(piece.getPoLineId());
if (poLine == null)
continue;
Title title = poLinesAndTitlesById.titleById.get(piece.getTitleId());
if (title == null)
continue;
Location pieceLocation = pieceLocationsGroupedByPoLine.get(poLine.getId()).get(piece.getId());
if (holdingUpdateOnCheckinReceiveRequired(piece, pieceLocation, poLine) && !isRevertToOnOrder(piece)) {
String holdingKey = buildProcessedHoldingKey(pieceLocation, title.getInstanceId());
String holdingId = processedHoldings.get(holdingKey);
item.put(ITEM_HOLDINGS_RECORD_ID, holdingId);
}
futuresForItemsUpdates.add(receiveInventoryItemAndUpdatePiece(item, piece, requestContext));
}
return collectResultsOnSuccess(futuresForItemsUpdates).thenApply(results -> {
if (logger.isDebugEnabled()) {
long successQty = results.stream().filter(result -> result).count();
logger.debug("{} out of {} inventory item(s) successfully updated", successQty, results.size());
}
return piecesGroupedByPoLine;
});
}
Aggregations