Search in sources :

Example 1 with MetadataDublinCoreRecord

use of cz.mzk.recordmanager.server.metadata.MetadataDublinCoreRecord in project RecordManager2 by moravianlibrary.

the class KrameriusFulltextProcessor method process.

@Override
public HarvestedRecord process(HarvestedRecord item) throws Exception {
    logger.debug("Processing Harvested Record: " + item.toString() + " uniqueId: " + item.getUniqueId());
    String policy;
    String model;
    // read complete HarvestedRecord using DAO
    HarvestedRecord rec = recordDao.findByIdAndHarvestConfiguration(item.getUniqueId().getRecordId(), confId);
    InputStream is = new ByteArrayInputStream(rec.getRawRecord());
    // get Kramerius policy from record
    try {
        DublinCoreRecord dcRecord = parser.parseRecord(is);
        MetadataDublinCoreRecord mdrc = new MetadataDublinCoreRecord(dcRecord);
        policy = mdrc.getPolicyKramerius();
        model = mdrc.getModelKramerius();
    } catch (InvalidDcException e) {
        logger.warn("InvalidDcException for record with id:" + item.getUniqueId());
        logger.warn(e.getMessage());
        // doesn't do anything, just returns rec from DAO and writes a message into log
        return rec;
    }
    // modify read HarvestedRecord only if following condition is fulfilled
    if (policy.equals("public") || downloadPrivateFulltexts) {
        logger.debug("Processor: privacy condition fulfilled, reading pages");
        String rootUuid = rec.getUniqueId().getRecordId();
        List<FulltextKramerius> pages;
        if (model.equals("periodical")) {
            logger.info("Using (periodical) fultexter \"for root\" for uuid " + rootUuid + ".");
            pages = fulltexter.getFulltextForRoot(rootUuid);
        } else {
            logger.info("Using (monograph/default) fultexter \"for parent\" for uuid " + rootUuid + ".");
            pages = fulltexter.getFulltextObjects(rootUuid);
        }
        // if we got empty list in pages => do nothing, return original record
        if (pages.isEmpty()) {
            return rec;
        }
        // delete old FulltextKramerius from database before adding new ones
        fmDao.deleteFulltext(rec.getId());
        rec.setFulltextKramerius(pages);
    } else {
        logger.debug("Processor: privacy condition is NOT fulfilled, skipping record");
    }
    return rec;
}
Also used : DublinCoreRecord(cz.mzk.recordmanager.server.dc.DublinCoreRecord) MetadataDublinCoreRecord(cz.mzk.recordmanager.server.metadata.MetadataDublinCoreRecord) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) InvalidDcException(cz.mzk.recordmanager.server.dc.InvalidDcException) FulltextKramerius(cz.mzk.recordmanager.server.model.FulltextKramerius) MetadataDublinCoreRecord(cz.mzk.recordmanager.server.metadata.MetadataDublinCoreRecord) HarvestedRecord(cz.mzk.recordmanager.server.model.HarvestedRecord)

Example 2 with MetadataDublinCoreRecord

use of cz.mzk.recordmanager.server.metadata.MetadataDublinCoreRecord in project RecordManager2 by moravianlibrary.

the class DublinCoreParserXMLImplTest method testDCRecordNuslNTK.

@Test
public void testDCRecordNuslNTK() {
    /* System.out.println("test NuslNTK - parser"); */
    /* file contains complete oai-pmh metadata structure */
    InputStream is = this.getClass().getResourceAsStream("/records/dublincore/NuslNTK-nusl2-oaipmh.xml");
    DublinCoreRecord dc = parser.parseRecord(is);
    Assert.assertNotNull(dc);
    // Kramerius specific data are not present
    MetadataDublinCoreRecord mdrc = new MetadataDublinCoreRecord(dc);
    Assert.assertTrue(mdrc.getModelKramerius().equals("unknown"));
}
Also used : MetadataDublinCoreRecord(cz.mzk.recordmanager.server.metadata.MetadataDublinCoreRecord) InputStream(java.io.InputStream) MetadataDublinCoreRecord(cz.mzk.recordmanager.server.metadata.MetadataDublinCoreRecord) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 3 with MetadataDublinCoreRecord

use of cz.mzk.recordmanager.server.metadata.MetadataDublinCoreRecord in project RecordManager2 by moravianlibrary.

the class DublinCoreParserXMLImplTest method testDCRecordK4NTK.

@Test
public void testDCRecordK4NTK() {
    InputStream is = this.getClass().getResourceAsStream("/records/dublincore/K4NTK-uuid-d3cf7ce9-1891-4e39-bb35-3b38b6eb0d60.xml");
    DublinCoreRecord dc = parser.parseRecord(is);
    Assert.assertNotNull(dc);
    // Kramerius specific tests
    MetadataDublinCoreRecord mdrc = new MetadataDublinCoreRecord(dc);
    Assert.assertTrue(mdrc.getPolicyKramerius().equals("public"));
    Assert.assertTrue(mdrc.getModelKramerius().equals("monograph"));
}
Also used : MetadataDublinCoreRecord(cz.mzk.recordmanager.server.metadata.MetadataDublinCoreRecord) InputStream(java.io.InputStream) MetadataDublinCoreRecord(cz.mzk.recordmanager.server.metadata.MetadataDublinCoreRecord) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Aggregations

MetadataDublinCoreRecord (cz.mzk.recordmanager.server.metadata.MetadataDublinCoreRecord)3 InputStream (java.io.InputStream)3 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)2 Test (org.testng.annotations.Test)2 DublinCoreRecord (cz.mzk.recordmanager.server.dc.DublinCoreRecord)1 InvalidDcException (cz.mzk.recordmanager.server.dc.InvalidDcException)1 FulltextKramerius (cz.mzk.recordmanager.server.model.FulltextKramerius)1 HarvestedRecord (cz.mzk.recordmanager.server.model.HarvestedRecord)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1