Search in sources :

Example 6 with OAIHarvestConfiguration

use of cz.mzk.recordmanager.server.model.OAIHarvestConfiguration in project RecordManager2 by moravianlibrary.

the class OAIItemProcessor method beforeStep.

@Override
public void beforeStep(StepExecution stepExecution) {
    try (SessionBinder session = sync.register()) {
        Long confId = stepExecution.getJobParameters().getLong("configurationId");
        OAIHarvestConfiguration hc = configDao.get(confId);
        if (hc != null) {
            format = formatResolver.resolve(hc.getMetadataPrefix());
            String regex = MoreObjects.firstNonNull(hc.getRegex(), DEFAULT_EXTRACT_ID_PATTERN);
            configuration = hc;
            idExtractor = new RegexpExtractor(regex);
        } else {
            DownloadImportConfiguration dic = downloadImportConfDao.get(confId);
            if (dic != null) {
                format = formatResolver.resolve(Constants.METADATA_FORMAT_XML_MARC);
                String regex = MoreObjects.firstNonNull(dic.getRegex(), DEFAULT_EXTRACT_ID_PATTERN);
                configuration = dic;
                idExtractor = new RegexpExtractor(regex);
            }
        }
        try {
            TransformerFactory transformerFactory = TransformerFactory.newInstance();
            transformer = transformerFactory.newTransformer();
        } catch (TransformerConfigurationException tce) {
            throw new RuntimeException(tce);
        }
    }
}
Also used : RegexpExtractor(cz.mzk.recordmanager.server.util.RegexpExtractor) OAIHarvestConfiguration(cz.mzk.recordmanager.server.model.OAIHarvestConfiguration) TransformerFactory(javax.xml.transform.TransformerFactory) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) SessionBinder(cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder) DownloadImportConfiguration(cz.mzk.recordmanager.server.model.DownloadImportConfiguration)

Example 7 with OAIHarvestConfiguration

use of cz.mzk.recordmanager.server.model.OAIHarvestConfiguration in project RecordManager2 by moravianlibrary.

the class OAIItemSingleReader method beforeStep.

@Override
public void beforeStep(final StepExecution stepExecution) {
    try (SessionBinder sess = hibernateSync.register()) {
        OAIHarvestConfiguration conf = configDao.get(confId);
        OAIHarvesterParams params = new OAIHarvesterParams();
        params.setUrl(conf.getUrl());
        params.setMetadataPrefix(conf.getMetadataPrefix());
        params.setGranularity(conf.getGranularity());
        params.setSet(conf.getSet());
        /*			params.setFrom(fromDate);
			params.setUntil(untilDate);
*/
        harvester = harvesterFactory.create(params);
        processIdentify(conf);
        conf = configDao.get(confId);
        params.setGranularity(conf.getGranularity());
        harvester = harvesterFactory.create(params);
    }
}
Also used : OAIHarvestConfiguration(cz.mzk.recordmanager.server.model.OAIHarvestConfiguration) SessionBinder(cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder)

Example 8 with OAIHarvestConfiguration

use of cz.mzk.recordmanager.server.model.OAIHarvestConfiguration in project RecordManager2 by moravianlibrary.

the class OAIItemReader method beforeStep.

@Override
public void beforeStep(final StepExecution stepExecution) {
    try (SessionBinder sess = hibernateSync.register()) {
        OAIHarvestConfiguration conf = configDao.get(confId);
        OAIHarvesterParams params = new OAIHarvesterParams();
        params.setUrl(conf.getUrl());
        params.setMetadataPrefix(conf.getMetadataPrefix());
        params.setGranularity(conf.getGranularity());
        params.setSet(conf.getSet());
        params.setFrom(fromDate);
        params.setUntil(untilDate);
        harvester = harvesterFactory.create(params);
        processIdentify(conf);
        conf = configDao.get(confId);
        params.setGranularity(conf.getGranularity());
        harvester = harvesterFactory.create(params);
    }
}
Also used : OAIHarvestConfiguration(cz.mzk.recordmanager.server.model.OAIHarvestConfiguration) SessionBinder(cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder)

Example 9 with OAIHarvestConfiguration

use of cz.mzk.recordmanager.server.model.OAIHarvestConfiguration in project RecordManager2 by moravianlibrary.

the class OAIOneByOneItemReader method beforeStep.

@Override
public void beforeStep(final StepExecution stepExecution) {
    try (SessionBinder sess = hibernateSync.register()) {
        OAIHarvestConfiguration conf = configDao.get(confId);
        OAIHarvesterParams params = new OAIHarvesterParams();
        params.setUrl(conf.getUrl());
        params.setMetadataPrefix(conf.getMetadataPrefix());
        params.setSet(conf.getSet());
        params.setGranularity(conf.getGranularity());
        params.setFrom(fromDate);
        params.setUntil(untilDate);
        harvester = harvesterFactory.create(params);
        processIdentify(conf);
        conf = configDao.get(confId);
        params.setGranularity(conf.getGranularity());
        harvester = harvesterFactory.create(params);
    }
}
Also used : OAIHarvestConfiguration(cz.mzk.recordmanager.server.model.OAIHarvestConfiguration) SessionBinder(cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder)

Example 10 with OAIHarvestConfiguration

use of cz.mzk.recordmanager.server.model.OAIHarvestConfiguration in project RecordManager2 by moravianlibrary.

the class ImportConfigurationDAOTest method persist.

@Test
public void persist() {
    OAIHarvestConfiguration importConf = new OAIHarvestConfiguration();
    importConf.setLibrary(libraryDao.get(100L));
    importConf.setContact(contactPersonDao.get(200L));
    importConf.setUrl("http://aleph.mzk.cz/OAI");
    importConf.setHarvestFrequency(HarvestFrequency.WEEKLY);
    importConfigurationDao.persist(importConf);
    ImportConfiguration importConfFromDB = importConfigurationDao.get(importConf.getId());
    Assert.assertNotNull(importConfFromDB);
    Assert.assertEquals(importConfFromDB.getHarvestFrequency(), HarvestFrequency.WEEKLY);
}
Also used : OAIHarvestConfiguration(cz.mzk.recordmanager.server.model.OAIHarvestConfiguration) ImportConfiguration(cz.mzk.recordmanager.server.model.ImportConfiguration) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Aggregations

OAIHarvestConfiguration (cz.mzk.recordmanager.server.model.OAIHarvestConfiguration)18 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)12 Test (org.testng.annotations.Test)12 InputStream (java.io.InputStream)9 HashMap (java.util.HashMap)9 JobExecution (org.springframework.batch.core.JobExecution)9 JobParameter (org.springframework.batch.core.JobParameter)9 JobParameters (org.springframework.batch.core.JobParameters)9 ByteArrayInputStream (java.io.ByteArrayInputStream)7 HarvestedRecord (cz.mzk.recordmanager.server.model.HarvestedRecord)6 SessionBinder (cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder)6 MarcRecord (cz.mzk.recordmanager.server.marc.MarcRecord)4 MarcRecordImpl (cz.mzk.recordmanager.server.marc.MarcRecordImpl)4 Record (org.marc4j.marc.Record)4 Cosmotron996 (cz.mzk.recordmanager.server.model.Cosmotron996)3 DownloadImportConfiguration (cz.mzk.recordmanager.server.model.DownloadImportConfiguration)2 RegexpExtractor (cz.mzk.recordmanager.server.util.RegexpExtractor)2 ImportConfiguration (cz.mzk.recordmanager.server.model.ImportConfiguration)1 KrameriusConfiguration (cz.mzk.recordmanager.server.model.KrameriusConfiguration)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1