Search in sources :

Example 6 with OrcidSolrResults

use of org.orcid.utils.solr.entities.OrcidSolrResults in project ORCID-Source by ORCID.

the class OrcidSearchManagerImplTest method testFindOrcidIdsNoResults.

@Test
public void testFindOrcidIdsNoResults() {
    when(solrDao.findByDocumentCriteria(Matchers.<Map<String, List<String>>>any())).thenReturn(new OrcidSolrResults());
    Search search = orcidSearchManager.findOrcidIds(new HashMap<>());
    assertNotNull(search);
    assertEquals(Long.valueOf(0), search.getNumFound());
    assertEquals(0, search.getResults().size());
}
Also used : Search(org.orcid.jaxb.model.search_v2.Search) ArrayList(java.util.ArrayList) FundingList(org.orcid.jaxb.model.message.FundingList) List(java.util.List) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 7 with OrcidSolrResults

use of org.orcid.utils.solr.entities.OrcidSolrResults in project ORCID-Source by ORCID.

the class SolrDaoTest method queryStringSearchPatent.

@Test
public void queryStringSearchPatent() throws Exception {
    OrcidSolrDocument firstOrcid = buildAndPersistFirstOrcid();
    String patentQueryString = "patent-numbers:Elec-hammer01X%3A";
    OrcidSolrResults orcidSolrResults = solrDao.findByDocumentCriteria(patentQueryString, null, null);
    List<OrcidSolrResult> solrResultsList = orcidSolrResults.getResults();
    assertTrue(solrResultsList.size() == 1);
    assertEquals(firstOrcid.getOrcid(), solrResultsList.get(0).getOrcid());
}
Also used : OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults) Test(org.junit.Test)

Example 8 with OrcidSolrResults

use of org.orcid.utils.solr.entities.OrcidSolrResults in project ORCID-Source by ORCID.

the class OrcidSearchManagerImpl method findOrcidsByQuery.

@Override
public OrcidMessage findOrcidsByQuery(String query, Integer start, Integer rows) {
    OrcidMessage orcidMessage = new OrcidMessage();
    OrcidSearchResults searchResults = new OrcidSearchResults();
    OrcidSolrResults orcidSolrResults = solrDao.findByDocumentCriteria(query, start, rows);
    searchResults.setNumFound(orcidSolrResults.getNumFound());
    List<OrcidSolrResult> indexedOrcids = orcidSolrResults.getResults();
    if (indexedOrcids != null && !indexedOrcids.isEmpty()) {
        List<OrcidSearchResult> orcidSearchResults = buildSearchResultsFromPublicProfile(indexedOrcids);
        searchResults.getOrcidSearchResult().addAll(orcidSearchResults);
    }
    orcidMessage.setOrcidSearchResults(searchResults);
    return orcidMessage;
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidSearchResults(org.orcid.jaxb.model.message.OrcidSearchResults) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults)

Example 9 with OrcidSolrResults

use of org.orcid.utils.solr.entities.OrcidSolrResults in project ORCID-Source by ORCID.

the class OrcidSearchManagerImpl method findOrcidsByQuery.

@Override
public OrcidMessage findOrcidsByQuery(Map<String, List<String>> query) {
    OrcidMessage orcidMessage = new OrcidMessage();
    OrcidSearchResults searchResults = new OrcidSearchResults();
    OrcidSolrResults orcidSolrResults = solrDao.findByDocumentCriteria(query);
    searchResults.setNumFound(orcidSolrResults.getNumFound());
    List<OrcidSolrResult> indexedOrcids = orcidSolrResults.getResults();
    if (indexedOrcids != null && !indexedOrcids.isEmpty()) {
        List<OrcidSearchResult> orcidSearchResults = buildSearchResultsFromPublicProfile(indexedOrcids);
        searchResults.getOrcidSearchResult().addAll(orcidSearchResults);
    }
    orcidMessage.setOrcidSearchResults(searchResults);
    return orcidMessage;
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidSearchResults(org.orcid.jaxb.model.message.OrcidSearchResults) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults)

Example 10 with OrcidSolrResults

use of org.orcid.utils.solr.entities.OrcidSolrResults in project ORCID-Source by ORCID.

the class OrcidSearchManagerImpl method findOrcidIds.

@Override
public Search findOrcidIds(Map<String, List<String>> queryParameters) {
    Search search = new Search();
    OrcidSolrResults orcidSolrResults = solrDao.findByDocumentCriteria(queryParameters);
    if (orcidSolrResults != null && orcidSolrResults.getResults() != null) {
        List<Result> orcidIdList = orcidSolrResults.getResults().stream().map(r -> {
            Result result = new Result();
            result.setOrcidIdentifier(recordManagerReadOnly.getOrcidIdentifier(r.getOrcid()));
            return result;
        }).collect(Collectors.toList());
        search.getResults().addAll(orcidIdList);
        search.setNumFound(orcidSolrResults.getNumFound());
    } else {
        search.setNumFound(0L);
    }
    return search;
}
Also used : OrcidProfileCacheManager(org.orcid.core.manager.OrcidProfileCacheManager) Arrays(java.util.Arrays) NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) ArrayList(java.util.ArrayList) Search(org.orcid.jaxb.model.search_v2.Search) Value(org.springframework.beans.factory.annotation.Value) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults) Result(org.orcid.jaxb.model.search_v2.Result) Map(java.util.Map) RecordManagerReadOnly(org.orcid.core.manager.read_only.RecordManagerReadOnly) OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidSearchException(org.orcid.core.exception.OrcidSearchException) OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Resource(javax.annotation.Resource) FundingList(org.orcid.jaxb.model.message.FundingList) IOException(java.io.IOException) Reader(java.io.Reader) Collectors(java.util.stream.Collectors) OrcidSearchManager(org.orcid.core.manager.OrcidSearchManager) OrcidSearchResults(org.orcid.jaxb.model.message.OrcidSearchResults) List(java.util.List) Funding(org.orcid.jaxb.model.message.Funding) RelevancyScore(org.orcid.jaxb.model.message.RelevancyScore) BufferedReader(java.io.BufferedReader) SolrDao(org.orcid.persistence.dao.SolrDao) Required(org.springframework.beans.factory.annotation.Required) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Search(org.orcid.jaxb.model.search_v2.Search) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults) Result(org.orcid.jaxb.model.search_v2.Result) OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult)

Aggregations

OrcidSolrResults (org.orcid.utils.solr.entities.OrcidSolrResults)10 OrcidSolrResult (org.orcid.utils.solr.entities.OrcidSolrResult)9 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 OrcidSolrDocument (org.orcid.utils.solr.entities.OrcidSolrDocument)4 List (java.util.List)3 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)3 OrcidSearchResult (org.orcid.jaxb.model.message.OrcidSearchResult)3 OrcidSearchResults (org.orcid.jaxb.model.message.OrcidSearchResults)3 Map (java.util.Map)2 FundingList (org.orcid.jaxb.model.message.FundingList)2 Search (org.orcid.jaxb.model.search_v2.Search)2 NonTransientDataAccessResourceException (org.springframework.dao.NonTransientDataAccessResourceException)2 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 Arrays (java.util.Arrays)1 Collectors (java.util.stream.Collectors)1 Resource (javax.annotation.Resource)1 SolrQuery (org.apache.solr.client.solrj.SolrQuery)1