Search in sources :

Example 11 with Preferences

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

Example 12 with Preferences

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

the class OrcidProfileManagerBaseTest method createBasicProfile.

protected OrcidProfile createBasicProfile() {
    OrcidProfile profile = new OrcidProfile();
    profile.setPassword("password");
    profile.setVerificationCode("1234");
    profile.setSecurityQuestionAnswer("random answer");
    profile.setOrcidIdentifier(TEST_ORCID);
    OrcidBio bio = new OrcidBio();
    ContactDetails contactDetails = new ContactDetails();
    contactDetails.addOrReplacePrimaryEmail(new Email("will@semantico.com"));
    bio.setContactDetails(contactDetails);
    profile.setOrcidBio(bio);
    PersonalDetails personalDetails = new PersonalDetails();
    bio.setPersonalDetails(personalDetails);
    personalDetails.setGivenNames(new GivenNames("Will"));
    personalDetails.setFamilyName(new FamilyName("Simpson"));
    bio.setBiography(new Biography("Will is a software developer"));
    ResearcherUrls researcherUrls = new ResearcherUrls();
    bio.setResearcherUrls(researcherUrls);
    researcherUrls.getResearcherUrl().add(new ResearcherUrl(new Url("http://www.wjrs.co.uk"), null));
    OrcidWorks orcidWorks = new OrcidWorks();
    profile.setOrcidWorks(orcidWorks);
    OrcidWork orcidWork = createWork1();
    // TODO JB - needs test
    // orcidWork.setAddedToProfileDate(new
    // AddedToProfileDate(DateUtils.convertToXMLGregorianCalendar("2010-03-04")));
    // orcidWork.setAddedToProfileDate(new
    // AddedToProfileDate(DateUtils.convertToXMLGregorianCalendar("2010-03-04")));
    orcidWorks.getOrcidWork().add(orcidWork);
    OrcidInternal orcidInternal = new OrcidInternal();
    profile.setOrcidInternal(orcidInternal);
    SecurityDetails securityDetails = new SecurityDetails();
    securityDetails.setSecurityQuestionId(new SecurityQuestionId(3));
    orcidInternal.setSecurityDetails(securityDetails);
    Preferences preferences = new Preferences();
    orcidInternal.setPreferences(preferences);
    return profile;
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) Url(org.orcid.jaxb.model.message.Url) ResearcherUrl(org.orcid.jaxb.model.message.ResearcherUrl) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) SecurityQuestionId(org.orcid.jaxb.model.message.SecurityQuestionId) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) 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) SecurityDetails(org.orcid.jaxb.model.message.SecurityDetails) Preferences(org.orcid.jaxb.model.message.Preferences)

Example 13 with Preferences

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

the class JpaJaxbEntityAdapterToOrcidProfileTest method checkOrcidInternal.

private void checkOrcidInternal(OrcidInternal orcidInternal) {
    SecurityDetails securityDetails = orcidInternal.getSecurityDetails();
    assertNotNull(securityDetails);
    assertEquals("e9adO9I4UpBwqI5tGR+qDodvAZ7mlcISn+T+kyqXPf2Z6PPevg7JijqYr6KGO8VOskOYqVOEK2FEDwebxWKGDrV/TQ9gRfKWZlzxssxsOnA=", securityDetails.getEncryptedPassword().getContent());
    assertEquals(1, securityDetails.getSecurityQuestionId().getValue());
    assertEquals("iTlIoR2JsFl5guE56cazmg==", securityDetails.getEncryptedSecurityAnswer().getContent());
    assertEquals("1vLkD2Lm8c24TyALcW0Brg==", securityDetails.getEncryptedVerificationCode().getContent());
    Preferences preferences = orcidInternal.getPreferences();
    assertNotNull(preferences);
    assertTrue(preferences.getSendChangeNotifications().isValue());
    assertFalse(preferences.getSendOrcidNews().isValue());
}
Also used : SecurityDetails(org.orcid.jaxb.model.message.SecurityDetails) Preferences(org.orcid.jaxb.model.message.Preferences)

Example 14 with Preferences

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

the class Jaxb2JpaAdapterImpl method setInternalDetails.

