Search in sources :

Example 11 with OtherNames

use of org.orcid.jaxb.model.message.OtherNames in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method testDeactivateProfile.

@Test
@Transactional
@Rollback(true)
public void testDeactivateProfile() {
    OrcidProfile profile1 = createBasicProfile();
    profile1.getOrcidBio().getPersonalDetails().setCreditName(new CreditName("My Credit Name"));
    ExternalIdentifiers extIds = new ExternalIdentifiers();
    ExternalIdentifier extId = new ExternalIdentifier();
    extId.setExternalIdCommonName(new ExternalIdCommonName("External body"));
    extId.setExternalIdReference(new ExternalIdReference("abc123"));
    extIds.getExternalIdentifier().add(extId);
    profile1.getOrcidBio().setExternalIdentifiers(extIds);
    OtherNames otherNames = new OtherNames();
    otherNames.addOtherName("OtherName 1", null);
    otherNames.addOtherName("OtherName 2", null);
    profile1.getOrcidBio().getPersonalDetails().setOtherNames(otherNames);
    profile1 = orcidProfileManager.createOrcidProfile(profile1, false, false);
    assertEquals(1, profile1.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals(2, profile1.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().size());
    assertEquals("My Credit Name", profile1.getOrcidBio().getPersonalDetails().getCreditName().getContent());
    assertEquals(Visibility.PRIVATE, profile1.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().iterator().next().getVisibility());
    orcidProfileManager.deactivateOrcidProfile(profile1);
    OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile(profile1.getOrcidIdentifier().getPath());
    assertTrue(retrievedProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().isEmpty());
    assertNull(retrievedProfile.getOrcidBio().getPersonalDetails().getCreditName());
    assertEquals(0, retrievedProfile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().size());
    assertEquals("Given Names Deactivated", retrievedProfile.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
    assertEquals("Family Name Deactivated", retrievedProfile.getOrcidBio().getPersonalDetails().getFamilyName().getContent());
    assertNull(retrievedProfile.getOrcidBio().getBiography().getContent());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) OtherNames(org.orcid.jaxb.model.message.OtherNames) CreditName(org.orcid.jaxb.model.message.CreditName) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with OtherNames

use of org.orcid.jaxb.model.message.OtherNames 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)

Example 13 with OtherNames

use of org.orcid.jaxb.model.message.OtherNames in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method testUpdateProfileDefaultVisibilityForItemsAndUpdate.

@Test
@Transactional
@Rollback(true)
public void testUpdateProfileDefaultVisibilityForItemsAndUpdate() {
    OrcidProfile profile = createBasicProfile();
    Keyword k = new Keyword("word", null);
    Keywords kk = new Keywords();
    kk.getKeyword().add(k);
    ResearcherUrl r = new ResearcherUrl(new Url("http://whatever.com"), null);
    ResearcherUrls rr = new ResearcherUrls();
    rr.getResearcherUrl().add(r);
    ExternalIdentifier i = new ExternalIdentifier(null);
    i.setExternalIdReference(new ExternalIdReference("ref"));
    i.setExternalIdCommonName(new ExternalIdCommonName("cn"));
    ExternalIdentifiers ii = new ExternalIdentifiers();
    ii.getExternalIdentifier().add(i);
    OtherNames oo = new OtherNames();
    oo.addOtherName("other", null);
    profile.getOrcidBio().setKeywords(kk);
    profile.getOrcidBio().setResearcherUrls(rr);
    profile.getOrcidBio().setExternalIdentifiers(ii);
    profile.getOrcidBio().getPersonalDetails().setOtherNames(oo);
    profile = orcidProfileManager.createOrcidProfile(profile, true, false);
    assertEquals("word", profile.getOrcidBio().getKeywords().getKeyword().iterator().next().getContent());
    assertEquals(Visibility.PRIVATE, profile.getOrcidBio().getKeywords().getKeyword().iterator().next().getVisibility());
    assertEquals(new Url("http://whatever.com"), profile.getOrcidBio().getResearcherUrls().getResearcherUrl().iterator().next().getUrl());
    assertEquals(Visibility.PRIVATE, profile.getOrcidBio().getResearcherUrls().getResearcherUrl().iterator().next().getVisibility());
    assertEquals("cn", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().iterator().next().getExternalIdCommonName().getContent());
    assertEquals(Visibility.PRIVATE, profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().iterator().next().getVisibility());
    assertEquals("other", profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().iterator().next().getContent());
    assertEquals(Visibility.PRIVATE, profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().iterator().next().getVisibility());
    profile.getOrcidBio().getKeywords().setVisibility(Visibility.PUBLIC);
    profile.getOrcidBio().getKeywords().getKeyword().get(0).setContent("kk - updated");
    profile.getOrcidBio().getResearcherUrls().setVisibility(Visibility.PUBLIC);
    profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrl().setValue("http://whatever.com/updated");
    profile.getOrcidBio().getExternalIdentifiers().setVisibility(Visibility.PUBLIC);
    profile.getOrcidBio().getPersonalDetails().getOtherNames().setVisibility(Visibility.PUBLIC);
    profile = orcidProfileManager.updateOrcidProfile(profile);
    assertEquals("kk - updated", profile.getOrcidBio().getKeywords().getKeyword().iterator().next().getContent());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getKeywords().getKeyword().iterator().next().getVisibility());
    assertEquals(new Url("http://whatever.com/updated"), profile.getOrcidBio().getResearcherUrls().getResearcherUrl().iterator().next().getUrl());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getResearcherUrls().getResearcherUrl().iterator().next().getVisibility());
    assertEquals("cn", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().iterator().next().getExternalIdCommonName().getContent());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().iterator().next().getVisibility());
    assertEquals("other", profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().iterator().next().getContent());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().iterator().next().getVisibility());
    OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
    assertEquals(new Url("http://whatever.com/updated"), resultProfile.getOrcidBio().getResearcherUrls().getResearcherUrl().iterator().next().getUrl());
    assertEquals(Visibility.PUBLIC, resultProfile.getOrcidBio().getResearcherUrls().getResearcherUrl().iterator().next().getVisibility());
    assertEquals("cn", resultProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().iterator().next().getExternalIdCommonName().getContent());
    assertEquals(Visibility.PUBLIC, resultProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().iterator().next().getVisibility());
    assertEquals("other", resultProfile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().iterator().next().getContent());
    assertEquals(Visibility.PUBLIC, resultProfile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().iterator().next().getVisibility());
    Keyword kw = resultProfile.getOrcidBio().getKeywords().getKeyword().iterator().next();
    assertEquals("kk - updated", kw.getContent());
    assertEquals(Visibility.PUBLIC, kw.getVisibility());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Keywords(org.orcid.jaxb.model.message.Keywords) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) Keyword(org.orcid.jaxb.model.message.Keyword) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) OtherNames(org.orcid.jaxb.model.message.OtherNames) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with OtherNames

