Search in sources :

Example 11 with NonTransientDataAccessResourceException

use of org.springframework.dao.NonTransientDataAccessResourceException in project ORCID-Source by ORCID.

the class FundingSubtypeSolrDaoImpl method persist.

@Override
public void persist(OrgDefinedFundingTypeSolrDocument fundingType) {
    try {
        solrServer.addBean(fundingType);
        solrServer.commit();
    } catch (SolrServerException se) {
        throw new NonTransientDataAccessResourceException("Error persisting funding type to SOLR Server", se);
    } catch (IOException ioe) {
        throw new NonTransientDataAccessResourceException("IOException when persisting funding type to SOLR", ioe);
    }
}
Also used : NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException)

Example 12 with NonTransientDataAccessResourceException

use of org.springframework.dao.NonTransientDataAccessResourceException in project ORCID-Source by ORCID.

the class SolrIndexUpdater method persist.

public void persist(OrcidSolrDocument orcidSolrDocument) {
    try {
        solrServer.addBean(orcidSolrDocument);
        solrServer.commit();
    } catch (SolrServerException se) {
        throw new NonTransientDataAccessResourceException("Error persisting to SOLR Server", se);
    } catch (IOException ioe) {
        throw new NonTransientDataAccessResourceException("IOException when persisting to SOLR", ioe);
    }
}
Also used : NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException)

Example 13 with NonTransientDataAccessResourceException

use of org.springframework.dao.NonTransientDataAccessResourceException in project ORCID-Source by ORCID.

the class OrgDisambiguatedSolrDaoImpl method persist.

@Override
public void persist(OrgDisambiguatedSolrDocument orgDisambiguatedSolrDocument) {
    try {
        solrServer.addBean(orgDisambiguatedSolrDocument);
        solrServer.commit();
    } catch (SolrServerException se) {
        throw new NonTransientDataAccessResourceException("Error persisting org to SOLR Server", se);
    } catch (IOException ioe) {
        throw new NonTransientDataAccessResourceException("IOException when persisting org to SOLR", ioe);
    }
}
Also used : NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException)

Example 14 with NonTransientDataAccessResourceException

use of org.springframework.dao.NonTransientDataAccessResourceException in project uPortal by Jasig.

the class HibernateDbLoader method process.

@Override
public void process(DbLoaderConfig configuration) throws ParserConfigurationException, SAXException, IOException {
    final String scriptFile = configuration.getScriptFile();
    final List<String> script;
    if (scriptFile == null) {
        script = null;
    } else {
        script = new LinkedList<String>();
    }
    final ITableDataProvider tableData = this.loadTables(configuration, dialect);
    //Handle table drop/create
    if (configuration.isDropTables() || configuration.isCreateTables()) {
        //Load Table object model
        final Map<String, Table> tables = tableData.getTables();
        final Mapping mapping = this.configuration.buildMapping();
        final String defaultCatalog = this.configuration.getProperty(Environment.DEFAULT_CATALOG);
        final String defaultSchema = this.configuration.getProperty(Environment.DEFAULT_SCHEMA);
        final Map<String, DataAccessException> failedSql = new LinkedHashMap<String, DataAccessException>();
        //Generate and execute drop table scripts
        if (configuration.isDropTables()) {
            final List<String> dropScript = this.dropScript(tables.values(), dialect, defaultCatalog, defaultSchema);
            if (script == null) {
                this.logger.info("Dropping existing tables");
                for (final String sql : dropScript) {
                    this.logger.info(sql);
                    try {
                        jdbcOperations.update(sql);
                    } catch (NonTransientDataAccessResourceException dae) {
                        throw dae;
                    } catch (DataAccessException dae) {
                        failedSql.put(sql, dae);
                    }
                }
            } else {
                script.addAll(dropScript);
            }
        }
        //Log any drop/create statements that failed
        for (final Map.Entry<String, DataAccessException> failedSqlEntry : failedSql.entrySet()) {
            this.logger.warn("'" + failedSqlEntry.getKey() + "' failed to execute due to " + failedSqlEntry.getValue());
        }
        //Generate and execute create table scripts
        if (configuration.isCreateTables()) {
            final List<String> createScript = this.createScript(tables.values(), dialect, mapping, defaultCatalog, defaultSchema);
            if (script == null) {
                this.logger.info("Creating tables");
                for (final String sql : createScript) {
                    this.logger.info(sql);
                    jdbcOperations.update(sql);
                }
            } else {
                script.addAll(createScript);
            }
        }
    }
    //Perform database population
    if (script == null && configuration.isPopulateTables()) {
        this.logger.info("Populating database");
        final Map<String, Map<String, Integer>> tableColumnTypes = tableData.getTableColumnTypes();
        this.populateTables(configuration, tableColumnTypes);
    }
    //Write out the script file
    if (script != null) {
        for (final ListIterator<String> iterator = script.listIterator(); iterator.hasNext(); ) {
            final String sql = iterator.next();
            iterator.set(sql + ";");
        }
        final File outputFile = new File(scriptFile);
        FileUtils.writeLines(outputFile, script);
        this.logger.info("Saved DDL to: " + outputFile.getAbsolutePath());
    }
}
Also used : Table(org.hibernate.mapping.Table) Mapping(org.hibernate.engine.spi.Mapping) LinkedHashMap(java.util.LinkedHashMap) NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) File(java.io.File) DataAccessException(org.springframework.dao.DataAccessException)

Aggregations

NonTransientDataAccessResourceException (org.springframework.dao.NonTransientDataAccessResourceException)14 SolrServerException (org.apache.solr.client.solrj.SolrServerException)12 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)7 IOException (java.io.IOException)6 SolrQuery (org.apache.solr.client.solrj.SolrQuery)6 SolrDocument (org.apache.solr.common.SolrDocument)4 OrcidSolrDocument (org.orcid.utils.solr.entities.OrcidSolrDocument)4 Date (java.util.Date)2 OrcidSolrResult (org.orcid.utils.solr.entities.OrcidSolrResult)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 SolrException (org.apache.solr.common.SolrException)1 Mapping (org.hibernate.engine.spi.Mapping)1