use of cz.mzk.recordmanager.server.dc.DublinCoreRecord in project RecordManager2 by moravianlibrary.
the class IdentifiersDublinCoreRecordFunctions method getISSNs.
public List<String> getISSNs(DublinCoreFunctionContext dcContext) {
List<String> issns = new ArrayList<String>();
DublinCoreRecord record = dcContext.record();
for (String ident : record.getIdentifiers()) {
Matcher matcher = ISSN_PATTERN.matcher(ident);
if (matcher.matches()) {
issns.add(matcher.group(1));
}
}
return issns;
}
use of cz.mzk.recordmanager.server.dc.DublinCoreRecord in project RecordManager2 by moravianlibrary.
the class MetadataRecordFactory method getMetadataRecord.
public MetadataRecord getMetadataRecord(HarvestedRecord record) {
if (record == null) {
return null;
}
ImportConfiguration configuration = record.getHarvestedFrom();
InputStream is = new ByteArrayInputStream(record.getRawRecord());
String recordFormat = record.getFormat();
if (Constants.METADATA_FORMAT_MARC21.equals(recordFormat) || Constants.METADATA_FORMAT_XML_MARC.equals(recordFormat) || Constants.METADATA_FORMAT_MARC_CPK.equals(recordFormat) || Constants.METADATA_FORMAT_OAI_MARCXML_CPK.equals(recordFormat) || Constants.METADATA_FORMAT_MARC21E.equals(recordFormat)) {
MarcRecord marcRec = marcXmlParser.parseRecord(is);
return getMetadataRecord(marcRec, configuration);
}
if (Constants.METADATA_FORMAT_DUBLIN_CORE.equals(recordFormat) || Constants.METADATA_FORMAT_ESE.equals(recordFormat)) {
DublinCoreRecord dcRec = dcParser.parseRecord(is);
return getMetadataRecord(record, dcRec, configuration);
}
return null;
}
use of cz.mzk.recordmanager.server.dc.DublinCoreRecord in project RecordManager2 by moravianlibrary.
the class ExportRecordsProcessor method process.
@Override
public String process(HarvestedRecordUniqueId recordId) throws Exception {
HarvestedRecord record = harvestedRecordDao.get(recordId);
try {
if (record != null && record.getRawRecord() != null && record.getRawRecord().length != 0) {
InputStream is = new ByteArrayInputStream(record.getRawRecord());
progressLogger.incrementAndLogProgress();
switch(record.getFormat()) {
case Constants.METADATA_FORMAT_MARC21:
MarcRecord marcRecord = marcXmlParser.parseRecord(is);
if (marcRecord.getDataFields(OAI_FIELD).isEmpty()) {
marcRecord.addDataField(OAI_FIELD, ' ', ' ', "a", record.getUniqueId().getRecordId());
}
return marcRecord.export(iOFormat);
case Constants.METADATA_FORMAT_DUBLIN_CORE:
case Constants.METADATA_FORMAT_ESE:
DublinCoreRecord dcRecord = dcParser.parseRecord(is);
return dcRecord.export(iOFormat);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of cz.mzk.recordmanager.server.dc.DublinCoreRecord in project RecordManager2 by moravianlibrary.
the class DublinCoreSolrRecordMapper method parseAsDedupRecord.
protected Map<String, Object> parseAsDedupRecord(HarvestedRecord record) {
InputStream is = new ByteArrayInputStream(record.getRawRecord());
MappingScript<DublinCoreFunctionContext> script = getMappingScript(record);
DublinCoreRecord rec = parser.parseRecord(is);
DublinCoreFunctionContext dcContext = new DublinCoreFunctionContext(rec, record, metadataRecordFactory.getMetadataRecord(record));
Map<String, Object> fields = script.parse(dcContext);
return fields;
}
use of cz.mzk.recordmanager.server.dc.DublinCoreRecord in project RecordManager2 by moravianlibrary.
the class DublinCoreSolrRecordMapper method parseAsLocalRecord.
protected Map<String, Object> parseAsLocalRecord(HarvestedRecord record) {
InputStream is = new ByteArrayInputStream(record.getRawRecord());
DublinCoreRecord rec = parser.parseRecord(is);
DublinCoreFunctionContext dcContext = new DublinCoreFunctionContext(rec, record, metadataRecordFactory.getMetadataRecord(record));
return harvestedRecordMappingScript.parse(dcContext);
}
Aggregations