Search in sources :

Example 1 with DefaultMarcInterceptor

use of cz.mzk.recordmanager.server.marc.intercepting.DefaultMarcInterceptor in project RecordManager2 by moravianlibrary.

the class GenerateItemIdWriter method write.

@Override
public void write(List<? extends HarvestedRecordUniqueId> items) throws Exception {
    for (HarvestedRecordUniqueId uniqueId : items) {
        try {
            progress.incrementAndLogProgress();
            HarvestedRecord hr = hrDao.get(uniqueId);
            if (hr == null || hr.getRawRecord() == null || hr.getRawRecord().length == 0 || !hr.getFormat().equals("marc21-xml") || hr.getHarvestedFrom().getItemId() == null) {
                continue;
            }
            Record record = marcXmlParser.parseUnderlyingRecord(new ByteArrayInputStream(hr.getRawRecord()));
            hr.setRawRecord(new DefaultMarcInterceptor(record, hr.getHarvestedFrom(), uniqueId.getRecordId()).intercept());
        } catch (Exception ex) {
            logger.error(String.format("Exception thrown in harvested_record with id=%s", uniqueId), ex);
        }
    }
}
Also used : HarvestedRecordUniqueId(cz.mzk.recordmanager.server.model.HarvestedRecord.HarvestedRecordUniqueId) ByteArrayInputStream(java.io.ByteArrayInputStream) Record(org.marc4j.marc.Record) HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord) DefaultMarcInterceptor(cz.mzk.recordmanager.server.marc.intercepting.DefaultMarcInterceptor) HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord)

Aggregations

DefaultMarcInterceptor (cz.mzk.recordmanager.server.marc.intercepting.DefaultMarcInterceptor)1 HarvestedRecord (cz.mzk.recordmanager.server.model.HarvestedRecord)1 HarvestedRecordUniqueId (cz.mzk.recordmanager.server.model.HarvestedRecord.HarvestedRecordUniqueId)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Record (org.marc4j.marc.Record)1