Search in sources :

Example 1 with UrlName

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

the class OrcidProfileManagerImplTest method testUpdateOrcidBioKeepTheUserVisibility.

@Test
@Transactional
public void testUpdateOrcidBioKeepTheUserVisibility() {
    OrcidProfile profile = createBasicProfile();
    String orcidIdentifier = null;
    profile.setOrcidIdentifier(orcidIdentifier);
    setBio(profile, Visibility.LIMITED);
    OrcidHistory orcidHistory = new OrcidHistory();
    orcidHistory.setClaimed(new Claimed(true));
    orcidHistory.setCreationMethod(CreationMethod.DIRECT);
    orcidHistory.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    profile.setOrcidHistory(orcidHistory);
    Preferences preferences = new Preferences();
    preferences.setSendChangeNotifications(new SendChangeNotifications(true));
    preferences.setSendOrcidNews(new SendOrcidNews(true));
    //Default visibility for user will be LIMITED
    preferences.setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.LIMITED));
    preferences.setNotificationsEnabled(DefaultPreferences.NOTIFICATIONS_ENABLED);
    preferences.setSendEmailFrequencyDays(DefaultPreferences.SEND_EMAIL_FREQUENCY_DAYS);
    preferences.setSendMemberUpdateRequests(DefaultPreferences.SEND_MEMBER_UPDATE_REQUESTS);
    OrcidInternal internal = new OrcidInternal();
    internal.setPreferences(preferences);
    profile.setOrcidInternal(internal);
    profile = orcidProfileManager.createOrcidProfile(profile, true, false);
    //Update it setting it to PUBLIC and check
    profile = orcidProfileManager.retrieveOrcidProfile(profile.getOrcidIdentifier().getPath());
    assertNotNull(profile);
    assertNotNull(profile.getOrcidBio());
    OrcidBio bioToUpdate = profile.getOrcidBio();
    assertEquals(Visibility.LIMITED, bioToUpdate.getBiography().getVisibility());
    assertEquals("This is my biography", bioToUpdate.getBiography().getContent());
    assertEquals(Visibility.LIMITED, bioToUpdate.getContactDetails().getAddress().getCountry().getVisibility());
    assertEquals(Iso3166Country.US, bioToUpdate.getContactDetails().getAddress().getCountry().getValue());
    assertEquals(Visibility.LIMITED, bioToUpdate.getExternalIdentifiers().getVisibility());
    assertEquals(1, bioToUpdate.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals(Visibility.LIMITED, bioToUpdate.getKeywords().getVisibility());
    assertEquals(1, bioToUpdate.getKeywords().getKeyword().size());
    assertEquals(Visibility.LIMITED, bioToUpdate.getPersonalDetails().getOtherNames().getVisibility());
    assertEquals(1, bioToUpdate.getPersonalDetails().getOtherNames().getOtherName().size());
    assertEquals(Visibility.LIMITED, bioToUpdate.getResearcherUrls().getVisibility());
    assertEquals(1, bioToUpdate.getResearcherUrls().getResearcherUrl().size());
    //Update bio
    bioToUpdate.getBiography().setContent("Updated biography");
    bioToUpdate.getBiography().setVisibility(Visibility.PRIVATE);
    //Update address
    bioToUpdate.getContactDetails().getAddress().getCountry().setValue(Iso3166Country.CR);
    bioToUpdate.getContactDetails().getAddress().getCountry().setVisibility(Visibility.PRIVATE);
    //Update external identifiers
    ExternalIdentifier extId = new ExternalIdentifier();
    extId.setExternalIdCommonName(new ExternalIdCommonName("common-name-2"));
    extId.setExternalIdReference(new ExternalIdReference("ext-id-reference-2"));
    extId.setExternalIdUrl(new ExternalIdUrl("http://orcid.org/ext-id/2"));
    extId.setVisibility(Visibility.PRIVATE);
    bioToUpdate.getExternalIdentifiers().setVisibility(Visibility.PRIVATE);
    bioToUpdate.getExternalIdentifiers().getExternalIdentifier().add(extId);
    //Update keywords
    Keyword k = new Keyword();
    k.setContent("keyword-2");
    k.setVisibility(Visibility.PRIVATE);
    bioToUpdate.getKeywords().getKeyword().add(k);
    bioToUpdate.getKeywords().setVisibility(Visibility.PRIVATE);
    //Update researcher urls
    ResearcherUrl rUrl = new ResearcherUrl();
    rUrl.setUrl(new Url("http://orcid.org/researcher-url-2"));
    rUrl.setUrlName(new UrlName("url-name-2"));
    rUrl.setVisibility(Visibility.PRIVATE);
    bioToUpdate.getResearcherUrls().getResearcherUrl().add(rUrl);
    bioToUpdate.getResearcherUrls().setVisibility(Visibility.PRIVATE);
    //Update other names
    OtherName o = new OtherName();
    o.setContent("other-name-2");
    o.setVisibility(Visibility.PRIVATE);
    bioToUpdate.getPersonalDetails().getOtherNames().getOtherName().add(o);
    bioToUpdate.getPersonalDetails().getOtherNames().setVisibility(Visibility.PRIVATE);
    //Update the biography
    orcidProfileManager.updateOrcidBio(profile);
    //Get the record again and check that visibilities where not updated 
    OrcidProfile updatedProfile = orcidProfileManager.retrieveOrcidProfile(profile.getOrcidIdentifier().getPath());
    assertNotNull(updatedProfile);
    assertNotNull(updatedProfile.getOrcidBio());
    OrcidBio updatedBio = updatedProfile.getOrcidBio();
    assertEquals(Visibility.LIMITED, updatedBio.getBiography().getVisibility());
    assertEquals("Updated biography", updatedBio.getBiography().getContent());
    assertEquals(Visibility.LIMITED, updatedBio.getContactDetails().getAddress().getCountry().getVisibility());
    assertEquals(Iso3166Country.US, updatedBio.getContactDetails().getAddress().getCountry().getValue());
    assertEquals(Visibility.LIMITED, updatedBio.getExternalIdentifiers().getVisibility());
    assertEquals(2, updatedBio.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals(Visibility.LIMITED, updatedBio.getKeywords().getVisibility());
    assertEquals(2, updatedBio.getKeywords().getKeyword().size());
    assertEquals(Visibility.LIMITED, updatedBio.getPersonalDetails().getOtherNames().getVisibility());
    assertEquals(2, updatedBio.getPersonalDetails().getOtherNames().getOtherName().size());
    assertEquals(Visibility.LIMITED, updatedBio.getResearcherUrls().getVisibility());
    assertEquals(2, updatedBio.getResearcherUrls().getResearcherUrl().size());
}
Also used : SendOrcidNews(org.orcid.jaxb.model.message.SendOrcidNews) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) Keyword(org.orcid.jaxb.model.message.Keyword) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) OtherName(org.orcid.jaxb.model.message.OtherName) UrlName(org.orcid.jaxb.model.message.UrlName) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Claimed(org.orcid.jaxb.model.message.Claimed) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Date(java.util.Date) ApprovalDate(org.orcid.jaxb.model.message.ApprovalDate) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) Preferences(org.orcid.jaxb.model.message.Preferences) DefaultPreferences(org.orcid.core.constants.DefaultPreferences) SendChangeNotifications(org.orcid.jaxb.model.message.SendChangeNotifications) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with UrlName

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

