use of org.orcid.jaxb.model.message.OrcidSearchResult in project ORCID-Source by ORCID.
the class RegistrationController method findPotentialDuplicatesByFirstNameLastName.
private List<OrcidProfile> findPotentialDuplicatesByFirstNameLastName(String firstName, String lastName) {
LOGGER.debug("About to search for potential duplicates during registration for first name={}, last name={}", firstName, lastName);
List<OrcidProfile> orcidProfiles = new ArrayList<OrcidProfile>();
SearchOrcidSolrCriteria queryForm = new SearchOrcidSolrCriteria();
queryForm.setGivenName(firstName);
queryForm.setFamilyName(lastName);
String query = queryForm.deriveQueryString();
OrcidMessage visibleProfiles = orcidSearchManager.findOrcidsByQuery(query, DUP_SEARCH_START, DUP_SEARCH_ROWS);
if (visibleProfiles.getOrcidSearchResults() != null) {
for (OrcidSearchResult searchResult : visibleProfiles.getOrcidSearchResults().getOrcidSearchResult()) {
orcidProfiles.add(searchResult.getOrcidProfile());
}
}
LOGGER.debug("Found {} potential duplicates during registration for first name={}, last name={}", new Object[] { orcidProfiles.size(), firstName, lastName });
return orcidProfiles;
}
use of org.orcid.jaxb.model.message.OrcidSearchResult in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method oneOrcidInDbOtherMissing.
@Test
@Rollback
public void oneOrcidInDbOtherMissing() {
when(solrDao.findByDocumentCriteria("rndQuery", null, null)).thenReturn(multipleResultsForQuery());
when(orcidProfileCacheManager.retrievePublicBio("5678")).thenReturn(getOrcidProfile5678MandatoryOnly());
when(orcidProfileCacheManager.retrievePublicBio("6789")).thenReturn(null);
OrcidMessage retrievedOrcidMessage = orcidSearchManager.findOrcidsByQuery("rndQuery");
assertNotNull(retrievedOrcidMessage);
assertTrue(retrievedOrcidMessage.getOrcidSearchResults() != null && retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().size() == 1);
OrcidSearchResult searchResult = retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0);
OrcidProfile profileReturnedFromSearch = searchResult.getOrcidProfile();
assertEquals("5678", profileReturnedFromSearch.getOrcidIdentifier().getPath());
}
use of org.orcid.jaxb.model.message.OrcidSearchResult in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method orcidRetrievalAllDataPresentInDb.
@Test
@Rollback
public void orcidRetrievalAllDataPresentInDb() throws Exception {
when(solrDao.findByOrcid("1434")).thenReturn(getSolrRes5678());
when(orcidProfileCacheManager.retrievePublicBio("5678")).thenReturn(getOrcidProfileAllIndexFieldsPopulated());
String orcid = "1434";
// demonstrate that the mapping from solr (profile 1234) and dao (5678)
// are truly seperate - the search results only return a subset of the
// full orcid
// because we want to keep the payload down.
OrcidMessage retrievedOrcidMessage = orcidSearchManager.findOrcidSearchResultsById(orcid);
assertNotNull(retrievedOrcidMessage);
assertTrue(retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().size() == 1);
OrcidSearchResult result = retrievedOrcidMessage.getOrcidSearchResults().getOrcidSearchResult().get(0);
assertTrue(new Float(37.2).compareTo(result.getRelevancyScore().getValue()) == 0);
OrcidProfile retrievedProfile = result.getOrcidProfile();
assertEquals("5678", retrievedProfile.getOrcidIdentifier().getPath());
OrcidBio orcidBio = retrievedProfile.getOrcidBio();
assertEquals("Logan", orcidBio.getPersonalDetails().getFamilyName().getContent());
assertEquals("Donald Edward", orcidBio.getPersonalDetails().getGivenNames().getContent());
assertEquals("Stanley Higgins", orcidBio.getPersonalDetails().getCreditName().getContent());
List<String> otherNames = orcidBio.getPersonalDetails().getOtherNames().getOtherNamesAsStrings();
assertTrue(otherNames.contains("Edward Bass"));
assertTrue(otherNames.contains("Gareth Dove"));
OrcidWorks orcidWorks = retrievedProfile.retrieveOrcidWorks();
OrcidWork orcidWork1 = orcidWorks.getOrcidWork().get(0);
OrcidWork orcidWork2 = orcidWorks.getOrcidWork().get(1);
assertTrue(orcidWork1.getWorkExternalIdentifiers().getWorkExternalIdentifier().size() == 1);
assertEquals("work1-doi1", orcidWork1.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierId().getContent());
assertTrue(orcidWork2.getWorkExternalIdentifiers().getWorkExternalIdentifier().size() == 2);
assertEquals("work2-doi1", orcidWork2.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierId().getContent());
assertEquals("work2-doi2", orcidWork2.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(1).getWorkExternalIdentifierId().getContent());
List<Funding> fundings = retrievedProfile.retrieveFundings().getFundings();
Funding funding1 = fundings.get(0);
Funding funding2 = fundings.get(1);
// check returns a reduced payload
assertNotNull(funding1.getTitle());
assertNotNull(funding1.getTitle().getTitle());
assertEquals("grant1", funding1.getTitle().getTitle().getContent());
assertEquals("Grant 1 - a short description", funding1.getDescription());
assertNull(funding1.getPutCode());
assertNotNull(funding2.getTitle());
assertNotNull(funding2.getTitle().getTitle());
assertEquals("grant2", funding2.getTitle().getTitle().getContent());
assertEquals("Grant 2 - a short description", funding2.getDescription());
assertNull(funding2.getPutCode());
}
use of org.orcid.jaxb.model.message.OrcidSearchResult in project ORCID-Source by ORCID.
the class OrcidSearchManagerImpl method findOrcidSearchResultsById.
@Override
public OrcidMessage findOrcidSearchResultsById(String orcid) {
OrcidMessage orcidMessage = new OrcidMessage();
OrcidSearchResults searchResults = new OrcidSearchResults();
OrcidSolrResult indexedOrcid = solrDao.findByOrcid(orcid);
if (indexedOrcid != null) {
List<OrcidSearchResult> orcidSearchResults = buildSearchResultsFromPublicProfile(Arrays.asList(indexedOrcid));
searchResults.getOrcidSearchResult().addAll(orcidSearchResults);
}
orcidMessage.setOrcidSearchResults(searchResults);
searchResults.setNumFound(1);
return orcidMessage;
}
use of org.orcid.jaxb.model.message.OrcidSearchResult 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;
}
Aggregations