Skip to content

Commit

Permalink
Revert "MODINV-943 Add logs"
Browse files Browse the repository at this point in the history
This reverts commit 94c373a.
  • Loading branch information
dmytrokrutii committed May 29, 2024
1 parent a2b9e2c commit 3a312a9
Showing 1 changed file with 2 additions and 46 deletions.
48 changes: 2 additions & 46 deletions src/main/java/org/folio/inventory/resources/Items.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ protected void respondWithManyItems(
CollectionResourceClient locationsClient;

try {
log.info("respondWithManyItems:: creating http clients");
OkapiHttpClient okapiClient = createHttpClient(routingContext, context);
holdingsClient = createHoldingsClient(okapiClient, context);
instancesClient = createInstancesClient(okapiClient, context);
Expand All @@ -322,7 +321,7 @@ protected void respondWithManyItems(
}
catch (MalformedURLException e) {
invalidOkapiUrlResponse(routingContext, context);
log.info("respondWithManyItems:: error while creating http clients", e);

return;
}

Expand Down Expand Up @@ -356,8 +355,6 @@ protected void respondWithManyItems(
final List<JsonObject> holdings = JsonArrayHelper.toList(
holdingsResponse.getJson().getJsonArray("holdingsRecords"));

log.info("respondWithManyItems:: collecting instanceIds");

List<String> instanceIds = holdings.stream()
.map(holding -> holding.getString(INSTANCE_ID_PROPERTY))
.filter(Objects::nonNull)
Expand All @@ -380,21 +377,15 @@ protected void respondWithManyItems(
instancesResponse.getBody()));
}

log.info("respondWithManyItems:: instanceIds size: {}", instanceIds.size());

final List<JsonObject> instances = JsonArrayHelper.toList(
instancesResponse.getJson().getJsonArray("instances"));

log.info("respondWithManyItems:: collecting materialTypeIds");

List<String> materialTypeIds = wrappedItems.records.stream()
.map(Item::getMaterialTypeId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());

log.info("respondWithManyItems:: materialTypeIds size: {}", materialTypeIds.size());

materialTypeIds.forEach(id -> {
CompletableFuture<Response> newFuture = new CompletableFuture<>();

Expand All @@ -404,17 +395,12 @@ protected void respondWithManyItems(
materialTypesClient.get(id, newFuture::complete);
});

log.info("respondWithManyItems:: collecting permanentLoanTypeIds");

List<String> permanentLoanTypeIds = wrappedItems.records.stream()
.map(Item::getPermanentLoanTypeId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());

log.info("respondWithManyItems:: permanentLoanTypeIds size: {}", permanentLoanTypeIds.size());

log.info("respondWithManyItems:: collecting temporaryLoanTypeIds");
List<String> temporaryLoanTypeIds = wrappedItems.records.stream()
.map(Item::getTemporaryLoanTypeId)
.filter(Objects::nonNull)
Expand All @@ -433,28 +419,18 @@ protected void respondWithManyItems(
loanTypesClient.get(id, newFuture::complete);
});

log.info("respondWithManyItems:: collecting effectiveLocationIds");

List<String> effectiveLocationIds = wrappedItems.records.stream()
.map(Item::getEffectiveLocationId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());

log.info("respondWithManyItems:: effectiveLocationIds size: {}", effectiveLocationIds.size());

log.info("respondWithManyItems:: collecting permanentLocationIds");

List<String> permanentLocationIds = wrappedItems.records.stream()
.map(Item::getPermanentLocationId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());

log.info("respondWithManyItems:: permanentLocationIds size: {}", permanentLocationIds.size());

log.info("respondWithManyItems: collecting temporaryLocationIds");

List<String> temporaryLocationIds = wrappedItems.records.stream()
.map(Item::getTemporaryLocationId)
.filter(Objects::nonNull)
Expand All @@ -473,8 +449,6 @@ protected void respondWithManyItems(
locationsClient.get(id, newFuture::complete);
});

log.info("respondWithManyItems:: temporaryLocationIds size: {}", temporaryLocationIds.size());

CompletableFuture<Response> boundWithPartsFuture =
getBoundWithPartsForMultipleItemsFuture(wrappedItems, routingContext);

Expand All @@ -487,45 +461,27 @@ protected void respondWithManyItems(

try {

log.info("respondWithManyItems:: trying to fetch materialTypes");

Map<String, JsonObject> foundMaterialTypes
= allMaterialTypeFutures.stream()
.map(CompletableFuture::join)
.peek(r -> log.info("Fetch material type -> response code '{}'", r.getStatusCode()))
.filter(response -> response.getStatusCode() == 200)
.map(Response::getJson)
.peek(r -> log.info("Successfully fetch material type with id '{}'", r.getString("id")))
.collect(Collectors.toMap(r -> r.getString("id"), r -> r));

log.info("respondWithManyItems:: foundMaterialTypes size: {}", foundMaterialTypes.size());

log.info("respondWithManyItems:: trying to fetch loanTypes");

Map<String, JsonObject> foundLoanTypes
= allLoanTypeFutures.stream()
.map(CompletableFuture::join)
.peek(r -> log.info("Fetch loan type -> response code '{}'", r.getStatusCode()))
.filter(response -> response.getStatusCode() == 200)
.map(Response::getJson)
.peek(r -> log.info("Successfully fetch loan type with id '{}'", r.getString("id")))
.collect(Collectors.toMap(r -> r.getString("id"), r -> r));

log.info("respondWithManyItems:: foundLoanTypes size: {}", foundLoanTypes.size());

log.info("respondWithManyItems:: trying to fetch locations");

Map<String, JsonObject> foundLocations
= allLocationsFutures.stream()
.map(CompletableFuture::join)
.peek(r -> log.info("Fetch location -> response code '{}'", r.getStatusCode()))
.filter(response -> response.getStatusCode() == 200)
.map(Response::getJson)
.peek(r -> log.info("Successfully fetch locations with id '{}'", r.getString("id")))
.collect(Collectors.toMap(r -> r.getString("id"), r -> r));

log.info("respondWithManyItems:: foundLocations size: {}", foundLocations.size());

setBoundWithFlagsOnItems(wrappedItems, boundWithPartsFuture);

JsonResponse.success(routingContext.response(),
Expand Down Expand Up @@ -1104,7 +1060,7 @@ private CompletableFuture<Response> getBoundWithPartsForItemFuture(

private void setBoundWithFlagsOnItems(MultipleRecords<Item> wrappedItems,
CompletableFuture<Response> boundWithPartsFuture) {
log.info("setBoundWithFlagsOnItems:: trying to set withIsBoundWith");

Response response = boundWithPartsFuture.join();
if (response != null && response.hasBody() && response.getStatusCode()==200) {
JsonArray boundWithParts = response.getJson().getJsonArray(BOUND_WITH_PARTS_COLLECTION);
Expand Down

0 comments on commit 3a312a9

Please sign in to comment.