Search in sources :

Example 36 with OrcidBio

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;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) GivenNames(org.orcid.jaxb.model.message.GivenNames) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Affiliation(org.orcid.jaxb.model.message.Affiliation)

Example 37 with OrcidBio

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());
}
Also used : OrcidSearchResult(org.orcid.jaxb.model.message.OrcidSearchResult) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Funding(org.orcid.jaxb.model.message.Funding) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 38 with OrcidBio

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());
}
Also used : OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 39 with OrcidBio

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());
}
Also used : OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 40 with OrcidBio

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;
}
Also used : Email(org.orcid.jaxb.model.message.Email) Keywords(org.orcid.jaxb.model.message.Keywords) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Address(org.orcid.jaxb.model.message.Address) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) Keyword(org.orcid.jaxb.model.message.Keyword) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) FamilyName(org.orcid.jaxb.model.message.FamilyName) OtherNames(org.orcid.jaxb.model.message.OtherNames) ArrayList(java.util.ArrayList) CreditName(org.orcid.jaxb.model.message.CreditName) UrlName(org.orcid.jaxb.model.message.UrlName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.pojo.GivenNames) Biography(org.orcid.jaxb.model.message.Biography) Country(org.orcid.jaxb.model.message.Country) Iso3166Country(org.orcid.jaxb.model.message.Iso3166Country) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers)

Aggregations

OrcidBio (org.orcid.jaxb.model.message.OrcidBio)56 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)38 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)28 Test (org.junit.Test)27 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)23 Email (org.orcid.jaxb.model.message.Email)20 GivenNames (org.orcid.jaxb.model.message.GivenNames)20 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)19 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)16 FamilyName (org.orcid.jaxb.model.message.FamilyName)16 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)15 CreditName (org.orcid.jaxb.model.message.CreditName)14 BaseTest (org.orcid.core.BaseTest)13 ExternalIdReference (org.orcid.jaxb.model.message.ExternalIdReference)11 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)11 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)10 ExternalIdCommonName (org.orcid.jaxb.model.message.ExternalIdCommonName)9 OtherNames (org.orcid.jaxb.model.message.OtherNames)9 Biography (org.orcid.jaxb.model.message.Biography)8 Keyword (org.orcid.jaxb.model.message.Keyword)8