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);
}
}
}
}
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());
}
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;
}
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);
}
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;
}
Aggregations