use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class CosmotronHarvestJobTest method testDeletedRecord.
@Test
public void testDeletedRecord() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/cosmotron/DeletedRecord.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);
HarvestedRecord record = recordDao.findByIdAndHarvestConfiguration("CbvkUsCat" + Constants.COSMOTRON_RECORD_ID_CHAR + "0000003", 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 CosmotronHarvestJobTest method testNew996.
@Test
public void testNew996() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/cosmotron/New9961.xml");
InputStream response2 = this.getClass().getResourceAsStream("/sample/cosmotron/New9962.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=12345")).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);
Assert.assertNotNull(cosmotronDao.findByIdAndHarvestConfiguration("CbvkUsCat" + Constants.COSMOTRON_RECORD_ID_CHAR + "0000003", config));
Assert.assertNotNull(cosmotronDao.findByIdAndHarvestConfiguration("CbvkUsCat" + Constants.COSMOTRON_RECORD_ID_CHAR + "0000004", config));
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 KrameriusHarvesterNoSortingTest method harvesterNoServerResponse.
// Kramerius Harvester without sorting
@Test
public void harvesterNoServerResponse() throws Exception {
initHttpClientWithException();
initSolrServerWithException();
KrameriusHarvesterParams parameters = new KrameriusHarvesterParams();
parameters.setUrl("http://k4.techlib.cz/search/api/v5.0");
parameters.setMetadataStream("DC");
KrameriusHarvesterNoSorting harvester = new KrameriusHarvesterNoSorting(httpClient, solrServerFactory, parameters, 1L);
// 1st response with IOException => uuid list is empty
List<String> uuids = harvester.getUuids(null);
Assert.assertTrue(uuids.isEmpty());
// 2nd response with SolrServerException => uuid list is empty
uuids = harvester.getUuids(0);
Assert.assertTrue(uuids.isEmpty());
// 3rd response is => OK
uuids = harvester.getUuids(0);
Assert.assertFalse(uuids.isEmpty());
// 1st DC download - server responds with IOException, download returns null;
HarvestedRecord record = harvester.downloadRecord(uuids.get(0));
Assert.assertNull(record);
// 2nd DC download - OK
record = harvester.downloadRecord(uuids.get(1));
Assert.assertNotNull(record);
}
use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class KrameriusHarvesterNoSortingTest method downloadRecord.
// Kramerius Harvester with sorting
@Test
public void downloadRecord() throws Exception {
init();
KrameriusHarvesterParams parameters = new KrameriusHarvesterParams();
parameters.setUrl("http://k4.techlib.cz/search/api/v5.0");
parameters.setMetadataStream("DC");
KrameriusHarvesterNoSorting harvester = new KrameriusHarvesterNoSorting(httpClient, solrServerFactory, parameters, 1L);
List<String> uuids = harvester.getUuids(0);
for (String uuid : uuids) {
HarvestedRecord record = harvester.downloadRecord(uuid);
Assert.assertNotNull(record);
}
}
use of cz.mzk.recordmanager.server.model.HarvestedRecord in project RecordManager2 by moravianlibrary.
the class CosmotronUpdate996Writer method move996ToParentRecord.
private void move996ToParentRecord(HarvestedRecordUniqueId parentUniqueId) {
List<Cosmotron996> childRecs = cosmotronDao.findByParentId(parentUniqueId);
HarvestedRecord parentRec = hrDao.get(parentUniqueId);
// ignore deleted HarvestedRecord
if (parentRec.getDeleted() != null)
return;
updateMarc(parentRec, childRecs);
parentRec.setUpdated(new Date());
hrDao.persist(parentRec);
}
Aggregations