use of cz.mzk.recordmanager.server.marc.MarcRecord in project RecordManager2 by moravianlibrary.
the class CosmotronHarvestJobTest method testHarvestRecords.
@Test
public void testHarvestRecords() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/ListRecords2.xml");
expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=ListRecords&metadataPrefix=marc21")).andReturn(response1);
replay(httpClient);
final Long confID = 300L;
Map<String, JobParameter> params = new HashMap<>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(confID));
JobExecution exec = jobExecutor.execute(Constants.JOB_ID_HARVEST_COSMOTRON, new JobParameters(params));
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
HarvestedRecord hr = recordDao.findByIdAndHarvestConfiguration("MZK01-000213478", confID);
Assert.assertNotNull(hr);
InputStream is = new ByteArrayInputStream(hr.getRawRecord());
Record record = marcXmlParser.parseUnderlyingRecord(is);
MarcRecord marcRecord = new MarcRecordImpl(record);
Assert.assertEquals(marcRecord.getDataFields("996").size(), 5);
}
use of cz.mzk.recordmanager.server.marc.MarcRecord in project RecordManager2 by moravianlibrary.
the class MarcScriptFactoryTest method test2.
@Test
public void test2() {
MarcRecord record = parser.parseRecord(this.getClass().getResourceAsStream("/records/marcxml/MZK01-000087310.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);
Collection<?> author2Roles = (Collection<?>) entries.get("author2_role");
Assert.assertTrue(author2Roles.isEmpty());
}
use of cz.mzk.recordmanager.server.marc.MarcRecord in project RecordManager2 by moravianlibrary.
the class BoundingBoxMarcFunctionsTest method testAustralia.
@Test
public void testAustralia() throws Exception {
List<String> data = new ArrayList<String>();
data.add("034 $aa $b6000000 $dE1023922 $eE1784848 $fN0023252 $gS0474141");
MarcRecord record = MarcRecordFactory.recordFactory(data);
String result = functions.getBoundingBox(new MarcFunctionContext(record, null, null));
Assert.assertEquals(result, "102.65611111111112 -47.69472222222222 178.81333333333333 2.5477777777777777");
}
use of cz.mzk.recordmanager.server.marc.MarcRecord in project RecordManager2 by moravianlibrary.
the class BoundingBoxMarcFunctionsTest method testSantiago.
@Test
public void testSantiago() throws Exception {
List<String> data = new ArrayList<String>();
data.add("034 $aa $b5100000 $dW0720810 $eW0475023 $fS0135757 $gS0345432");
MarcRecord record = MarcRecordFactory.recordFactory(data);
String result = functions.getBoundingBox(new MarcFunctionContext(record, null, null));
Assert.assertEquals(result, "-72.13611111111112 -34.90888888888889 -47.83972222222222 -13.965833333333332");
}
use of cz.mzk.recordmanager.server.marc.MarcRecord in project RecordManager2 by moravianlibrary.
the class CbvkMarcInterceptor method intercept.
@Override
public byte[] intercept() {
if (super.getRecord() == null) {
return new byte[0];
}
MarcRecord marc = new MarcRecordImpl(super.getRecord());
Record newRecord = new RecordImpl();
newRecord.setLeader(getRecord().getLeader());
for (ControlField cf : super.getRecord().getControlFields()) {
newRecord.addVariableField(cf);
}
Map<String, List<DataField>> dfMap = marc.getAllFields();
for (String tag : new TreeSet<String>(dfMap.keySet())) {
// sorted tags
for (DataField df : dfMap.get(tag)) {
// remove field 520
if (df.getTag().equals("520"))
continue;
processField996(df);
newRecord.addVariableField(df);
}
}
return new MarcRecordImpl(newRecord).export(IOFormat.XML_MARC).getBytes(StandardCharsets.UTF_8);
}
Aggregations