From 5f4d02b5d2f1db1c0d0739790efe8167537d363a Mon Sep 17 00:00:00 2001 From: Javokhir Abdullaev Date: Wed, 28 Aug 2024 20:59:58 +0500 Subject: [PATCH 1/4] Fix DataImportConsumerVerticleTest in mod-inventory and Fix NPE in HoldingsItemMatcher --- .../handlers/matching/loaders/HoldingLoader.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java b/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java index d3acb0e5f..596f2ec3d 100644 --- a/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java +++ b/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java @@ -4,13 +4,11 @@ import static org.apache.commons.lang3.StringUtils.EMPTY; import static org.apache.commons.lang3.StringUtils.isNotEmpty; +import io.vertx.core.json.Json; +import io.vertx.core.json.JsonObject; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; - -import io.vertx.core.json.Json; -import io.vertx.core.json.JsonObject; - import org.folio.DataImportEventPayload; import org.folio.HoldingsRecord; import org.folio.inventory.common.Context; @@ -26,6 +24,7 @@ public class HoldingLoader extends AbstractLoader { private static final String HOLDINGS_FIELD = "holdings"; private static final String INSTANCE_ID_FIELD = "instanceId"; private static final String INSTANCES_IDS_KEY = "INSTANCES_IDS"; + private static final String EMPTY_ARRAY = "[]"; private Storage storage; private AbstractPreloader preloader; @@ -59,7 +58,7 @@ protected String addCqlSubMatchCondition(DataImportEventPayload eventPayload) { cqlSubMatch = getConditionByMultiMatchResult(eventPayload); } else if (isNotEmpty(eventPayload.getContext().get(INSTANCES_IDS_KEY))) { cqlSubMatch = getConditionByMultipleMarcBibMatchResult(eventPayload); - } else if (isNotEmpty(eventPayload.getContext().get(EntityType.HOLDINGS.value()))) { + } else if (checkIfValueIsEmptyArray(eventPayload.getContext().get(EntityType.HOLDINGS.value()))) { JsonObject holdingAsJson = new JsonObject(eventPayload.getContext().get(EntityType.HOLDINGS.value())); if (holdingAsJson.getJsonObject(HOLDINGS_FIELD) != null) { holdingAsJson = holdingAsJson.getJsonObject(HOLDINGS_FIELD); @@ -73,6 +72,12 @@ protected String addCqlSubMatchCondition(DataImportEventPayload eventPayload) { return cqlSubMatch; } + private static boolean checkIfValueIsEmptyArray(String value) { + if (value.equals(EMPTY_ARRAY)) + return false; + return isNotEmpty(value); + } + private String getConditionByMultipleMarcBibMatchResult(DataImportEventPayload eventPayload) { return getConditionByMultipleValues(INSTANCE_ID_FIELD, eventPayload, INSTANCES_IDS_KEY); } From eaff5ba697659c77444e6c7c73f868ab4ea75386 Mon Sep 17 00:00:00 2001 From: Javokhir Abdullaev Date: Wed, 28 Aug 2024 21:55:39 +0500 Subject: [PATCH 2/4] Fix DataImportConsumerVerticleTest in mod-inventory and Fix NPE in HoldingsItemMatcher --- .../dataimport/handlers/matching/loaders/HoldingLoader.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java b/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java index 596f2ec3d..7dbaecc96 100644 --- a/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java +++ b/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java @@ -58,7 +58,7 @@ protected String addCqlSubMatchCondition(DataImportEventPayload eventPayload) { cqlSubMatch = getConditionByMultiMatchResult(eventPayload); } else if (isNotEmpty(eventPayload.getContext().get(INSTANCES_IDS_KEY))) { cqlSubMatch = getConditionByMultipleMarcBibMatchResult(eventPayload); - } else if (checkIfValueIsEmptyArray(eventPayload.getContext().get(EntityType.HOLDINGS.value()))) { + } else if (checkIfValueIsNullOrEmpty(eventPayload.getContext().get(EntityType.HOLDINGS.value()))) { JsonObject holdingAsJson = new JsonObject(eventPayload.getContext().get(EntityType.HOLDINGS.value())); if (holdingAsJson.getJsonObject(HOLDINGS_FIELD) != null) { holdingAsJson = holdingAsJson.getJsonObject(HOLDINGS_FIELD); @@ -72,8 +72,8 @@ protected String addCqlSubMatchCondition(DataImportEventPayload eventPayload) { return cqlSubMatch; } - private static boolean checkIfValueIsEmptyArray(String value) { - if (value.equals(EMPTY_ARRAY)) + private static boolean checkIfValueIsNullOrEmpty(String value) { + if (value == null || value.equals(EMPTY_ARRAY)) return false; return isNotEmpty(value); } From 9c49ebb81d2723d659fbacc4daba4455024fab6a Mon Sep 17 00:00:00 2001 From: Javokhir Abdullaev Date: Thu, 29 Aug 2024 19:50:08 +0500 Subject: [PATCH 3/4] small fix --- .../dataimport/handlers/matching/loaders/HoldingLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java b/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java index 7dbaecc96..975465859 100644 --- a/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java +++ b/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java @@ -58,7 +58,7 @@ protected String addCqlSubMatchCondition(DataImportEventPayload eventPayload) { cqlSubMatch = getConditionByMultiMatchResult(eventPayload); } else if (isNotEmpty(eventPayload.getContext().get(INSTANCES_IDS_KEY))) { cqlSubMatch = getConditionByMultipleMarcBibMatchResult(eventPayload); - } else if (checkIfValueIsNullOrEmpty(eventPayload.getContext().get(EntityType.HOLDINGS.value()))) { + } else if (IsNotNullOrEmpty(eventPayload.getContext().get(EntityType.HOLDINGS.value()))) { JsonObject holdingAsJson = new JsonObject(eventPayload.getContext().get(EntityType.HOLDINGS.value())); if (holdingAsJson.getJsonObject(HOLDINGS_FIELD) != null) { holdingAsJson = holdingAsJson.getJsonObject(HOLDINGS_FIELD); @@ -72,7 +72,7 @@ protected String addCqlSubMatchCondition(DataImportEventPayload eventPayload) { return cqlSubMatch; } - private static boolean checkIfValueIsNullOrEmpty(String value) { + private static boolean IsNotNullOrEmpty(String value) { if (value == null || value.equals(EMPTY_ARRAY)) return false; return isNotEmpty(value); From 398f4df6a57752e487f751bc4673e3d74a42e65b Mon Sep 17 00:00:00 2001 From: Javokhir Abdullaev Date: Thu, 29 Aug 2024 20:39:55 +0500 Subject: [PATCH 4/4] small fix --- .../dataimport/handlers/matching/loaders/HoldingLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java b/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java index 975465859..44a8364bb 100644 --- a/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java +++ b/src/main/java/org/folio/inventory/dataimport/handlers/matching/loaders/HoldingLoader.java @@ -58,7 +58,7 @@ protected String addCqlSubMatchCondition(DataImportEventPayload eventPayload) { cqlSubMatch = getConditionByMultiMatchResult(eventPayload); } else if (isNotEmpty(eventPayload.getContext().get(INSTANCES_IDS_KEY))) { cqlSubMatch = getConditionByMultipleMarcBibMatchResult(eventPayload); - } else if (IsNotNullOrEmpty(eventPayload.getContext().get(EntityType.HOLDINGS.value()))) { + } else if (isNotNullOrEmpty(eventPayload.getContext().get(EntityType.HOLDINGS.value()))) { JsonObject holdingAsJson = new JsonObject(eventPayload.getContext().get(EntityType.HOLDINGS.value())); if (holdingAsJson.getJsonObject(HOLDINGS_FIELD) != null) { holdingAsJson = holdingAsJson.getJsonObject(HOLDINGS_FIELD); @@ -72,7 +72,7 @@ protected String addCqlSubMatchCondition(DataImportEventPayload eventPayload) { return cqlSubMatch; } - private static boolean IsNotNullOrEmpty(String value) { + private static boolean isNotNullOrEmpty(String value) { if (value == null || value.equals(EMPTY_ARRAY)) return false; return isNotEmpty(value);