use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidSearchManagerImplTest method getOrcidProfile5678MandatoryOnly.
private OrcidProfile getOrcidProfile5678MandatoryOnly() {
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setOrcidIdentifier("5678");
OrcidBio orcidBio = new OrcidBio();
PersonalDetails personalDetails = new PersonalDetails();
personalDetails.setFamilyName(new FamilyName("Logan"));
personalDetails.setGivenNames(new GivenNames("Donald Edward"));
new Affiliation();
orcidBio.setPersonalDetails(personalDetails);
orcidProfile.setOrcidBio(orcidBio);
return orcidProfile;
}
use of org.orcid.jaxb.model.message.OrcidBio 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.OrcidBio in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testUpdatedResearcherUrlToExistingPreservingVisibility.
@Test
public void testUpdatedResearcherUrlToExistingPreservingVisibility() throws Exception {
OrcidBio existingOrcidBioProtected = protectedOrcidMessage.getOrcidProfile().getOrcidBio();
OrcidBio updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
ResearcherUrls existingResearcherUrls = existingOrcidBioProtected.getResearcherUrls();
assertEquals(Visibility.PUBLIC, existingResearcherUrls.getVisibility());
assertTrue(existingResearcherUrls.getResearcherUrl().size() == 3);
assertEquals("http://library.brown.edu/about/hay/carberry.php", existingResearcherUrls.getResearcherUrl().get(0).getUrl().getValue());
assertEquals("http://en.wikipedia.org/wiki/Josiah_S._Carberry", existingResearcherUrls.getResearcherUrl().get(1).getUrl().getValue());
assertEquals("http://www.brown.edu/Administration/News_Bureau/Databases/Encyclopedia/search.php?serial=C0070", existingResearcherUrls.getResearcherUrl().get(2).getUrl().getValue());
ResearcherUrls updatedResearcherUrls = new ResearcherUrls();
ResearcherUrl onlyUrl = new ResearcherUrl(new Url("http://library.brown.edu/about/hay/carberry.html"), null);
updatedResearcherUrls.getResearcherUrl().add(onlyUrl);
updatedResearcherUrls.setVisibility(Visibility.LIMITED);
updatedOrcidBioPublic.setResearcherUrls(updatedResearcherUrls);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
assertTrue(existingOrcidBioProtected.getResearcherUrls().getResearcherUrl().size() == 1);
assertEquals("http://library.brown.edu/about/hay/carberry.html", existingOrcidBioProtected.getResearcherUrls().getResearcherUrl().get(0).getUrl().getValue());
assertEquals(existingOrcidBioProtected.getResearcherUrls(), updatedOrcidBioPublic.getResearcherUrls());
assertEquals(Visibility.LIMITED, existingOrcidBioProtected.getResearcherUrls().getVisibility());
updatedResearcherUrls = new ResearcherUrls();
onlyUrl = new ResearcherUrl(new Url("http://library.brown.edu/about/hay/carberry.jsp"), null);
updatedResearcherUrls.getResearcherUrl().add(onlyUrl);
updatedResearcherUrls.setVisibility(null);
updatedOrcidBioPublic.setResearcherUrls(updatedResearcherUrls);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
assertTrue(existingOrcidBioProtected.getResearcherUrls().getResearcherUrl().size() == 1);
assertEquals("http://library.brown.edu/about/hay/carberry.jsp", existingOrcidBioProtected.getResearcherUrls().getResearcherUrl().get(0).getUrl().getValue());
assertEquals(existingOrcidBioProtected.getResearcherUrls(), updatedOrcidBioPublic.getResearcherUrls());
assertEquals(Visibility.LIMITED, existingOrcidBioProtected.getResearcherUrls().getVisibility());
}
use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testbiographyCopyDontFailOnEmpyVisibility.
@Test
public void testbiographyCopyDontFailOnEmpyVisibility() {
OrcidBio existing = getBio("bio1 ", Visibility.PUBLIC, 1);
existing.getBiography().setContent("Old biography");
existing.getBiography().setVisibility(null);
OrcidBio updated = getBio("bio1 ", Visibility.LIMITED, 1);
updated.getBiography().setContent("New biography");
updated.getBiography().setVisibility(null);
assertEquals("Old biography", existing.getBiography().getContent());
orcidJaxbCopyManager.copyUpdatedShortDescriptionToExistingPreservingVisibility(existing, updated);
assertEquals(OrcidVisibilityDefaults.SHORT_DESCRIPTION_DEFAULT.getVisibility(), updated.getBiography().getVisibility());
//It will not be updated if the visibility is null or PRIVATE
assertEquals("Old biography", existing.getBiography().getContent());
//Do it again but now set a visibility to the existing bio
existing.getBiography().setContent("Old biography");
existing.getBiography().setVisibility(Visibility.LIMITED);
updated.getBiography().setContent("New biography");
updated.getBiography().setVisibility(null);
orcidJaxbCopyManager.copyUpdatedShortDescriptionToExistingPreservingVisibility(existing, updated);
//The visibility will be the same
assertEquals(Visibility.LIMITED, updated.getBiography().getVisibility());
//And the content will change
assertEquals("New biography", existing.getBiography().getContent());
}
use of org.orcid.jaxb.model.message.OrcidBio in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method getBio.
private OrcidBio getBio(String sufix, Visibility visibility, int max) {
OrcidBio orcidBio = new OrcidBio();
Biography bio = new Biography(sufix + "My Biography", visibility);
orcidBio.setBiography(bio);
ContactDetails contactDetails = new ContactDetails();
Address address = new Address();
Country country = new Country(visibility.equals(Visibility.PRIVATE) ? Iso3166Country.US : Iso3166Country.CR);
country.setVisibility(visibility);
address.setCountry(country);
contactDetails.setAddress(address);
List<Email> emails = new ArrayList<Email>();
for (int i = 0; i < max; i++) {
Email email = new Email();
email.setValue(sufix + "Email" + i);
if (i == 0) {
email.setPrimary(true);
}
email.setVisibility(visibility);
emails.add(email);
}
contactDetails.setEmail(emails);
orcidBio.setContactDetails(contactDetails);
ExternalIdentifiers extIds = new ExternalIdentifiers();
extIds.setVisibility(visibility);
for (int i = 0; i < max; i++) {
ExternalIdentifier extId = new ExternalIdentifier();
extId.setExternalIdCommonName(new ExternalIdCommonName(sufix + "CommonName" + i));
extId.setExternalIdReference(new ExternalIdReference(sufix + "Reference" + i));
extIds.getExternalIdentifier().add(extId);
}
orcidBio.setExternalIdentifiers(extIds);
Keywords keywords = new Keywords();
keywords.setVisibility(visibility);
for (int i = 0; i < max; i++) {
Keyword k = new Keyword();
k.setContent(sufix + "Keyword" + i);
keywords.getKeyword().add(k);
}
orcidBio.setKeywords(keywords);
PersonalDetails personalDetails = new PersonalDetails();
CreditName creditName = new CreditName(sufix + "Credit name");
creditName.setVisibility(visibility);
personalDetails.setCreditName(creditName);
FamilyName familyName = new FamilyName(sufix + "Family");
personalDetails.setFamilyName(familyName);
GivenNames givenNames = new GivenNames();
givenNames.setContent(sufix + "Given");
personalDetails.setGivenNames(givenNames);
OtherNames other = new OtherNames();
other.setVisibility(visibility);
for (int i = 0; i < max; i++) {
other.addOtherName(sufix + "Other" + i, null);
}
personalDetails.setOtherNames(other);
orcidBio.setPersonalDetails(personalDetails);
ResearcherUrls researcherUrls = new ResearcherUrls();
researcherUrls.setVisibility(visibility);
for (int i = 0; i < max; i++) {
ResearcherUrl rUrl = new ResearcherUrl();
rUrl.setUrl(new Url("http://www.rurl.com/" + sufix + "/" + i));
rUrl.setUrlName(new UrlName(sufix + "Url" + i));
researcherUrls.getResearcherUrl().add(rUrl);
}
orcidBio.setResearcherUrls(researcherUrls);
return orcidBio;
}
Aggregations