Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODINV-1049 Existing "035" field is not retained the original position in imported record #636

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading