Search in sources :

Example 6 with Search

use of nl.knaw.huygens.timbuctoo.server.endpoints.v2.Search in project timbuctoo by HuygensING.

the class RelationSearchV2_1EndpointFixture method getPersonSearchId.

public String getPersonSearchId() {
    HttpRequest postRequest = new HttpRequest("POST", "/v2.1/search/wwpersons", "{}").withHeader("Content-type", "application/json").withHeader("VRE_ID", "WomenWriters");
    ActualResult response = executeRequestUsingJaxRs(postRequest);
    return response.getFirstHeader("Location").map(l -> l.replaceAll("http://[^/]+/", "")).map(l -> l.replaceAll(".*\\/", "")).orElse("");
}
Also used : HttpRequest(nl.knaw.huygens.concordion.extensions.HttpRequest) FullOGNL(org.concordion.api.FullOGNL) TimbuctooConfiguration(nl.knaw.huygens.timbuctoo.server.TimbuctooConfiguration) JsonBuilder.jsnO(nl.knaw.huygens.timbuctoo.util.JsonBuilder.jsnO) ArrayDiffResult(nl.knaw.huygens.contractdiff.jsondiff.ArrayDiffResult) MissingPropertyDiffResult(nl.knaw.huygens.contractdiff.diffresults.MissingPropertyDiffResult) RunWith(org.junit.runner.RunWith) JsonDiffer.jsonDiffer(nl.knaw.huygens.contractdiff.jsondiff.JsonDiffer.jsonDiffer) RelativeUrlWithoutLeadingSlash(nl.knaw.huygens.timbuctoo.server.endpoints.v2.matchers.RelativeUrlWithoutLeadingSlash) DropwizardMaker.makeTimbuctoo(nl.knaw.huygens.util.DropwizardMaker.makeTimbuctoo) StringUtils(org.apache.commons.lang3.StringUtils) ConcordionRunner(org.concordion.integration.junit4.ConcordionRunner) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ClientBuilder(javax.ws.rs.client.ClientBuilder) DropwizardAppRule(io.dropwizard.testing.junit.DropwizardAppRule) ActualResult(nl.knaw.huygens.concordion.extensions.ActualResult) HttpRequest(nl.knaw.huygens.concordion.extensions.HttpRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) JsonDiffer(nl.knaw.huygens.contractdiff.jsondiff.JsonDiffer) NumericDateWithoutDashes(nl.knaw.huygens.timbuctoo.server.endpoints.v2.matchers.NumericDateWithoutDashes) WebTarget(javax.ws.rs.client.WebTarget) ClassRule(org.junit.ClassRule) JsonBuilder.jsn(nl.knaw.huygens.timbuctoo.util.JsonBuilder.jsn) ActualResult(nl.knaw.huygens.concordion.extensions.ActualResult)

Example 7 with Search

use of nl.knaw.huygens.timbuctoo.server.endpoints.v2.Search in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_GeneralTest method testSearchByQuery.

@Test
public void testSearchByQuery() {
    Search search = new Search();
    Result result = new Result();
    result.setOrcidIdentifier(new OrcidIdentifier("some-orcid-id"));
    search.getResults().add(result);
    OrcidSearchManager orcidSearchManager = Mockito.mock(OrcidSearchManagerImpl.class);
    Mockito.when(orcidSearchManager.findOrcidIds(Matchers.<Map<String, List<String>>>any())).thenReturn(search);
    OrcidSecurityManager orcidSecurityManager = Mockito.mock(OrcidSecurityManagerImpl.class);
    Mockito.doNothing().when(orcidSecurityManager).checkScopes(Mockito.any(ScopePathType.class));
    MemberV2ApiServiceDelegatorImpl delegator = new MemberV2ApiServiceDelegatorImpl();
    ReflectionTestUtils.setField(delegator, "orcidSearchManager", orcidSearchManager);
    ReflectionTestUtils.setField(delegator, "orcidSecurityManager", orcidSecurityManager);
    Response response = delegator.searchByQuery(new HashMap<String, List<String>>());
    assertNotNull(response);
    assertNotNull(response.getEntity());
    assertTrue(response.getEntity() instanceof Search);
    assertEquals(1, ((Search) response.getEntity()).getResults().size());
    assertEquals("some-orcid-id", ((Search) response.getEntity()).getResults().get(0).getOrcidIdentifier().getPath());
}
Also used : Response(javax.ws.rs.core.Response) ScopePathType(org.orcid.jaxb.model.message.ScopePathType) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) Search(org.orcid.jaxb.model.search_v2.Search) MemberV2ApiServiceDelegatorImpl(org.orcid.api.memberV2.server.delegator.impl.MemberV2ApiServiceDelegatorImpl) OrcidSecurityManager(org.orcid.core.manager.OrcidSecurityManager) List(java.util.List) OrcidSearchManager(org.orcid.core.manager.OrcidSearchManager) Result(org.orcid.jaxb.model.search_v2.Result) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 8 with Search

use of nl.knaw.huygens.timbuctoo.server.endpoints.v2.Search 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 9 with Search

use of nl.knaw.huygens.timbuctoo.server.endpoints.v2.Search in project ORCID-Source by ORCID.

the class OrcidSearchManagerImplTest method testFindOrcidIds.

@Test
public void testFindOrcidIds() {
    when(mockSolrDao.findByDocumentCriteria(Matchers.<Map<String, List<String>>>any())).thenReturn(multipleResultsForQuery());
    Search search = orcidSearchManager.findOrcidIds(new HashMap<>());
    assertNotNull(search);
    assertEquals(2, search.getResults().size());
    assertEquals(Long.valueOf(2), search.getNumFound());
    assertEquals("5678", search.getResults().get(0).getOrcidIdentifier().getPath());
    assertEquals("6789", search.getResults().get(1).getOrcidIdentifier().getPath());
}
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) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 10 with Search

use of nl.knaw.huygens.timbuctoo.server.endpoints.v2.Search 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)

Aggregations

Search (org.orcid.jaxb.model.search_v2.Search)10 List (java.util.List)9 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 Response (javax.ws.rs.core.Response)5 Result (org.orcid.jaxb.model.search_v2.Result)5 DBUnitTest (org.orcid.test.DBUnitTest)5 OrcidSearchManager (org.orcid.core.manager.OrcidSearchManager)4 OrcidSecurityManager (org.orcid.core.manager.OrcidSecurityManager)4 OrcidIdentifier (org.orcid.jaxb.model.common_v2.OrcidIdentifier)4 FundingList (org.orcid.jaxb.model.message.FundingList)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 IOException (java.io.IOException)2 URI (java.net.URI)2 Map (java.util.Map)2 Vres (nl.knaw.huygens.timbuctoo.model.vre.Vres)2 Autocomplete (nl.knaw.huygens.timbuctoo.server.endpoints.v2.domain.Autocomplete)2 PublicV2ApiServiceDelegatorImpl (org.orcid.api.publicV2.server.delegator.impl.PublicV2ApiServiceDelegatorImpl)2 BaseTest (org.orcid.core.BaseTest)2