Search in sources :

Example 6 with Preferences

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

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

the class SourceInActivitiesTest method getMinimalOrcidProfile.

private OrcidProfile getMinimalOrcidProfile() {
    OrcidProfile profile = new OrcidProfile();
    OrcidBio bio = new OrcidBio();
    ContactDetails contactDetails = new ContactDetails();
    contactDetails.addOrReplacePrimaryEmail(new org.orcid.jaxb.model.message.Email(System.currentTimeMillis() + "@user.com"));
    Preferences preferences = new Preferences();
    preferences.setSendChangeNotifications(new SendChangeNotifications(true));
    preferences.setSendOrcidNews(new SendOrcidNews(true));
    preferences.setSendMemberUpdateRequests(true);
    preferences.setSendEmailFrequencyDays("1");
    preferences.setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.fromValue("public")));
    PersonalDetails personalDetails = new PersonalDetails();
    personalDetails.setFamilyName(new FamilyName("First"));
    personalDetails.setGivenNames(new GivenNames("Last"));
    bio.setContactDetails(contactDetails);
    bio.setPersonalDetails(personalDetails);
    OrcidInternal internal = new OrcidInternal();
    internal.setPreferences(preferences);
    profile.setOrcidBio(bio);
    profile.setOrcidInternal(internal);
    OrcidHistory orcidHistory = new OrcidHistory();
    orcidHistory.setClaimed(new Claimed(true));
    orcidHistory.setCreationMethod(CreationMethod.fromValue("integration-test"));
    profile.setOrcidHistory(orcidHistory);
    orcidHistory.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    profile.setPassword("password1");
    return orcidProfileManager.createOrcidProfile(profile, false, false);
}
Also used : SendOrcidNews(org.orcid.jaxb.model.message.SendOrcidNews) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Claimed(org.orcid.jaxb.model.message.Claimed) Date(java.util.Date) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) GivenNames(org.orcid.jaxb.model.message.GivenNames) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Preferences(org.orcid.jaxb.model.message.Preferences) SendChangeNotifications(org.orcid.jaxb.model.message.SendChangeNotifications)

Example 8 with Preferences

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

the class PreferencesForm method getOrcidProfile.

public OrcidProfile getOrcidProfile() {
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setOrcidIdentifier(orcid);
    OrcidInternal internal = new OrcidInternal();
    orcidProfile.setOrcidInternal(internal);
    Preferences preferences = new Preferences();
    internal.setPreferences(preferences);
    preferences.setSendChangeNotifications((sendChangeNotifications != null && !sendChangeNotifications.isEmpty()) ? new SendChangeNotifications(true) : null);
    preferences.setSendOrcidNews((sendOrcidNews != null && !sendOrcidNews.isEmpty()) ? new SendOrcidNews(true) : null);
    return orcidProfile;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) SendOrcidNews(org.orcid.jaxb.model.message.SendOrcidNews) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) Preferences(org.orcid.jaxb.model.message.Preferences) SendChangeNotifications(org.orcid.jaxb.model.message.SendChangeNotifications)

Example 9 with Preferences

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

the class SetUpClientsAndUsers method createUser.

