use of cz.mzk.recordmanager.server.model.OAIHarvestConfiguration in project RecordManager2 by moravianlibrary.
the class ConfigurationTest method test.
@Test
public void test() {
OAIHarvestConfiguration oaiConf = oaiConfigDao.get(OAI_CONF_ID);
KrameriusConfiguration kramConf = kramConfigDao.get(KRAM_CONF_ID);
Assert.assertEquals(importConfigDao.get(OAI_CONF_ID), oaiConf);
Assert.assertEquals(importConfigDao.get(KRAM_CONF_ID), kramConf);
kramConfigDao.persist(kramConf);
Assert.assertNotNull(kramConfigDao.get(KRAM_CONF_ID));
}
use of cz.mzk.recordmanager.server.model.OAIHarvestConfiguration in project RecordManager2 by moravianlibrary.
the class OAIHarvestJobTest method testIdentify.
@Test
public void testIdentify() 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 configId = 300L;
Map<String, JobParameter> params = new HashMap<>();
params.put("configurationId", new JobParameter(configId));
JobParameters jobParams = new JobParameters(params);
JobExecution exec = jobExecutor.execute("oaiHarvestJob", jobParams);
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
final OAIHarvestConfiguration updatedOaiConfig = configDao.get(configId);
// is granularity correctly read from Identify?
Assert.assertEquals(updatedOaiConfig.getGranularity(), OAIGranularity.SECOND);
}
use of cz.mzk.recordmanager.server.model.OAIHarvestConfiguration in project RecordManager2 by moravianlibrary.
the class OAIHarvestJobTest method testDeleteRecord.
@Test
public void testDeleteRecord() 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, new JobParameters(params));
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
OAIHarvestConfiguration config = configDao.get(confID);
HarvestedRecord record = recordDao.findByIdAndHarvestConfiguration("111111", config);
Assert.assertNotNull(record, "Record not stored.");
Assert.assertNotNull(record.getDeleted());
}
use of cz.mzk.recordmanager.server.model.OAIHarvestConfiguration in project RecordManager2 by moravianlibrary.
the class ImportRecordsWriter method beforeStep.
@Override
public void beforeStep(StepExecution stepExecution) {
try (SessionBinder session = sync.register()) {
OAIHarvestConfiguration hc = oaiHarvestConfigurationDao.get(configurationId);
String regex = null;
if (hc != null) {
regex = hc.getRegex();
harvestConfiguration = hc;
} else {
DownloadImportConfiguration dic = downloadImportConfigurationDao.get(configurationId);
if (dic != null) {
regex = dic.getRegex();
harvestConfiguration = dic;
}
}
if (regex != null) {
regexpExtractor = new RegexpExtractor(regex);
}
}
}
use of cz.mzk.recordmanager.server.model.OAIHarvestConfiguration 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());
}
Aggregations