From e98235b3d00f7929172ce7d798fc595d6c41699f Mon Sep 17 00:00:00 2001 From: nielserik Date: Thu, 24 Oct 2024 11:18:06 +0200 Subject: [PATCH] CIRC-2136 set new location on check-in response and pick slip context. --- .../folio/circulation/domain/notice/TemplateContextUtil.java | 3 ++- .../domain/representations/ItemSummaryRepresentation.java | 5 ++++- .../infrastructure/storage/inventory/LocationRepository.java | 5 +++++ .../folio/circulation/resources/CheckInProcessAdapter.java | 4 +++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/folio/circulation/domain/notice/TemplateContextUtil.java b/src/main/java/org/folio/circulation/domain/notice/TemplateContextUtil.java index 948a695327..213fe69013 100644 --- a/src/main/java/org/folio/circulation/domain/notice/TemplateContextUtil.java +++ b/src/main/java/org/folio/circulation/domain/notice/TemplateContextUtil.java @@ -211,7 +211,8 @@ private static JsonObject createItemContext(Item item) { .put("displaySummary", item.getDisplaySummary()) .put("descriptionOfPieces", item.getDescriptionOfPieces()); - Location location = item.getLocation(); + Location location = item.canFloatThroughCheckInServicePoint() ? + item.getFloatDestinationLocation() : item.getLocation(); if (location != null) { log.info("createItemContext:: location is not null"); diff --git a/src/main/java/org/folio/circulation/domain/representations/ItemSummaryRepresentation.java b/src/main/java/org/folio/circulation/domain/representations/ItemSummaryRepresentation.java index f9143cc197..8f02b05cc3 100644 --- a/src/main/java/org/folio/circulation/domain/representations/ItemSummaryRepresentation.java +++ b/src/main/java/org/folio/circulation/domain/representations/ItemSummaryRepresentation.java @@ -78,7 +78,10 @@ public JsonObject createItemSummary(Item item) { final Location location = item.getLocation(); - if (location != null) { + if (item.canFloatThroughCheckInServicePoint()) { + itemSummary.put("location", new JsonObject() + .put("name", item.getFloatDestinationLocation().getName())); + } else if (location != null) { log.info("createItemSummary:: location is not null"); itemSummary.put("location", new JsonObject() .put("name", location.getName())); diff --git a/src/main/java/org/folio/circulation/infrastructure/storage/inventory/LocationRepository.java b/src/main/java/org/folio/circulation/infrastructure/storage/inventory/LocationRepository.java index 9c95b5712b..5ce2848381 100644 --- a/src/main/java/org/folio/circulation/infrastructure/storage/inventory/LocationRepository.java +++ b/src/main/java/org/folio/circulation/infrastructure/storage/inventory/LocationRepository.java @@ -88,6 +88,11 @@ public CompletableFuture> getPermanentLocation(Item item) { return getLocation(item, Item::getPermanentLocationId); } + public CompletableFuture> getFloatDestinationLocation(Item item) { + log.debug("getFloatDestinationLocation:: parameters item: {}", item); + return getLocation(item, Item::getFloatDestinationLocationId); + } + private CompletableFuture> getLocation(Item item, Function locationIdGetter) { log.debug("getLocation:: parameters item: {}", item); diff --git a/src/main/java/org/folio/circulation/resources/CheckInProcessAdapter.java b/src/main/java/org/folio/circulation/resources/CheckInProcessAdapter.java index 88bda6bfb9..5179afe894 100644 --- a/src/main/java/org/folio/circulation/resources/CheckInProcessAdapter.java +++ b/src/main/java/org/folio/circulation/resources/CheckInProcessAdapter.java @@ -309,7 +309,9 @@ CompletableFuture> findFloatingDestination(CheckInContext context) return locationRepository.fetchLocationsForServicePoint(context.getCheckInServicePointId().toString()) .thenApply(rLocations -> rLocations.map(locations -> locations.stream() .filter(Location::isFloatingCollection).findFirst() - .map(item::withFloatDestinationLocation).orElse(item))); + .map(item::withFloatDestinationLocation).orElse(item))) + .thenCompose(it -> locationRepository.getFloatDestinationLocation(it.value())) + .thenApply(location -> Result.succeeded(item.withFloatDestinationLocation(location.value()))); } else { return Result.ofAsync(item); }