Search in sources :

Example 1 with SessionBinder

use of cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder in project RecordManager2 by moravianlibrary.

the class AsyncOAIItemReader 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 2 with SessionBinder

use of cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder 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 3 with SessionBinder

use of cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder 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 4 with SessionBinder

use of cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder 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 5 with SessionBinder

use of cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder 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)

Aggregations

SessionBinder (cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder)11 OAIHarvestConfiguration (cz.mzk.recordmanager.server.model.OAIHarvestConfiguration)6 DownloadImportConfiguration (cz.mzk.recordmanager.server.model.DownloadImportConfiguration)2 RegexpExtractor (cz.mzk.recordmanager.server.util.RegexpExtractor)2 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)2 TransformerFactory (javax.xml.transform.TransformerFactory)2 KrameriusConfiguration (cz.mzk.recordmanager.server.model.KrameriusConfiguration)1