Search in sources :

Example 1 with DublinCoreRecord

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;
}
Also used : DublinCoreRecord(cz.mzk.recordmanager.server.dc.DublinCoreRecord) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList)

Example 2 with DublinCoreRecord

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;
}
Also used : DublinCoreRecord(cz.mzk.recordmanager.server.dc.DublinCoreRecord) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MarcRecord(cz.mzk.recordmanager.server.marc.MarcRecord) ImportConfiguration(cz.mzk.recordmanager.server.model.ImportConfiguration)

Example 3 with DublinCoreRecord

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;
}
Also used : DublinCoreRecord(cz.mzk.recordmanager.server.dc.DublinCoreRecord) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MarcRecord(cz.mzk.recordmanager.server.marc.MarcRecord) HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord)

Example 4 with DublinCoreRecord

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;
}
Also used : DublinCoreRecord(cz.mzk.recordmanager.server.dc.DublinCoreRecord) DublinCoreFunctionContext(cz.mzk.recordmanager.server.scripting.dc.DublinCoreFunctionContext) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream)

Example 5 with DublinCoreRecord

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);
}
Also used : DublinCoreRecord(cz.mzk.recordmanager.server.dc.DublinCoreRecord) DublinCoreFunctionContext(cz.mzk.recordmanager.server.scripting.dc.DublinCoreFunctionContext) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream)

Aggregations

DublinCoreRecord (cz.mzk.recordmanager.server.dc.DublinCoreRecord)9 InputStream (java.io.InputStream)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 DublinCoreFunctionContext (cz.mzk.recordmanager.server.scripting.dc.DublinCoreFunctionContext)4 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)2 DublinCoreRecordImpl (cz.mzk.recordmanager.server.dc.DublinCoreRecordImpl)2 MarcRecord (cz.mzk.recordmanager.server.marc.MarcRecord)2 HarvestedRecord (cz.mzk.recordmanager.server.model.HarvestedRecord)2 ArrayList (java.util.ArrayList)2 Matcher (java.util.regex.Matcher)2 Test (org.testng.annotations.Test)2 InvalidDcException (cz.mzk.recordmanager.server.dc.InvalidDcException)1 MetadataDublinCoreRecord (cz.mzk.recordmanager.server.metadata.MetadataDublinCoreRecord)1 FulltextKramerius (cz.mzk.recordmanager.server.model.FulltextKramerius)1 ImportConfiguration (cz.mzk.recordmanager.server.model.ImportConfiguration)1