private void createUser(Map<String, String> params) throws Exception {
    // Create it
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier(params.get(ORCID)));
    orcidProfile.setType(OrcidType.fromValue(params.get(ORCID_TYPE)));
    if (params.get(MEMBER_TYPE) != null) {
        orcidProfile.setGroupType(MemberType.fromValue(params.get(MEMBER_TYPE)));
    }
    orcidProfile.setPassword(params.get(PASSWORD));
    OrcidInternal internal = new OrcidInternal();
    Preferences preferences = new Preferences();
    ActivitiesVisibilityDefault visibilityDefaults = new ActivitiesVisibilityDefault();
    visibilityDefaults.setValue(Visibility.PUBLIC);
    preferences.setActivitiesVisibilityDefault(visibilityDefaults);
    internal.setPreferences(preferences);
    orcidProfile.setOrcidInternal(internal);
    Email email = new Email(params.get(EMAIL));
    email.setCurrent(true);
    email.setPrimary(true);
    email.setVerified(true);
    email.setVisibility(Visibility.PUBLIC);
    List<Email> emails = new ArrayList<Email>();
    emails.add(email);
    ContactDetails contactDetails = new ContactDetails();
    contactDetails.setEmail(emails);
    org.orcid.jaxb.model.message.PersonalDetails personalDetails = new org.orcid.jaxb.model.message.PersonalDetails();
    org.orcid.jaxb.model.message.CreditName creditName = new org.orcid.jaxb.model.message.CreditName(params.get(CREDIT_NAME));
    creditName.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility());
    personalDetails.setCreditName(creditName);
    personalDetails.setFamilyName(new org.orcid.jaxb.model.message.FamilyName(params.get(FAMILY_NAMES)));
    personalDetails.setGivenNames(new org.orcid.jaxb.model.message.GivenNames(params.get(GIVEN_NAMES)));
    OrcidBio bio = new OrcidBio();
    bio.setContactDetails(contactDetails);
    bio.setPersonalDetails(personalDetails);
    bio.setBiography(new Biography(params.get(BIO), OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility()));
    orcidProfile.setOrcidBio(bio);
    OrcidHistory history = new OrcidHistory();
    history.setClaimed(new Claimed(true));
    history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    history.setCreationMethod(CreationMethod.DIRECT);
    orcidProfile.setOrcidHistory(history);
    orcidProfileManager.createOrcidProfile(orcidProfile, false, false);
    if (params.containsKey(LOCKED)) {
        orcidProfileManager.lockProfile(params.get(ORCID), LockReason.SPAM.getLabel(), null);
    }
    if (params.containsKey(DEVELOPER_TOOLS)) {
        profileEntityManager.enableDeveloperTools(orcidProfile);
    }
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) ArrayList(java.util.ArrayList) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) Biography(org.orcid.jaxb.model.message.Biography) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Preferences(org.orcid.jaxb.model.message.Preferences) CreditName(org.orcid.jaxb.model.common_v2.CreditName) Claimed(org.orcid.jaxb.model.message.Claimed) Date(java.util.Date) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory)

Example 10 with Preferences

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

the class NotificationController method getDefaultPreference.

@RequestMapping(value = "/frequencies/{encryptedEmail}/email-frequencies.json", method = RequestMethod.GET)
@ResponseBody
public Preferences getDefaultPreference(HttpServletRequest request, HttpServletResponse response, @PathVariable("encryptedEmail") String encryptedEmail) throws UnsupportedEncodingException {
    String decryptedEmail = encryptionManager.decryptForExternalUse(new String(Base64.decodeBase64(encryptedEmail), "UTF-8"));
    OrcidProfile profile = orcidProfileManager.retrieveOrcidProfileByEmail(decryptedEmail);
    response.addHeader("X-Robots-Tag", "noindex");
    Preferences pref = profile.getOrcidInternal().getPreferences();
    return pref != null ? pref : new Preferences();
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Preferences(org.orcid.jaxb.model.message.Preferences) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Preferences (org.orcid.jaxb.model.message.Preferences)15 OrcidInternal (org.orcid.jaxb.model.message.OrcidInternal)10 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)10 ActivitiesVisibilityDefault (org.orcid.jaxb.model.message.ActivitiesVisibilityDefault)7 SendChangeNotifications (org.orcid.jaxb.model.message.SendChangeNotifications)6 SendOrcidNews (org.orcid.jaxb.model.message.SendOrcidNews)6 Date (java.util.Date)5 Test (org.junit.Test)5 DefaultPreferences (org.orcid.core.constants.DefaultPreferences)5 Claimed (org.orcid.jaxb.model.message.Claimed)5 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)5 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)5 SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)5 ResearcherUrl (org.orcid.jaxb.model.message.ResearcherUrl)4 Url (org.orcid.jaxb.model.message.Url)4 ApprovalDate (org.orcid.jaxb.model.message.ApprovalDate)3 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)3 ExternalIdCommonName (org.orcid.jaxb.model.message.ExternalIdCommonName)3 ExternalIdReference (org.orcid.jaxb.model.message.ExternalIdReference)3 ExternalIdUrl (org.orcid.jaxb.model.message.ExternalIdUrl)3