use of org.folio.rest.jaxrs.model.CompositePoLine.OrderFormat.ELECTRONIC_RESOURCE in project mod-orders by folio-org.
the class InventoryManager method openOrderCreateItemRecord.
/**
* Return id of created Item
*/
public CompletableFuture<String> openOrderCreateItemRecord(CompositePoLine compPOL, String holdingId, RequestContext requestContext) {
final int ITEM_QUANTITY = 1;
logger.debug("Handling {} items for PO Line and holdings with id={}", ITEM_QUANTITY, holdingId);
FolioVertxCompletableFuture<String> itemFuture = new FolioVertxCompletableFuture<>(requestContext.getContext());
try {
Piece pieceWithHoldingId = new Piece().withHoldingId(holdingId);
if (compPOL.getOrderFormat() == ELECTRONIC_RESOURCE) {
createMissingElectronicItems(compPOL, pieceWithHoldingId, ITEM_QUANTITY, requestContext).thenApply(idS -> itemFuture.complete(idS.get(0))).exceptionally(itemFuture::completeExceptionally);
} else {
createMissingPhysicalItems(compPOL, pieceWithHoldingId, ITEM_QUANTITY, requestContext).thenApply(idS -> itemFuture.complete(idS.get(0))).exceptionally(itemFuture::completeExceptionally);
}
} catch (Exception e) {
itemFuture.completeExceptionally(e);
}
return itemFuture;
}
Aggregations