use of cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext in project RecordManager2 by moravianlibrary.
the class MarcSolrRecordMapper method parseAsDedupRecord.
protected Map<String, Object> parseAsDedupRecord(HarvestedRecord record) {
InputStream is = new ByteArrayInputStream(record.getRawRecord());
MarcRecord rec = marcXmlParser.parseRecord(is);
MappingScript<MarcFunctionContext> script = getDedupMappingScript(record);
MarcFunctionContext ctx = new MarcFunctionContext(rec, record, metadataRecordFactory.getMetadataRecord(record));
Map<String, Object> result = script.parse(ctx);
return result;
}
use of cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext in project RecordManager2 by moravianlibrary.
the class MarcScriptFactoryTest method test1.
@Test
@SuppressWarnings("unchecked")
public void test1() {
MarcRecord record = parser.parseRecord(this.getClass().getResourceAsStream("/records/marcxml/MZK01-001439241.xml"));
InputStream is1 = getClass().getResourceAsStream("/groovy/ExtendedMarc.groovy");
InputStream is2 = getClass().getResourceAsStream("/groovy/BaseMarc.groovy");
MappingScript<MarcFunctionContext> script = factory.create(is1, is2);
MarcFunctionContext ctx = new MarcFunctionContext(record, metadataRecordFactory.getMetadataRecord(record));
Map<String, Object> entries = script.parse(ctx);
Assert.assertEquals(entries.get("author"), null);
Assert.assertEquals(entries.get("published"), "Rožnov pod Radhoštěm : Proxima Bohemia, 2014");
Assert.assertEquals(entries.get("title"), "Česká republika : města a obce České republiky : tradice, historie, památky, turistika, současnost /");
Assert.assertNotNull(entries.get("language"));
Assert.assertTrue(entries.get("language") instanceof List<?>);
List<String> languages = (List<String>) entries.get("language");
Assert.assertEquals(languages.size(), 1);
Assert.assertEquals(languages.get(0), "Czech");
}
use of cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext in project RecordManager2 by moravianlibrary.
the class BoundingBoxMarcFunctionsTest method testPrague.
@Test
public void testPrague() throws Exception {
List<String> data = new ArrayList<String>();
data.add("034 $aa $b20000 $dE0141016 $eE0144724 $fN0501302 $gN0495545");
MarcRecord record = MarcRecordFactory.recordFactory(data);
String result = functions.getBoundingBox(new MarcFunctionContext(record, null, null));
Assert.assertEquals(result, "14.171111111111111 49.92916666666667 14.79 50.217222222222226");
}
use of cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext in project RecordManager2 by moravianlibrary.
the class BoundingBoxMarcFunctionsTest method testInvalidRecord.
@Test
public void testInvalidRecord() throws Exception {
List<String> data = new ArrayList<String>();
data.add("034 $aa $dE0142526 $eE0142526 $fN0500516 $gN0500516");
MarcRecord record = MarcRecordFactory.recordFactory(data);
String result = functions.getBoundingBox(new MarcFunctionContext(record, null, null));
Assert.assertNull(result);
}
use of cz.mzk.recordmanager.server.scripting.marc.MarcFunctionContext in project RecordManager2 by moravianlibrary.
the class BoundingBoxMarcFunctionsTest method testCzechRepublic.
@Test
public void testCzechRepublic() throws Exception {
List<String> data = new ArrayList<String>();
data.add("034 $aa $b200000 $dE0115843 $eE0185426 $fN0510158 $gN0483256");
MarcRecord record = MarcRecordFactory.recordFactory(data);
String result = functions.getBoundingBoxAsPolygon(new MarcFunctionContext(record, null, null));
Assert.assertEquals(result, "POLYGON((11.979 48.549, 18.907 48.549, 18.907 51.033, 11.979 51.033, 11.979 48.549))");
}
Aggregations