use of org.orcid.jaxb.model.message.ExternalIdentifier in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testDefaultVisibilityForItemsAppliedOnUpdate.
@Test
@Transactional
@Rollback(true)
public void testDefaultVisibilityForItemsAppliedOnUpdate() {
OrcidProfile profile = createBasicProfile();
OrcidHistory orcidHistory = new OrcidHistory();
orcidHistory.setClaimed(new Claimed(true));
orcidHistory.setCreationMethod(CreationMethod.DIRECT);
orcidHistory.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile.setOrcidHistory(orcidHistory);
Keyword k = new Keyword("word", null);
Keywords kk = new Keywords();
kk.getKeyword().add(k);
kk.setVisibility(Visibility.LIMITED);
ResearcherUrl r = new ResearcherUrl(new Url("http://whatever.com"), null);
ResearcherUrls rr = new ResearcherUrls();
rr.getResearcherUrl().add(r);
rr.setVisibility(Visibility.LIMITED);
ExternalIdentifier i = new ExternalIdentifier(null);
i.setExternalIdReference(new ExternalIdReference("ref"));
i.setExternalIdCommonName(new ExternalIdCommonName("cn"));
ExternalIdentifiers ii = new ExternalIdentifiers();
ii.getExternalIdentifier().add(i);
ii.setVisibility(Visibility.LIMITED);
OtherNames oo = new OtherNames();
oo.addOtherName("other", null);
oo.setVisibility(Visibility.LIMITED);
profile.getOrcidBio().setKeywords(kk);
profile.getOrcidBio().setResearcherUrls(rr);
profile.getOrcidBio().setExternalIdentifiers(ii);
profile.getOrcidBio().getPersonalDetails().setOtherNames(oo);
//Create the profile
profile = orcidProfileManager.createOrcidProfile(profile, true, false);
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.getOrcidInternal().getPreferences().setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.LIMITED));
//Claim the profile
profile = orcidProfileManager.updateOrcidProfile(profile);
//now attempt to alter privacy. It should fail as record has been claimed.
profile.getOrcidBio().getKeywords().setVisibility(Visibility.PUBLIC);
profile.getOrcidBio().getResearcherUrls().setVisibility(Visibility.PUBLIC);
profile.getOrcidBio().getExternalIdentifiers().setVisibility(Visibility.PUBLIC);
profile.getOrcidBio().getPersonalDetails().getOtherNames().setVisibility(Visibility.PUBLIC);
profile = orcidProfileManager.updateOrcidProfile(profile);
assertEquals("word", profile.getOrcidBio().getKeywords().getKeyword().iterator().next().getContent());
assertEquals(Visibility.LIMITED, profile.getOrcidBio().getKeywords().getKeyword().iterator().next().getVisibility());
assertEquals(new Url("http://whatever.com"), profile.getOrcidBio().getResearcherUrls().getResearcherUrl().iterator().next().getUrl());
assertEquals(Visibility.LIMITED, profile.getOrcidBio().getResearcherUrls().getResearcherUrl().iterator().next().getVisibility());
assertEquals("cn", profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().iterator().next().getExternalIdCommonName().getContent());
assertEquals(Visibility.LIMITED, profile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().iterator().next().getVisibility());
assertEquals("other", profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().iterator().next().getContent());
assertEquals(Visibility.LIMITED, profile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().iterator().next().getVisibility());
}
use of org.orcid.jaxb.model.message.ExternalIdentifier 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());
}
use of org.orcid.jaxb.model.message.ExternalIdentifier 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);
}
use of org.orcid.jaxb.model.message.ExternalIdentifier in project ORCID-Source by ORCID.
the class OrcidMessageVersionConverterImplV1_2_rc4ToV1_2_rc5 method downgradeProfile.
private void downgradeProfile(OrcidProfile orcidProfile) {
if (orcidProfile != null) {
if (orcidProfile.getOrcidBio() != null)
if (orcidProfile.getOrcidBio().getExternalIdentifiers() != null)
for (ExternalIdentifier externalIdentifier : orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier()) {
externalIdentifier.setExternalIdOrcid(externalIdentifier.getExternalIdSource());
externalIdentifier.setExternalIdSource(null);
}
if (orcidProfile.getOrcidActivities() != null) {
if (orcidProfile.getOrcidActivities().getAffiliations() != null)
for (Activity act : orcidProfile.getOrcidActivities().getAffiliations().getAffiliation()) downGradeActivity(act);
if (orcidProfile.getOrcidActivities().getFundings() != null)
for (Activity act : orcidProfile.getOrcidActivities().getFundings().getFundings()) downGradeActivity(act);
if (orcidProfile.getOrcidActivities().getOrcidWorks() != null)
for (Activity act : orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork()) downGradeActivity(act);
}
if (orcidProfile.getOrcidInternal() != null) {
orcidProfile.getOrcidInternal().setSalesforceId(null);
}
}
}
use of org.orcid.jaxb.model.message.ExternalIdentifier in project ORCID-Source by ORCID.
the class OrcidMessageVersionConverterImplV1_2_rc4ToV1_2_rc5 method upgradeProfile.
private void upgradeProfile(OrcidProfile orcidProfile) {
if (orcidProfile != null) {
if (orcidProfile.getOrcidBio() != null)
if (orcidProfile.getOrcidBio().getExternalIdentifiers() != null)
for (ExternalIdentifier externalIdentifier : orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier()) {
externalIdentifier.setExternalIdSource(externalIdentifier.getExternalIdOrcid());
externalIdentifier.setExternalIdOrcid(null);
}
if (orcidProfile.getOrcidInternal() != null)
orcidProfile.getOrcidInternal().setSalesforceId(new SalesforceId());
}
}
Aggregations