Search in sources :

Example 11 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) Date(java.util.Date) NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) DateUtils(org.orcid.utils.DateUtils) 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) OrcidSecurityManager(org.orcid.core.manager.OrcidSecurityManager) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) ProfileDao(org.orcid.persistence.dao.ProfileDao) Result(org.orcid.jaxb.model.search_v2.Result) Map(java.util.Map) RecordManagerReadOnly(org.orcid.core.manager.read_only.RecordManagerReadOnly) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidDeprecatedException(org.orcid.core.exception.OrcidDeprecatedException) 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) Jpa2JaxbAdapter(org.orcid.core.adapter.Jpa2JaxbAdapter) 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) DeactivatedException(org.orcid.core.exception.DeactivatedException) OrcidSearchManager(org.orcid.core.manager.OrcidSearchManager) OrcidSearchResults(org.orcid.jaxb.model.message.OrcidSearchResults) List(java.util.List) LockedException(org.orcid.core.security.aop.LockedException) 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) LastModifiedDate(org.orcid.jaxb.model.message.LastModifiedDate) 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)

Example 12 with OrcidSolrResults

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

the class OrcidSearchManagerImplTest method multipleResultsForQuery.

private OrcidSolrResults multipleResultsForQuery() {
    OrcidSolrResults orcidSolrResults = new OrcidSolrResults();
    List<OrcidSolrResult> resultsList = new ArrayList<>();
    orcidSolrResults.setResults(resultsList);
    resultsList.add(getOrcidSolrResult("5678", new Float(37.2)));
    resultsList.add(getOrcidSolrResult("6789", new Float(52.2)));
    orcidSolrResults.setNumFound(2);
    return orcidSolrResults;
}
Also used : OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) ArrayList(java.util.ArrayList) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults)

Example 13 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(mockSolrDao.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) List(java.util.List) ArrayList(java.util.ArrayList) FundingList(org.orcid.jaxb.model.message.FundingList) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 14 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) OrcidSearchManager(org.orcid.core.manager.v3.OrcidSearchManager) Arrays(java.util.Arrays) Date(java.util.Date) NonTransientDataAccessResourceException(org.springframework.dao.NonTransientDataAccessResourceException) DateUtils(org.orcid.utils.DateUtils) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults) OrcidSecurityManager(org.orcid.core.manager.OrcidSecurityManager) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) ProfileDao(org.orcid.persistence.dao.ProfileDao) Map(java.util.Map) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidDeprecatedException(org.orcid.core.exception.OrcidDeprecatedException) Result(org.orcid.jaxb.model.v3.dev1.search.Result) OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) Search(org.orcid.jaxb.model.v3.dev1.search.Search) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidSearchException(org.orcid.core.exception.OrcidSearchException) OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult) Jpa2JaxbAdapter(org.orcid.core.adapter.Jpa2JaxbAdapter) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) RecordManagerReadOnly(org.orcid.core.manager.v3.read_only.RecordManagerReadOnly) Resource(javax.annotation.Resource) FundingList(org.orcid.jaxb.model.message.FundingList) IOException(java.io.IOException) Reader(java.io.Reader) Collectors(java.util.stream.Collectors) DeactivatedException(org.orcid.core.exception.DeactivatedException) OrcidSearchResults(org.orcid.jaxb.model.message.OrcidSearchResults) List(java.util.List) LockedException(org.orcid.core.security.aop.LockedException) 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) LastModifiedDate(org.orcid.jaxb.model.message.LastModifiedDate) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Search(org.orcid.jaxb.model.v3.dev1.search.Search) OrcidSolrResults(org.orcid.utils.solr.entities.OrcidSolrResults) Result(org.orcid.jaxb.model.v3.dev1.search.Result) OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidSolrResult(org.orcid.utils.solr.entities.OrcidSolrResult)

Example 15 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)

Aggregations

OrcidSolrResults (org.orcid.utils.solr.entities.OrcidSolrResults)17 OrcidSolrResult (org.orcid.utils.solr.entities.OrcidSolrResult)15 ArrayList (java.util.ArrayList)10 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)6 OrcidSearchResult (org.orcid.jaxb.model.message.OrcidSearchResult)6 OrcidSearchResults (org.orcid.jaxb.model.message.OrcidSearchResults)6 List (java.util.List)5 Test (org.junit.Test)5 FundingList (org.orcid.jaxb.model.message.FundingList)4 OrcidSolrDocument (org.orcid.utils.solr.entities.OrcidSolrDocument)4 Map (java.util.Map)3 NonTransientDataAccessResourceException (org.springframework.dao.NonTransientDataAccessResourceException)3 BufferedReader (java.io.BufferedReader)2 IOException (java.io.IOException)2 Reader (java.io.Reader)2 Arrays (java.util.Arrays)2 Date (java.util.Date)2 Collectors (java.util.stream.Collectors)2 Resource (javax.annotation.Resource)2 BaseTest (org.orcid.core.BaseTest)2