Skip to content

Commit

Permalink
CIRC-2136 set new location on check-in response and pick slip context.
Browse files Browse the repository at this point in the history
  • Loading branch information
nielserik committed Oct 24, 2024
1 parent 4b1964b commit e98235b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public CompletableFuture<Result<Location>> getPermanentLocation(Item item) {
return getLocation(item, Item::getPermanentLocationId);
}

public CompletableFuture<Result<Location>> getFloatDestinationLocation(Item item) {
log.debug("getFloatDestinationLocation:: parameters item: {}", item);
return getLocation(item, Item::getFloatDestinationLocationId);
}

private CompletableFuture<Result<Location>> getLocation(Item item,
Function<Item, String> locationIdGetter) {
log.debug("getLocation:: parameters item: {}", item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ CompletableFuture<Result<Item>> 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);
}
Expand Down

0 comments on commit e98235b

Please sign in to comment.