Search in sources :

Example 1 with DeveloperToolsEnabled

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

the class OrcidMessageVersionConverterImplV1_2_rc3ToV1_2_rc4 method upgradeProfile.

private void upgradeProfile(OrcidProfile orcidProfile) {
    if (orcidProfile != null) {
        if (orcidProfile.getOrcidInternal() != null) {
            if (orcidProfile.getOrcidInternal().getPreferences() != null) {
                Preferences prefs = orcidProfile.getOrcidInternal().getPreferences();
                if (prefs.getWorkVisibilityDefault() != null && prefs.getWorkVisibilityDefault().getValue() != null) {
                    prefs.setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(prefs.getWorkVisibilityDefault().getValue()));
                    prefs.setWorkVisibilityDefault(null);
                }
                if (prefs.getDeveloperToolsEnabled() == null) {
                    DeveloperToolsEnabled dtn = new DeveloperToolsEnabled(false);
                    prefs.setDeveloperToolsEnabled(dtn);
                }
            }
        }
    }
}
Also used : ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Preferences(org.orcid.jaxb.model.message.Preferences) DeveloperToolsEnabled(org.orcid.jaxb.model.message.DeveloperToolsEnabled)

Example 2 with DeveloperToolsEnabled

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

the class OrcidProfileManagerImplTest method testUpdatePreferences.

@Test
@Transactional
@Rollback(true)
public void testUpdatePreferences() {
    OrcidProfile profile1 = createBasicProfile();
    profile1 = orcidProfileManager.createOrcidProfile(profile1, false, false);
    assertEquals(Visibility.PRIVATE, profile1.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault().getValue());
    OrcidProfile profile2 = new OrcidProfile();
    profile2.setOrcidIdentifier(TEST_ORCID);
    OrcidInternal internal = new OrcidInternal();
    profile2.setOrcidInternal(internal);
    Preferences preferences = new Preferences();
    internal.setPreferences(preferences);
    preferences.setSendChangeNotifications(new SendChangeNotifications(false));
    preferences.setSendOrcidNews(new SendOrcidNews(true));
    preferences.setDeveloperToolsEnabled(new DeveloperToolsEnabled(true));
    preferences.setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.PUBLIC));
    orcidProfileManager.updatePreferences(profile2.getOrcidIdentifier().getPath(), profile2.getOrcidInternal().getPreferences());
    OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
    assertEquals(false, retrievedProfile.getOrcidInternal().getPreferences().getSendChangeNotifications().isValue());
    assertEquals(true, retrievedProfile.getOrcidInternal().getPreferences().getSendOrcidNews().isValue());
    assertEquals(true, retrievedProfile.getOrcidInternal().getPreferences().getDeveloperToolsEnabled().isValue());
    assertEquals(Visibility.PUBLIC, retrievedProfile.getOrcidInternal().getPreferences().getActivitiesVisibilityDefault().getValue());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) SendOrcidNews(org.orcid.jaxb.model.message.SendOrcidNews) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) 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) DeveloperToolsEnabled(org.orcid.jaxb.model.message.DeveloperToolsEnabled) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ActivitiesVisibilityDefault (org.orcid.jaxb.model.message.ActivitiesVisibilityDefault)2 DeveloperToolsEnabled (org.orcid.jaxb.model.message.DeveloperToolsEnabled)2 Preferences (org.orcid.jaxb.model.message.Preferences)2 Test (org.junit.Test)1 DefaultPreferences (org.orcid.core.constants.DefaultPreferences)1 OrcidInternal (org.orcid.jaxb.model.message.OrcidInternal)1 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)1 SendChangeNotifications (org.orcid.jaxb.model.message.SendChangeNotifications)1 SendOrcidNews (org.orcid.jaxb.model.message.SendOrcidNews)1 Rollback (org.springframework.test.annotation.Rollback)1 Transactional (org.springframework.transaction.annotation.Transactional)1