use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class CosmotronHarvestJobTest method testCosmotronArticle.
@Test
public void testCosmotronArticle() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/cosmotron/Article.xml");
expect(httpClient.executeGet("http://katalog.cbvk.cz/i2/i2.ws.oai.cls?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://katalog.cbvk.cz/i2/i2.ws.oai.cls?verb=ListRecords&metadataPrefix=oai_marcxml_cpk")).andReturn(response1);
replay(httpClient);
final Long confID = 328L;
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);
OAIHarvestConfiguration config = configDao.get(confID);
HarvestedRecord hr = recordDao.findByIdAndHarvestConfiguration("LiUsCat_r011834", config);
Assert.assertNotNull(hr);
Assert.assertNull(hr.getDeleted());
}
use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class CosmotronHarvestJobTest method testCopy996ToParentRecord.
@Test
public void testCopy996ToParentRecord() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/cosmotron/RecordAnd996.xml");
InputStream response2 = this.getClass().getResourceAsStream("/sample/cosmotron/Deleted996.xml");
expect(httpClient.executeGet("http://katalog.cbvk.cz/i2/i2.ws.oai.cls?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://katalog.cbvk.cz/i2/i2.ws.oai.cls?verb=ListRecords&metadataPrefix=oai_marcxml_cpk")).andReturn(response1);
expect(httpClient.executeGet("http://katalog.cbvk.cz/i2/i2.ws.oai.cls?verb=ListRecords&resumptionToken=123456")).andReturn(response2);
replay(httpClient);
final Long confID = 328L;
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);
OAIHarvestConfiguration config = configDao.get(confID);
HarvestedRecord hr = recordDao.findByIdAndHarvestConfiguration("CbvkUsCat" + Constants.COSMOTRON_RECORD_ID_CHAR + "m0000002", config);
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(), 2);
}
use of cz.mzk.recordmanager.server.model.HarvestedRecord 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.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class CosmotronHarvestJobTest method testDeletedExistsRecord.
@Test
public void testDeletedExistsRecord() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/IdentifyNonstandardGranularity.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/ListRecordsNLKdeleted1.xml");
InputStream response2 = this.getClass().getResourceAsStream("/sample/ListRecordsNLKdeleted2.xml");
expect(httpClient.executeGet("http://oai.medvik.cz/medvik2cpk/oai?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://oai.medvik.cz/medvik2cpk/oai?verb=ListRecords&metadataPrefix=marc21")).andReturn(response1);
expect(httpClient.executeGet("http://oai.medvik.cz/medvik2cpk/oai?verb=ListRecords&resumptionToken=xaiutmvy00003")).andReturn(response2);
replay(httpClient);
final Long confID = 301L;
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 record = recordDao.findByIdAndHarvestConfiguration("111111", confID);
Assert.assertNotNull(record, "Record not stored.");
Assert.assertNotNull(record.getDeleted());
}
use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class KrameriusHarvesterNoSorting method downloadRecord.
public HarvestedRecord downloadRecord(String uuid) {
String recordId;
HarvestedRecordUniqueId id;
HarvestedRecord unparsedHr;
recordId = uuid;
id = new HarvestedRecordUniqueId(harvestedFrom, recordId);
unparsedHr = new HarvestedRecord(id);
String url = createUrl(uuid);
logger.info("Harvesting record from: " + url);
try (InputStream is = httpClient.executeGet(url)) {
if (is.markSupported()) {
is.mark(Integer.MAX_VALUE);
is.reset();
}
unparsedHr.setRawRecord(IOUtils.toByteArray(is));
} catch (IOException ioe) {
logger.error("Harvesting record from: " + url + " caused IOException!");
logger.error(ioe.getMessage());
return null;
}
// yet)
return unparsedHr;
}
Aggregations