From b8da483c801dfbbd54c23e6276ea74dd66af2dab Mon Sep 17 00:00:00 2001 From: Javokhir Abdullaev Date: Tue, 30 Jul 2024 19:16:15 +0500 Subject: [PATCH] MODINV-1049 Existing "035" field is not retained the original position in imported record --- .../services/util/AdditionalFieldsUtil.java | 19 ++++++++----------- ramls/raml-storage | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/mod-source-record-storage-server/src/main/java/org/folio/services/util/AdditionalFieldsUtil.java b/mod-source-record-storage-server/src/main/java/org/folio/services/util/AdditionalFieldsUtil.java index 8cb8d8ff3..6239a732f 100644 --- a/mod-source-record-storage-server/src/main/java/org/folio/services/util/AdditionalFieldsUtil.java +++ b/mod-source-record-storage-server/src/main/java/org/folio/services/util/AdditionalFieldsUtil.java @@ -27,6 +27,7 @@ import java.util.Optional; import java.util.Set; import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; @@ -57,7 +58,6 @@ public final class AdditionalFieldsUtil { public static final String TAG_00X_PREFIX = "00"; public static final String TAG_005 = "005"; - private static final String TAG_010 = "010"; public static final String TAG_999 = "999"; public static final String TAG_035 = "035"; public static final char TAG_035_SUB = 'a'; @@ -548,19 +548,16 @@ private static List get035oclcSubfields(VariableField field, char subf private static void replaceOclc035FieldWithNormalizedData(org.marc4j.marc.Record marcRecord, DataField dataField) { var variableFields = marcRecord.getVariableFields(TAG_035); + var index = new AtomicInteger(); if (!variableFields.isEmpty()) { variableFields.stream() .filter(variableField -> variableField.find(OCLC)) - .forEach(marcRecord::removeVariableField); - - var dataFields = marcRecord.getDataFields(); - for (int i = 0; i < dataFields.size(); i++) { - if (dataFields.get(i).getTag().equals(TAG_010)) { - marcRecord.getDataFields().add(i + 1, dataField); - return; - } - } - addDataFieldInNumericalOrder(dataField, marcRecord); + .forEach(variableField -> { + if (index.get() == 0) + index.set(marcRecord.getDataFields().indexOf(variableField)); + marcRecord.removeVariableField(variableField); + }); + marcRecord.getDataFields().add(index.get(), dataField); } } diff --git a/ramls/raml-storage b/ramls/raml-storage index 1e4076bf5..195de7f9f 160000 --- a/ramls/raml-storage +++ b/ramls/raml-storage @@ -1 +1 @@ -Subproject commit 1e4076bf5e4eae9670cd005adea7a174ccfaf681 +Subproject commit 195de7f9fd0f5ef76aac6542e11b0391a67e8af0