use of cz.mzk.recordmanager.server.marc.marc4j.MarcFactoryImpl in project RecordManager2 by moravianlibrary.
the class TdkivMarcInterceptor method intercept.
@Override
public byte[] intercept() {
if (super.getRecord() == null) {
return new byte[0];
}
Record newRecord = new RecordImpl();
MarcFactory marcFactory = new MarcFactoryImpl();
newRecord.addVariableField(marcFactory.newControlField("FMT", "VA"));
newRecord.addVariableField(marcFactory.newControlField("003", "CZ-PrNK"));
newRecord.addVariableField(marcFactory.newControlField("005", new SimpleDateFormat(DATE_STRING_005).format(new Date())));
newRecord.addVariableField(marcFactory.newControlField("008", "000804|n|anznnbabn-----------n-a|a------"));
newRecord.addVariableField(marcFactory.newDataField("040", ' ', ' ', "a", "ABA001", "b", "cze", "d", "ABA001"));
newRecord.setLeader(getRecord().getLeader());
for (ControlField cf : super.getRecord().getControlFields()) {
newRecord.addVariableField(cf);
}
for (DataField df : super.getRecord().getDataFields()) {
if (df.getTag().equals("DRL") && df.getSubfield('a') != null && newRecord.getControlNumberField() == null) {
Matcher matcher = RECORD_ID.matcher(df.getSubfield('a').getData());
if (matcher.find()) {
newRecord.addVariableField(marcFactory.newControlField("001", matcher.group(1)));
}
}
if (TAGS.containsKey(df.getTag())) {
df.setTag(TAGS.get(df.getTag()));
} else if (df.getTag().equals("ANG")) {
df.setTag("750");
df.setIndicator1('0');
df.setIndicator2('7');
} else if (df.getTag().equals("DRL")) {
df = marcFactory.newDataField("856", '4', '1', "u", df.getSubfield('a').getData(), "y", TEXT_856y);
} else
continue;
newRecord.addVariableField(df);
}
return new MarcRecordImpl(newRecord).export(IOFormat.XML_MARC).getBytes(StandardCharsets.UTF_8);
}
Aggregations