the class OrcidProfileManagerImplTest method setBio.

private void setBio(OrcidProfile profile, Visibility defaultVisibility) {
    OrcidBio bio = new OrcidBio();
    Biography biography = new Biography("This is my biography");
    if (defaultVisibility != null) {
        biography.setVisibility(defaultVisibility);
    }
    bio.setBiography(biography);
    ContactDetails contactDetails = new ContactDetails();
    Address address = new Address();
    address.setCountry(new Country(Iso3166Country.US));
    if (defaultVisibility != null) {
        address.getCountry().setVisibility(defaultVisibility);
    }
    contactDetails.setAddress(address);
    List<Email> emails = new ArrayList<Email>();
    Email email = new Email();
    email.setPrimary(true);
    email.setValue(System.currentTimeMillis() + "@test.orcid.org");
    emails.add(email);
    contactDetails.setEmail(emails);
    bio.setContactDetails(contactDetails);
    ExternalIdentifiers extIds = new ExternalIdentifiers();
    ExternalIdentifier extId = new ExternalIdentifier();
    extId.setExternalIdCommonName(new ExternalIdCommonName("common-name"));
    extId.setExternalIdReference(new ExternalIdReference("ext-id-reference"));
    extId.setExternalIdUrl(new ExternalIdUrl("http://orcid.org/ext-id"));
    extIds.getExternalIdentifier().add(extId);
    if (defaultVisibility != null) {
        extIds.setVisibility(defaultVisibility);
    }
    bio.setExternalIdentifiers(extIds);
    Keywords keywords = new Keywords();
    Keyword keyword = new Keyword();
    keyword.setContent("k1");
    keywords.getKeyword().add(keyword);
    if (defaultVisibility != null) {
        keywords.setVisibility(defaultVisibility);
    }
    bio.setKeywords(keywords);
    PersonalDetails personalDetails = new PersonalDetails();
    personalDetails.setCreditName(new CreditName("credit-name"));
    personalDetails.setGivenNames(new GivenNames("given-names"));
    personalDetails.setFamilyName(new FamilyName("family-name"));
    OtherNames otherNames = new OtherNames();
    OtherName otherName = new OtherName();
    otherName.setContent("o1");
    otherNames.getOtherName().add(otherName);
    if (defaultVisibility != null) {
        otherNames.setVisibility(defaultVisibility);
    }
    personalDetails.setOtherNames(otherNames);
    bio.setPersonalDetails(personalDetails);
    ResearcherUrls researcherUrls = new ResearcherUrls();
    ResearcherUrl researcherUrl = new ResearcherUrl();
    researcherUrl.setUrl(new Url("http://orcid.org/researcher-url-1"));
    researcherUrl.setUrlName(new UrlName("url-name-1"));
    researcherUrls.getResearcherUrl().add(researcherUrl);
    if (defaultVisibility != null) {
        researcherUrls.setVisibility(defaultVisibility);
    }
    bio.setResearcherUrls(researcherUrls);
    profile.setOrcidBio(bio);
}
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) OrganizationAddress(org.orcid.jaxb.model.message.OrganizationAddress) FamilyName(org.orcid.jaxb.model.message.FamilyName) OtherNames(org.orcid.jaxb.model.message.OtherNames) ArrayList(java.util.ArrayList) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.jaxb.model.message.GivenNames) Biography(org.orcid.jaxb.model.message.Biography) 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) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) Keyword(org.orcid.jaxb.model.message.Keyword) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) CreditName(org.orcid.jaxb.model.message.CreditName) OtherName(org.orcid.jaxb.model.message.OtherName) UrlName(org.orcid.jaxb.model.message.UrlName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Country(org.orcid.jaxb.model.message.Country) Iso3166Country(org.orcid.jaxb.model.message.Iso3166Country)

Example 3 with UrlName

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

the class RDFWriterTest method fakeBio.

private OrcidMessage fakeBio() throws DatatypeConfigurationException {
    OrcidMessage orcidMessage = new OrcidMessage();
    OrcidProfile orcidProfile1 = new OrcidProfile();
    OrcidIdentifier orcidIdentifier = new OrcidIdentifier();
    orcidProfile1.setOrcidIdentifier(orcidIdentifier);
    orcidIdentifier.setUri("http://orcid.example.com/000-1337");
    orcidIdentifier.setPath("000-1337");
    OrcidBio bio = new OrcidBio();
    orcidProfile1.setOrcidBio(bio);
    OrcidHistory history = new OrcidHistory();
    XMLGregorianCalendar value = dataTypeFactory.newXMLGregorianCalendar(1980, 12, 31, 23, 29, 29, 999, 0);
    history.setCreationMethod(CreationMethod.WEBSITE);
    history.setLastModifiedDate(new LastModifiedDate(value));
    orcidProfile1.setOrcidHistory(history);
    PersonalDetails personal = new PersonalDetails();
    bio.setPersonalDetails(personal);
    personal.setFamilyName(new FamilyName("Doe"));
    personal.setCreditName(new CreditName("John F Doe"));
    personal.setGivenNames(new GivenNames("John"));
    personal.setOtherNames(new OtherNames());
    personal.getOtherNames().addOtherName("Johnny", Visibility.PUBLIC);
    personal.getOtherNames().addOtherName("Mr Doe", Visibility.PUBLIC);
    ResearcherUrls urls = new ResearcherUrls();
    bio.setResearcherUrls(urls);
    ResearcherUrl anonymous = new ResearcherUrl(new Url("http://example.com/anon"), Visibility.PUBLIC);
    urls.getResearcherUrl().add(anonymous);
    // "home page" - with strange casing
    ResearcherUrl homePage = new ResearcherUrl(new Url("http://example.com/myPage"), new UrlName("homePage"), Visibility.PUBLIC);
    urls.getResearcherUrl().add(homePage);
    ResearcherUrl foaf = new ResearcherUrl(new Url("http://example.com/foaf#me"), new UrlName("FOAF"), Visibility.PUBLIC);
    urls.getResearcherUrl().add(foaf);
    ResearcherUrl webId = new ResearcherUrl(new Url("http://example.com/webId"), new UrlName("webID"), Visibility.PUBLIC);
    urls.getResearcherUrl().add(webId);
    ResearcherUrl other = new ResearcherUrl(new Url("http://example.com/other"), new UrlName("other"), Visibility.PUBLIC);
    urls.getResearcherUrl().add(other);
    bio.setContactDetails(new ContactDetails());
    bio.getContactDetails().setEmail(Arrays.asList(new Email("john@example.org"), new Email("doe@example.com")));
    bio.getContactDetails().setAddress(new Address());
    bio.getContactDetails().getAddress().setCountry(new Country(Iso3166Country.GB));
    orcidMessage.setOrcidProfile(orcidProfile1);
    return orcidMessage;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.message.LastModifiedDate) Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) Address(org.orcid.jaxb.model.message.Address) FamilyName(org.orcid.jaxb.model.message.FamilyName) OtherNames(org.orcid.jaxb.model.message.OtherNames) 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) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) GivenNames(org.orcid.jaxb.model.message.GivenNames) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) ResearcherUrls(org.orcid.jaxb.model.message.ResearcherUrls) Iso3166Country(org.orcid.jaxb.model.message.Iso3166Country) Country(org.orcid.jaxb.model.message.Country) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl)

