Search in sources :

Example 1 with RegexpExtractor

use of cz.mzk.recordmanager.server.util.RegexpExtractor 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 2 with RegexpExtractor

use of cz.mzk.recordmanager.server.util.RegexpExtractor 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);
        }
    }
}
Also used : RegexpExtractor(cz.mzk.recordmanager.server.util.RegexpExtractor) OAIHarvestConfiguration(cz.mzk.recordmanager.server.model.OAIHarvestConfiguration) SessionBinder(cz.mzk.recordmanager.server.util.HibernateSessionSynchronizer.SessionBinder) DownloadImportConfiguration(cz.mzk.recordmanager.server.model.DownloadImportConfiguration)

Aggregations

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