Search in sources :

Example 6 with NonTransientDataAccessResourceException

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

the class SolrDaoImpl method retrieveLastModified.

@Override
public Date retrieveLastModified(String orcid) {
    SolrQuery query = new SolrQuery();
    query.setQuery(ORCID + ":\"" + orcid + "\"");
    query.setFields(PROFILE_LAST_MODIFIED_DATE);
    try {
        QueryResponse response = solrServer.query(query);
        List<SolrDocument> results = response.getResults();
        if (results.isEmpty()) {
            return null;
        } else {
            return (Date) results.get(0).getFieldValue(PROFILE_LAST_MODIFIED_DATE);
        }
    } catch (SolrServerException e) {
        throw new NonTransientDataAccessResourceException("Error retrieving last modified date from SOLR Server", e);
    }
}
Also used : NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) SolrDocument(org.apache.solr.common.SolrDocument) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SolrServerException(org.apache.solr.client.solrj.SolrServerException) SolrQuery(org.apache.solr.client.solrj.SolrQuery) Date(java.util.Date)

Example 7 with NonTransientDataAccessResourceException

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

the class FundingSubtypeSolrDaoImpl method getFundingTypes.

@Override
public List<OrgDefinedFundingTypeSolrDocument> getFundingTypes(String searchTerm, int firstResult, int maxResult) {
    SolrQuery query = new SolrQuery();
    query.setQuery("{!edismax qf='org-defined-funding-type^50.0 text^1.0' pf='org-defined-funding-type^50.0' mm=1 sort='score desc'}" + searchTerm + "*").setFields("*");
    try {
        QueryResponse queryResponse = solrServerReadOnly.query(query);
        return queryResponse.getBeans(OrgDefinedFundingTypeSolrDocument.class);
    } catch (SolrServerException se) {
        String errorMessage = MessageFormat.format("Error when attempting to search for orgs, with search term {0}", new Object[] { searchTerm });
        throw new NonTransientDataAccessResourceException(errorMessage, se);
    }
}
Also used : NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) QueryResponse(org.apache.solr.client.solrj.response.QueryResponse) SolrServerException(org.apache.solr.client.solrj.SolrServerException) SolrQuery(org.apache.solr.client.solrj.SolrQuery)

Example 8 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 9 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 10 with NonTransientDataAccessResourceException

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

the class SolrDaoImpl method removeOrcids.

@Override
public void removeOrcids(List<String> orcids) {
    try {
        solrServer.deleteById(orcids);
        solrServer.commit();
    } catch (SolrServerException se) {
        throw new NonTransientDataAccessResourceException("Error deleting orcids from SOLR Server", se);
    } catch (IOException ioe) {
        throw new NonTransientDataAccessResourceException("Error deleting orcids from SOLR Server", ioe);
    }
}
Also used : NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) SolrServerException(org.apache.solr.client.solrj.SolrServerException) IOException(java.io.IOException)

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