Example 4 with UrlName

use of org.orcid.jaxb.model.message.UrlName 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 5 with UrlName

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

the class OrcidProfileManagerImplTest method testPrimaryAddressDontChangeOnClaimedRecords.

@Test
@Transactional
@Rollback(true)
public void testPrimaryAddressDontChangeOnClaimedRecords() {
    OrcidProfile profile = createBasicProfile();
    String orcidIdentifier = null;
    profile.setOrcidIdentifier(orcidIdentifier);
    setBio(profile, Visibility.PUBLIC);
    String email = profile.getOrcidBio().getContactDetails().getEmail().get(0).getValue();
    profile = orcidProfileManager.createOrcidProfile(profile, true, false);
    assertNotNull(profile);
    assertNotNull(profile.getOrcidIdentifier());
    assertFalse(PojoUtil.isEmpty(profile.getOrcidIdentifier().getPath()));
    profile = orcidProfileManager.retrieveOrcidProfile(profile.getOrcidIdentifier().getPath());
    assertNotNull(profile);
    assertNotNull(profile.getOrcidBio());
    assertNotNull(profile.getOrcidBio().getBiography());
    assertEquals("This is my biography", profile.getOrcidBio().getBiography().getContent());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getBiography().getVisibility());
    assertNotNull(profile.getOrcidBio().getContactDetails());
    assertNotNull(profile.getOrcidBio().getContactDetails().getAddress());
    assertNotNull(profile.getOrcidBio().getContactDetails().getAddress().getCountry());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getContactDetails().getAddress().getCountry().getVisibility());
    assertEquals(Iso3166Country.US, profile.getOrcidBio().getContactDetails().getAddress().getCountry().getValue());
    assertNotNull(profile.getOrcidBio().getContactDetails().getEmail());
    assertEquals(1, profile.getOrcidBio().getContactDetails().getEmail().size());
    assertNotNull(profile.getOrcidBio().getContactDetails().getEmail().get(0).getValue());
    assertEquals(email, profile.getOrcidBio().getContactDetails().getEmail().get(0).getValue());
    assertNotNull(profile.getOrcidBio().getExternalIdentifiers());
    assertNotNull(profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getExternalIdentifiers().getVisibility());
    assertEquals(1, profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("common-name", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals("ext-id-reference", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdReference().getContent());
    assertEquals("http://orcid.org/ext-id", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdUrl().getValue());
    assertNotNull(profile.getOrcidBio().getKeywords());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getKeywords().getVisibility());
    assertEquals(1, profile.getOrcidBio().getKeywords().getKeyword().size());
    assertEquals("k1", profile.getOrcidBio().getKeywords().getKeyword().get(0).getContent());
    assertNotNull(profile.getOrcidBio().getPersonalDetails());
    assertNotNull(profile.getOrcidBio().getPersonalDetails().getOtherNames());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getPersonalDetails().getOtherNames().getVisibility());
    assertEquals(1, profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().size());
    assertEquals("o1", profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(0).getContent());
    assertNotNull(profile.getOrcidBio().getResearcherUrls());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getResearcherUrls().getVisibility());
    assertEquals(1, profile.getOrcidBio().getResearcherUrls().getResearcherUrl().size());
    assertEquals("http://orcid.org/researcher-url-1", profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrl().getValue());
    assertEquals("url-name-1", profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrlName().getContent());
    ProfileEntity profileEntity = profileDao.find(profile.getOrcidIdentifier().getPath());
    assertNotNull(profileEntity);
    assertNotNull(profileEntity.getAddresses());
    assertEquals(1, profileEntity.getAddresses().size());
    assertEquals(org.orcid.jaxb.model.common_v2.Iso3166Country.US, profileEntity.getAddresses().iterator().next().getIso2Country());
    //Update all values
    profile.getOrcidBio().getBiography().setContent("This is my biography # 2");
    profile.getOrcidBio().getContactDetails().getAddress().setCountry(new Country(Iso3166Country.CR));
    profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).setSource(null);
    profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).setExternalIdCommonName(new ExternalIdCommonName("common-name-2"));
    profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).setExternalIdReference(new ExternalIdReference("ext-id-reference-2"));
    profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).setExternalIdUrl(new ExternalIdUrl("http://orcid.org/ext-id-2"));
    profile.getOrcidBio().getKeywords().getKeyword().get(0).setSource(null);
    profile.getOrcidBio().getKeywords().getKeyword().get(0).setContent("k2");
    profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(0).setSource(null);
    profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(0).setContent("o2");
    profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).setSource(null);
    profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).setUrl(new Url("http://orcid.org/researcher-url-2"));
    profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).setUrlName(new UrlName("url-name-2"));
    orcidProfileManager.updateOrcidBio(profile);
    //Everything should be updated but the primary address that was already set
    profile = orcidProfileManager.retrieveOrcidProfile(profile.getOrcidIdentifier().getPath());
    assertNotNull(profile);
    assertNotNull(profile.getOrcidBio());
    assertNotNull(profile.getOrcidBio().getBiography());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getBiography().getVisibility());
    assertEquals("This is my biography # 2", profile.getOrcidBio().getBiography().getContent());
    assertNotNull(profile.getOrcidBio().getContactDetails());
    assertNotNull(profile.getOrcidBio().getContactDetails().getAddress());
    assertNotNull(profile.getOrcidBio().getContactDetails().getAddress().getCountry());
    assertNotNull(profile.getOrcidBio().getContactDetails().getEmail());
    assertEquals(1, profile.getOrcidBio().getContactDetails().getEmail().size());
    assertNotNull(profile.getOrcidBio().getContactDetails().getEmail().get(0).getValue());
    assertEquals(email, profile.getOrcidBio().getContactDetails().getEmail().get(0).getValue());
    assertNotNull(profile.getOrcidBio().getExternalIdentifiers());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getExternalIdentifiers().getVisibility());
    assertNotNull(profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("common-name-2", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals("ext-id-reference-2", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdReference().getContent());
    assertEquals("http://orcid.org/ext-id-2", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdUrl().getValue());
    assertNotNull(profile.getOrcidBio().getKeywords());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getKeywords().getVisibility());
    assertEquals(1, profile.getOrcidBio().getKeywords().getKeyword().size());
    assertEquals("k2", profile.getOrcidBio().getKeywords().getKeyword().get(0).getContent());
    assertNotNull(profile.getOrcidBio().getPersonalDetails());
    assertNotNull(profile.getOrcidBio().getPersonalDetails().getOtherNames());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getPersonalDetails().getOtherNames().getVisibility());
    assertEquals(1, profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().size());
    assertEquals("o2", profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(0).getContent());
    assertNotNull(profile.getOrcidBio().getResearcherUrls());
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getResearcherUrls().getVisibility());
    assertEquals(1, profile.getOrcidBio().getResearcherUrls().getResearcherUrl().size());
    assertEquals("http://orcid.org/researcher-url-2", profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrl().getValue());
    assertEquals("url-name-2", profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrlName().getContent());
    //Primary address should remain
    assertEquals(Iso3166Country.US, profile.getOrcidBio().getContactDetails().getAddress().getCountry().getValue());
    profileEntity = profileDao.find(profile.getOrcidIdentifier().getPath());
    assertNotNull(profileEntity);
    assertNotNull(profileEntity.getAddresses());
    assertEquals(2, profileEntity.getAddresses().size());
    Iterator<AddressEntity> it = profileEntity.getAddresses().iterator();
    while (it.hasNext()) {
        assertThat(it.next().getIso2Country(), anyOf(is(org.orcid.jaxb.model.common_v2.Iso3166Country.US), is(org.orcid.jaxb.model.common_v2.Iso3166Country.CR)));
    }
    //Claim the record
    OrcidHistory orcidHistory = new OrcidHistory();
    orcidHistory.setClaimed(new Claimed(true));
    orcidHistory.setCreationMethod(CreationMethod.DIRECT);
    orcidHistory.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    profile.setOrcidHistory(orcidHistory);
    Preferences preferences = new Preferences();
    preferences.setSendChangeNotifications(new SendChangeNotifications(true));
    preferences.setSendOrcidNews(new SendOrcidNews(true));
    //Default visibility for user will be LIMITED
    preferences.setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.LIMITED));
    preferences.setNotificationsEnabled(DefaultPreferences.NOTIFICATIONS_ENABLED);
    preferences.setSendEmailFrequencyDays(DefaultPreferences.SEND_EMAIL_FREQUENCY_DAYS);
    preferences.setSendMemberUpdateRequests(DefaultPreferences.SEND_MEMBER_UPDATE_REQUESTS);
    OrcidInternal internal = new OrcidInternal();
    internal.setPreferences(preferences);
    profile.setOrcidInternal(internal);
    orcidProfileManager.updateOrcidProfile(profile);
    //Everything should be updated but the address, because the record is claimed
    profile.getOrcidBio().getBiography().setContent("This is my biography # 3");
    profile.getOrcidBio().getContactDetails().getAddress().setCountry(new Country(Iso3166Country.PE));
    profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).setSource(null);
    profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).setExternalIdCommonName(new ExternalIdCommonName("common-name-3"));
    profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).setExternalIdReference(new ExternalIdReference("ext-id-reference-3"));
    profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).setExternalIdUrl(new ExternalIdUrl("http://orcid.org/ext-id-3"));
    profile.getOrcidBio().getKeywords().getKeyword().get(0).setSource(null);
    profile.getOrcidBio().getKeywords().getKeyword().get(0).setContent("k3");
    profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(0).setSource(null);
    profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(0).setContent("o3");
    profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).setSource(null);
    profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).setUrl(new Url("http://orcid.org/researcher-url-3"));
    profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).setUrlName(new UrlName("url-name-3"));
    orcidProfileManager.updateOrcidBio(profile);
    profile = orcidProfileManager.retrieveOrcidProfile(profile.getOrcidIdentifier().getPath());
    assertNotNull(profile);
    assertNotNull(profile.getOrcidBio());
    assertNotNull(profile.getOrcidBio().getBiography());
    assertEquals(Visibility.LIMITED, profile.getOrcidBio().getBiography().getVisibility());
    assertEquals("This is my biography # 3", profile.getOrcidBio().getBiography().getContent());
    assertNotNull(profile.getOrcidBio().getContactDetails());
    assertNotNull(profile.getOrcidBio().getContactDetails().getAddress());
    assertNotNull(profile.getOrcidBio().getContactDetails().getAddress().getCountry());
    assertNotNull(profile.getOrcidBio().getContactDetails().getEmail());
    assertEquals(1, profile.getOrcidBio().getContactDetails().getEmail().size());
    assertNotNull(profile.getOrcidBio().getContactDetails().getEmail().get(0).getValue());
    assertEquals(email, profile.getOrcidBio().getContactDetails().getEmail().get(0).getValue());
    assertNotNull(profile.getOrcidBio().getExternalIdentifiers());
    assertEquals(Visibility.LIMITED, profile.getOrcidBio().getExternalIdentifiers().getVisibility());
    assertNotNull(profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("common-name-3", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
    assertEquals("ext-id-reference-3", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdReference().getContent());
    assertEquals("http://orcid.org/ext-id-3", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdUrl().getValue());
    assertNotNull(profile.getOrcidBio().getKeywords());
    assertEquals(Visibility.LIMITED, profile.getOrcidBio().getKeywords().getVisibility());
    assertEquals(1, profile.getOrcidBio().getKeywords().getKeyword().size());
    assertEquals("k3", profile.getOrcidBio().getKeywords().getKeyword().get(0).getContent());
    assertNotNull(profile.getOrcidBio().getPersonalDetails());
    assertNotNull(profile.getOrcidBio().getPersonalDetails().getOtherNames());
    assertEquals(Visibility.LIMITED, profile.getOrcidBio().getPersonalDetails().getOtherNames().getVisibility());
    assertEquals(1, profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().size());
    assertEquals("o3", profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().get(0).getContent());
    assertNotNull(profile.getOrcidBio().getResearcherUrls());
    assertEquals(Visibility.LIMITED, profile.getOrcidBio().getResearcherUrls().getVisibility());
    assertEquals(1, profile.getOrcidBio().getResearcherUrls().getResearcherUrl().size());
    assertEquals("http://orcid.org/researcher-url-3", profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrl().getValue());
    assertEquals("url-name-3", profile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrlName().getContent());
    profileEntity = profileDao.find(profile.getOrcidIdentifier().getPath());
    assertNotNull(profileEntity);
    assertNotNull(profileEntity.getAddresses());
    assertEquals(3, profileEntity.getAddresses().size());
    it = profileEntity.getAddresses().iterator();
    while (it.hasNext()) {
        assertThat(it.next().getIso2Country(), anyOf(is(org.orcid.jaxb.model.common_v2.Iso3166Country.US), is(org.orcid.jaxb.model.common_v2.Iso3166Country.CR), is(org.orcid.jaxb.model.common_v2.Iso3166Country.PE)));
    }
    //Primary address should remain
    assertEquals(Visibility.PUBLIC, profile.getOrcidBio().getContactDetails().getAddress().getCountry().getVisibility());
    assertEquals(Iso3166Country.US, profile.getOrcidBio().getContactDetails().getAddress().getCountry().getValue());
}
Also used : SendOrcidNews(org.orcid.jaxb.model.message.SendOrcidNews) ExternalIdReference(org.orcid.jaxb.model.message.ExternalIdReference) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) UrlName(org.orcid.jaxb.model.message.UrlName) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) Claimed(org.orcid.jaxb.model.message.Claimed) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Date(java.util.Date) ApprovalDate(org.orcid.jaxb.model.message.ApprovalDate) ExternalIdUrl(org.orcid.jaxb.model.message.ExternalIdUrl) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ExternalIdCommonName(org.orcid.jaxb.model.message.ExternalIdCommonName) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) Country(org.orcid.jaxb.model.message.Country) Iso3166Country(org.orcid.jaxb.model.message.Iso3166Country) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Preferences(org.orcid.jaxb.model.message.Preferences) DefaultPreferences(org.orcid.core.constants.DefaultPreferences) SendChangeNotifications(org.orcid.jaxb.model.message.SendChangeNotifications) AddressEntity(org.orcid.persistence.jpa.entities.AddressEntity) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ResearcherUrl (org.orcid.jaxb.model.message.ResearcherUrl)5 Url (org.orcid.jaxb.model.message.Url)5 UrlName (org.orcid.jaxb.model.message.UrlName)5 Country (org.orcid.jaxb.model.message.Country)4 ExternalIdCommonName (org.orcid.jaxb.model.message.ExternalIdCommonName)4 ExternalIdReference (org.orcid.jaxb.model.message.ExternalIdReference)4 Iso3166Country (org.orcid.jaxb.model.message.Iso3166Country)4 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)4 Address (org.orcid.jaxb.model.message.Address)3 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)3 CreditName (org.orcid.jaxb.model.message.CreditName)3 Email (org.orcid.jaxb.model.message.Email)3 ExternalIdUrl (org.orcid.jaxb.model.message.ExternalIdUrl)3 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)3 FamilyName (org.orcid.jaxb.model.message.FamilyName)3 Keyword (org.orcid.jaxb.model.message.Keyword)3 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)3 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)3 OtherNames (org.orcid.jaxb.model.message.OtherNames)3 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)3