use of org.orcid.jaxb.model.message.OtherNames in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method testUpdatePersonalInformationRemovesOrcidIndexFields.

@Test
@Transactional
@Rollback(true)
public void testUpdatePersonalInformationRemovesOrcidIndexFields() throws Exception {
    // re-use the createFull method but add some extra criteria so we can
    // use our specific orcidAllSolrFieldsPopulatedForSave matcher
    OrcidProfile profile = createFullOrcidProfile();
    OtherNames otherNames = new OtherNames();
    otherNames.getOtherName().add(new OtherName("Stan", null));
    otherNames.getOtherName().add(new OtherName("Willis", null));
    profile.getOrcidBio().getPersonalDetails().setOtherNames(otherNames);
    OrcidWorks orcidWorks = new OrcidWorks();
    profile.setOrcidWorks(orcidWorks);
    WorkTitle singleWorkTitle = new WorkTitle();
    singleWorkTitle.setTitle(new Title("Single works"));
    singleWorkTitle.setSubtitle(new Subtitle("Single works"));
    OrcidWork orcidWork = createWork1(singleWorkTitle);
    // TODO JB some doi testing here?
    // orcidWork.getElectronicResourceNum().add(new
    // ElectronicResourceNum("10.1016/S0021-8502(00)90373-2",
    // ElectronicResourceNumType.DOI));
    orcidWorks.getOrcidWork().add(orcidWork);
    orcidProfileManager.createOrcidProfile(profile, false, false);
    // now negate all fields that form part of a solr query, leaving only
    // the orcid itself
    // we do this by passing through an orcid missing the fields from an
    // OrcidSolrDocument
    OrcidProfile negatedProfile = createBasicProfile();
    negatedProfile.getOrcidBio().getPersonalDetails().setFamilyName(null);
    negatedProfile.getOrcidBio().getPersonalDetails().setGivenNames(null);
    negatedProfile.getOrcidBio().getPersonalDetails().setCreditName(null);
    negatedProfile.getOrcidBio().getPersonalDetails().setOtherNames(null);
    negatedProfile.getOrcidActivities().setAffiliations(null);
    orcidProfileManager.updateOrcidBio(negatedProfile);
    assertEquals(IndexingStatus.PENDING, profileDao.find(TEST_ORCID).getIndexingStatus());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Subtitle(org.orcid.jaxb.model.message.Subtitle) OtherNames(org.orcid.jaxb.model.message.OtherNames) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OtherName(org.orcid.jaxb.model.message.OtherName) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with OtherNames

use of org.orcid.jaxb.model.message.OtherNames in project ORCID-Source by ORCID.

the class OrcidJaxbCopyManagerImpl method copyOtherNamesPreservingVisibility.

private void copyOtherNamesPreservingVisibility(PersonalDetails existingPersonalDetails, PersonalDetails updatedPersonalDetails) {
    OtherNames existingOtherNames = existingPersonalDetails.getOtherNames();
    OtherNames updatedOtherNames = updatedPersonalDetails.getOtherNames();
    // if no update, nothing to do
    if (updatedOtherNames == null) {
        return;
    }
    // otherwise take into account the visibility of updated and existing
    Visibility existingVisibility = existingOtherNames.getVisibility() != null ? existingOtherNames.getVisibility() : OrcidVisibilityDefaults.OTHER_NAMES_DEFAULT.getVisibility();
    updatedOtherNames.setVisibility(updatedOtherNames.getVisibility() != null ? updatedOtherNames.getVisibility() : existingVisibility);
    // now visibility has been preserved, overwrite the content
    existingPersonalDetails.setOtherNames(updatedOtherNames);
}
Also used : OtherNames(org.orcid.jaxb.model.message.OtherNames) Visibility(org.orcid.jaxb.model.message.Visibility)

Aggregations

OtherNames (org.orcid.jaxb.model.message.OtherNames)15 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)9 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)9 CreditName (org.orcid.jaxb.model.message.CreditName)8 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)8 Keywords (org.orcid.jaxb.model.message.Keywords)8 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)8 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)8 ResearcherUrls (org.orcid.jaxb.model.message.ResearcherUrls)8 GivenNames (org.orcid.jaxb.model.message.GivenNames)7 Keyword (org.orcid.jaxb.model.message.Keyword)7 ResearcherUrl (org.orcid.jaxb.model.message.ResearcherUrl)7 Test (org.junit.Test)6 ExternalIdCommonName (org.orcid.jaxb.model.message.ExternalIdCommonName)6 ExternalIdReference (org.orcid.jaxb.model.message.ExternalIdReference)6 FamilyName (org.orcid.jaxb.model.message.FamilyName)6 Url (org.orcid.jaxb.model.message.Url)6 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)6 WorkExternalIdentifiers (org.orcid.jaxb.model.message.WorkExternalIdentifiers)6 Address (org.orcid.jaxb.model.message.Address)5