Search in sources :

Example 1 with OrcidInternal

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

the class OrcidMessageVersionConverterImplV1_2_rc5ToV1_2_rc6 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()) {
                    Source source = externalIdentifier.getSource();
                    if (source != null) {
                        SourceOrcid sourceOrcid = source.getSourceOrcid();
                        if (sourceOrcid != null) {
                            externalIdentifier.setSource(null);
                            externalIdentifier.setExternalIdSource(new ExternalIdSource(sourceOrcid));
                        }
                    }
                }
        if (orcidProfile.getOrcidActivities() != null) {
            if (orcidProfile.getOrcidActivities().getOrcidWorks() != null) {
                for (OrcidWork act : orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork()) downGradeActivity(act);
            }
        }
        OrcidInternal orcidInternal = orcidProfile.getOrcidInternal();
        if (orcidInternal != null) {
            Preferences prefs = orcidInternal.getPreferences();
            if (prefs != null) {
                prefs.setSendEmailFrequencyDays(null);
                prefs.setSendMemberUpdateRequests(null);
            }
            ReferredBy referredBy = orcidInternal.getReferredBy();
            if (referredBy != null && !OrcidStringUtils.isValidOrcid(referredBy.getPath())) {
                orcidInternal.setReferredBy(null);
            }
        }
    }
}
Also used : WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) ExternalIdentifier(org.orcid.jaxb.model.message.ExternalIdentifier) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) ExternalIdSource(org.orcid.jaxb.model.message.ExternalIdSource) ReferredBy(org.orcid.jaxb.model.message.ReferredBy) SourceOrcid(org.orcid.jaxb.model.message.SourceOrcid) Preferences(org.orcid.jaxb.model.message.Preferences) ExternalIdSource(org.orcid.jaxb.model.message.ExternalIdSource) Source(org.orcid.jaxb.model.message.Source) WorkSource(org.orcid.jaxb.model.message.WorkSource)

Example 2 with OrcidInternal

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

Example 3 with OrcidInternal

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

the class OrcidProfileManagerImpl method initSecurityDetails.

private SecurityDetails initSecurityDetails(OrcidProfile cachedProfile) {
    OrcidInternal internal = cachedProfile.getOrcidInternal();
    if (internal == null) {
        internal = new OrcidInternal();
        cachedProfile.setOrcidInternal(internal);
    }
    SecurityDetails securityDetails = internal.getSecurityDetails();
    if (securityDetails == null) {
        securityDetails = new SecurityDetails();
        internal.setSecurityDetails(securityDetails);
    }
    return securityDetails;
}
Also used : OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) SecurityDetails(org.orcid.jaxb.model.message.SecurityDetails)

Example 4 with OrcidInternal

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

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

Aggregations

OrcidInternal (org.orcid.jaxb.model.message.OrcidInternal)14 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)12 Preferences (org.orcid.jaxb.model.message.Preferences)10 Date (java.util.Date)7 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)7 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)7 ActivitiesVisibilityDefault (org.orcid.jaxb.model.message.ActivitiesVisibilityDefault)6 Claimed (org.orcid.jaxb.model.message.Claimed)6 SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)6 Test (org.junit.Test)5 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)5 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)5 SendChangeNotifications (org.orcid.jaxb.model.message.SendChangeNotifications)5 SendOrcidNews (org.orcid.jaxb.model.message.SendOrcidNews)5 Transactional (org.springframework.transaction.annotation.Transactional)5 DefaultPreferences (org.orcid.core.constants.DefaultPreferences)4 Email (org.orcid.jaxb.model.message.Email)4 FamilyName (org.orcid.jaxb.model.message.FamilyName)4 GivenNames (org.orcid.jaxb.model.message.GivenNames)4 ResearcherUrl (org.orcid.jaxb.model.message.ResearcherUrl)4