Skip to content

Commit

Permalink
CIRCSTORE-540: fix NLP due to logging of null object
Browse files Browse the repository at this point in the history
  • Loading branch information
kapil-epam committed Dec 17, 2024
1 parent b25ccac commit 0d592b3
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ protected Future<List<Change<Request>>> collectRelevantChanges(JsonObject payloa
changes.add(new Change<>(request -> request.getSearchIndex().setShelvingOrder(newShelvingOrder)));
}

Future<Map<String, String>> fetchLocationAndServicePoint = updateItemAndServicePoint(newObject, changes);
Future<Map<String, String>> fetchLocationAndServicePoint = updateItemAndServicePoint(newObject);
return fetchLocationAndServicePoint
.compose(locationAndSpData -> addLocationAndServicePointChanges(locationAndSpData, changes))
.compose(res -> Future.succeededFuture(changes));
.compose(r -> Future.succeededFuture(changes))
.recover(throwable -> Future.succeededFuture(changes));
}

private static Future<List<Change<Request>>> addLocationAndServicePointChanges(Map<String, String> locationAndSpData, List<Change<Request>> changes) {
log.info("ItemUpdateProcessorForRequest :: locationAndSpData: {}", locationAndSpData);
changes.add(new Change<>(request -> {
if (request.getItem() == null) {
request.setItem(new Item());
Expand All @@ -90,7 +92,7 @@ private static Future<List<Change<Request>>> addLocationAndServicePointChanges(M
return Future.succeededFuture(changes);
}

private Future<Map<String, String>> updateItemAndServicePoint(JsonObject newObject, List<Change<Request>> changes) {
private Future<Map<String, String>> updateItemAndServicePoint(JsonObject newObject) {
String effectiveLocationId = newObject.getString("effectiveLocationId");
Map<String, String> locationAndSpData = new HashMap<>();
locationAndSpData.put(ITEM_EFFECTIVE_LOCATION_ID, effectiveLocationId);
Expand All @@ -108,8 +110,6 @@ private static Future<String> setEffectiveLocationData(Collection<Location> loca
Location effectiveLocation = locations.stream()
.filter(l -> l.getId().equals(effectiveLocationId))
.findFirst().orElse(null);
log.info("ItemUpdateProcessorForRequest :: setEffectiveLocationName(): locationsName: {}",
JsonObject.mapFrom(effectiveLocation).encode());
if (Objects.nonNull(effectiveLocation)) {
locationAndSpData.put(ITEM_EFFECTIVE_LOCATION_NAME, effectiveLocation.getName());
return succeededFuture(effectiveLocation.getPrimaryServicePoint().toString());
Expand All @@ -125,8 +125,6 @@ private Future<Object> setRetrievalServicePointData(String primaryServicePoint,
Servicepoint retrievalServicePoint = servicePoints.stream()
.filter(sp -> sp.getId().equals(primaryServicePoint))
.findFirst().orElse(null);
log.info("ItemUpdateProcessorForRequest :: setServicePoint(): {}",
JsonObject.mapFrom(retrievalServicePoint).encode());
if (Objects.nonNull(retrievalServicePoint)) {
locationAndSpData.put(RETRIEVAL_SERVICE_POINT_NAME, retrievalServicePoint.getName());
}
Expand Down

0 comments on commit 0d592b3

Please sign in to comment.