use of cz.mzk.recordmanager.server.model.AuthorityRecord in project RecordManager2 by moravianlibrary.
the class OAIAuthItemWriter method write.
protected void write(OAIRecord record) throws TransformerException {
String recordId = record.getHeader().getIdentifier();
AuthorityRecord authRec = recordDao.findByIdAndHarvestConfiguration(recordId, configuration);
if (authRec == null) {
authRec = new AuthorityRecord();
authRec.setOaiRecordId(record.getHeader().getIdentifier());
authRec.setHarvestedFrom(configuration);
authRec.setFormat(format);
}
if (record.getHeader().isDeleted()) {
authRec.setDeleted(new Date());
authRec.setRawRecord(new byte[0]);
recordDao.persist(authRec);
return;
} else {
Element element = record.getMetadata().getElement();
authRec.setRawRecord(asByteArray(element));
authRec.setAuthorityCode(getAuthorityCode(authRec.getRawRecord()));
}
recordDao.persist(authRec);
}
use of cz.mzk.recordmanager.server.model.AuthorityRecord in project RecordManager2 by moravianlibrary.
the class OAIHarvestAuthorityJobTest method testHarvestAuthorityRecords.
@Test
public void testHarvestAuthorityRecords() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/auth/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/auth/ListRecords1.xml");
expect(httpClient.executeGet("http://aleph.nkp.cz/OAI?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://aleph.nkp.cz/OAI?verb=ListRecords&metadataPrefix=marc21&set=AUTH")).andReturn(response1);
replay(httpClient);
final Long configId = oaiConfiguration.getId();
Map<String, JobParameter> params = new HashMap<String, JobParameter>();
params.put("configurationId", new JobParameter(configId));
JobParameters jobParams = new JobParameters(params);
JobExecution exec = jobExecutor.execute(Constants.JOB_ID_HARVEST_AUTH, jobParams);
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
AuthorityRecord authRec = authorityRecordDao.findByIdAndHarvestConfiguration("oai:aleph-nkp.cz:AUT10-000000001", oaiConfiguration);
Assert.assertNotNull(authRec);
Assert.assertEquals(authRec.getAuthorityCode(), "jk01010001");
authRec = authorityRecordDao.findByIdAndHarvestConfiguration("oai:aleph-nkp.cz:AUT10-000000006", oaiConfiguration);
Assert.assertEquals(authRec.getAuthorityCode(), "jk01010009");
Assert.assertNotNull(authRec);
authRec = authorityRecordDao.findByIdAndHarvestConfiguration("oai:aleph-nkp.cz:AUT10-000000007", oaiConfiguration);
Assert.assertEquals(authRec.getAuthorityCode(), "jk01010010");
Assert.assertNotNull(authRec);
}
Aggregations