Skip to content

Commit

Permalink
MODINV-1049 Existing "035" field is not retained the original positio…
Browse files Browse the repository at this point in the history
…n in imported record
  • Loading branch information
JavokhirAbdullayev committed Jul 30, 2024
1 parent fb4dc58 commit b8da483
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -548,19 +548,16 @@ private static List<Subfield> 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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion ramls/raml-storage

0 comments on commit b8da483

Please sign in to comment.