private void setInternalDetails(ProfileEntity profileEntity, OrcidInternal orcidInternal) {
    if (orcidInternal != null) {
        SecurityDetails securityDetails = orcidInternal.getSecurityDetails();
        if (securityDetails != null) {
            String encryptedPassword = securityDetails.getEncryptedPassword() != null ? securityDetails.getEncryptedPassword().getContent() : null;
            profileEntity.setEncryptedPassword(encryptedPassword);
            profileEntity.setSecurityQuestion(securityDetails.getSecurityQuestionId() == null ? null : securityQuestionDao.find((int) securityDetails.getSecurityQuestionId().getValue()));
            String encryptedAnswer = securityDetails.getEncryptedSecurityAnswer() != null ? securityDetails.getEncryptedSecurityAnswer().getContent() : null;
            profileEntity.setEncryptedSecurityAnswer(encryptedAnswer);
            String verificationCode = securityDetails.getEncryptedVerificationCode() != null ? securityDetails.getEncryptedVerificationCode().getContent() : null;
            profileEntity.setEncryptedVerificationCode(verificationCode);
        }
        if (orcidInternal.getReferredBy() != null) {
            profileEntity.setReferredBy(orcidInternal.getReferredBy().getPath());
        }
        Preferences preferences = orcidInternal.getPreferences();
        if (preferences != null) {
            String sendEmailFrequencyDays = preferences.getSendEmailFrequencyDays();
            profileEntity.setSendEmailFrequencyDays(Float.valueOf(sendEmailFrequencyDays == null ? DefaultPreferences.SEND_EMAIL_FREQUENCY_DAYS : sendEmailFrequencyDays));
            profileEntity.setSendChangeNotifications(preferences.getSendChangeNotifications() == null ? null : preferences.getSendChangeNotifications().isValue());
            profileEntity.setSendOrcidNews(preferences.getSendOrcidNews() == null ? null : preferences.getSendOrcidNews().isValue());
            profileEntity.setSendMemberUpdateRequests(preferences.getSendMemberUpdateRequests() == null ? null : preferences.getSendMemberUpdateRequests());
            // ActivitiesVisibilityDefault default is WorkVisibilityDefault
            if (preferences.getActivitiesVisibilityDefault() != null && preferences.getActivitiesVisibilityDefault().getValue() != null) {
                profileEntity.setActivitiesVisibilityDefault(org.orcid.jaxb.model.common_v2.Visibility.fromValue(preferences.getActivitiesVisibilityDefault().getValue().value()));
            }
            if (preferences.getDeveloperToolsEnabled() != null) {
                profileEntity.setEnableDeveloperTools(preferences.getDeveloperToolsEnabled().isValue());
            }
            profileEntity.setEnableNotifications(preferences.getNotificationsEnabled() == null ? DefaultPreferences.NOTIFICATIONS_ENABLED : preferences.getNotificationsEnabled());
        }
        if (orcidInternal.getSalesforceId() != null) {
            profileEntity.setSalesforeId(orcidInternal.getSalesforceId().getContent());
        }
    }
}
Also used : SecurityDetails(org.orcid.jaxb.model.message.SecurityDetails) Preferences(org.orcid.jaxb.model.message.Preferences) OrcidPreferences(org.orcid.jaxb.model.message.OrcidPreferences) DefaultPreferences(org.orcid.core.constants.DefaultPreferences)

Example 15 with Preferences

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

the class OrcidMessageVersionConverterImplV1_2_rc3ToV1_2_rc4 method downgradeProfile.

private void downgradeProfile(OrcidProfile orcidProfile) {
    if (orcidProfile != null) {
        if (orcidProfile.getOrcidHistory() != null) {
            if (orcidProfile.getOrcidHistory().getVerifiedEmail() != null) {
                orcidProfile.getOrcidHistory().setVerifiedEmail(null);
            }
            if (orcidProfile.getOrcidHistory().getVerifiedPrimaryEmail() != null) {
                orcidProfile.getOrcidHistory().setVerifiedPrimaryEmail(null);
            }
        }
        if (orcidProfile.getOrcidInternal() != null) {
            // earlier versions of the XSD don't have GroupOrcidIdentifier 
            if (orcidProfile.getOrcidInternal().getReferredBy() != null) {
                orcidProfile.getOrcidInternal().setReferredBy(null);
            }
            // earlier versions of the XSD don't have 
            if (orcidProfile.getOrcidInternal().getPreferences() != null && orcidProfile.getOrcidInternal().getPreferences().getDeveloperToolsEnabled() != null) {
                orcidProfile.getOrcidInternal().getPreferences().setDeveloperToolsEnabled(null);
            }
        }
        if (orcidProfile.getOrcidInternal() != null) {
            if (orcidProfile.getOrcidInternal().getPreferences() != null) {
                Preferences prefs = orcidProfile.getOrcidInternal().getPreferences();
                if (prefs.getActivitiesVisibilityDefault() != null && prefs.getActivitiesVisibilityDefault().getValue() != null) {
                    prefs.setWorkVisibilityDefault(new WorkVisibilityDefault(prefs.getActivitiesVisibilityDefault().getValue()));
                    prefs.setActivitiesVisibilityDefault(null);
                }
            }
        }
        //Previews versions doesnt have organization defined funding type
        if (orcidProfile.getOrcidActivities() != null) {
            OrcidActivities activities = orcidProfile.getOrcidActivities();
            if (activities.getFundings() != null) {
                FundingList fundingList = activities.getFundings();
                for (Funding funding : fundingList.getFundings()) {
                    funding.setOrganizationDefinedFundingType(null);
                }
            }
        }
    }
}
Also used : FundingList(org.orcid.jaxb.model.message.FundingList) WorkVisibilityDefault(org.orcid.jaxb.model.message.WorkVisibilityDefault) Funding(org.orcid.jaxb.model.message.Funding) Preferences(org.orcid.jaxb.model.message.Preferences) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities)

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