Search in sources :

Example 1 with DublinCoreFunctionContext

use of cz.mzk.recordmanager.server.scripting.dc.DublinCoreFunctionContext 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 2 with DublinCoreFunctionContext

use of cz.mzk.recordmanager.server.scripting.dc.DublinCoreFunctionContext 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)

Example 3 with DublinCoreFunctionContext

use of cz.mzk.recordmanager.server.scripting.dc.DublinCoreFunctionContext in project RecordManager2 by moravianlibrary.

the class IdentifiersDublinCoreRecordFunctionsTest method getISBNs.

@Test
public void getISBNs() {
    DublinCoreRecord record = new DublinCoreRecordImpl();
    record.addIdentifier("ISBN:0385424728");
    DublinCoreFunctionContext dcContext = new DublinCoreFunctionContext(record);
    List<String> isbns = functions.getISBNs(dcContext);
    Assert.assertFalse(isbns.isEmpty());
    Assert.assertEquals(isbns.get(0), "0385424728");
}
Also used : DublinCoreRecord(cz.mzk.recordmanager.server.dc.DublinCoreRecord) DublinCoreFunctionContext(cz.mzk.recordmanager.server.scripting.dc.DublinCoreFunctionContext) DublinCoreRecordImpl(cz.mzk.recordmanager.server.dc.DublinCoreRecordImpl) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Example 4 with DublinCoreFunctionContext

use of cz.mzk.recordmanager.server.scripting.dc.DublinCoreFunctionContext in project RecordManager2 by moravianlibrary.

the class DublinCoreScriptFactoryTest method test.

@Test
public void test() {
    InputStream is1 = getClass().getResourceAsStream("/groovy/BaseDublinCore.groovy");
    MappingScript<DublinCoreFunctionContext> script = factory.create(is1);
    DublinCoreRecord record = new DublinCoreRecordImpl();
    record.addTitle("test");
    DublinCoreFunctionContext dcContext = new DublinCoreFunctionContext(record);
    Map<String, Object> entries = script.parse(dcContext);
    Assert.assertEquals(entries.size(), 1);
    Assert.assertEquals(entries.get("title"), "test");
}
Also used : DublinCoreRecord(cz.mzk.recordmanager.server.dc.DublinCoreRecord) DublinCoreFunctionContext(cz.mzk.recordmanager.server.scripting.dc.DublinCoreFunctionContext) DublinCoreRecordImpl(cz.mzk.recordmanager.server.dc.DublinCoreRecordImpl) InputStream(java.io.InputStream) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Aggregations

DublinCoreRecord (cz.mzk.recordmanager.server.dc.DublinCoreRecord)4 DublinCoreFunctionContext (cz.mzk.recordmanager.server.scripting.dc.DublinCoreFunctionContext)4 InputStream (java.io.InputStream)3 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)2 DublinCoreRecordImpl (cz.mzk.recordmanager.server.dc.DublinCoreRecordImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Test (org.testng.annotations.Test)2