Search in sources :

Example 11 with RecordImpl

use of cz.mzk.recordmanager.server.marc.marc4j.RecordImpl in project RecordManager2 by moravianlibrary.

the class CbvkMarcInterceptor method intercept.

@Override
public byte[] intercept() {
    if (super.getRecord() == null) {
        return new byte[0];
    }
    MarcRecord marc = new MarcRecordImpl(super.getRecord());
    Record newRecord = new RecordImpl();
    newRecord.setLeader(getRecord().getLeader());
    for (ControlField cf : super.getRecord().getControlFields()) {
        newRecord.addVariableField(cf);
    }
    Map<String, List<DataField>> dfMap = marc.getAllFields();
    for (String tag : new TreeSet<String>(dfMap.keySet())) {
        // sorted tags
        for (DataField df : dfMap.get(tag)) {
            // remove field 520
            if (df.getTag().equals("520"))
                continue;
            processField996(df);
            newRecord.addVariableField(df);
        }
    }
    return new MarcRecordImpl(newRecord).export(IOFormat.XML_MARC).getBytes(StandardCharsets.UTF_8);
}
Also used : MarcRecordImpl(cz.mzk.recordmanager.server.marc.MarcRecordImpl) ControlField(org.marc4j.marc.ControlField) DataField(org.marc4j.marc.DataField) TreeSet(java.util.TreeSet) MarcRecord(cz.mzk.recordmanager.server.marc.MarcRecord) Record(org.marc4j.marc.Record) MarcRecord(cz.mzk.recordmanager.server.marc.MarcRecord) List(java.util.List) MarcRecordImpl(cz.mzk.recordmanager.server.marc.MarcRecordImpl) RecordImpl(cz.mzk.recordmanager.server.marc.marc4j.RecordImpl)

Aggregations

MarcRecordImpl (cz.mzk.recordmanager.server.marc.MarcRecordImpl)11 RecordImpl (cz.mzk.recordmanager.server.marc.marc4j.RecordImpl)11 ControlField (org.marc4j.marc.ControlField)11 DataField (org.marc4j.marc.DataField)11 Record (org.marc4j.marc.Record)11 MarcRecord (cz.mzk.recordmanager.server.marc.MarcRecord)10 List (java.util.List)8 TreeSet (java.util.TreeSet)8 MarcFactoryImpl (cz.mzk.recordmanager.server.marc.marc4j.MarcFactoryImpl)6 MarcFactory (org.marc4j.marc.MarcFactory)6 Subfield (org.marc4j.marc.Subfield)3 HarvestedRecord (cz.mzk.recordmanager.server.model.HarvestedRecord)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Matcher (java.util.regex.Matcher)2 Pair (org.apache.commons.lang3.tuple.Pair)2 Cosmotron996 (cz.mzk.recordmanager.server.model.Cosmotron996)1 HarvestedRecordUniqueId (cz.mzk.recordmanager.server.model.HarvestedRecord.HarvestedRecordUniqueId)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 SimpleDateFormat (java.text.SimpleDateFormat)1