@Override public Locale getLocaleFromOrcidProfile(OrcidProfile orcidProfile) { Locale locale = null; if (orcidProfile.getOrcidPreferences() != null && orcidProfile.getOrcidPreferences().getLocale() != null) { orcidProfile.getOrcidPreferences().getLocale().value(); locale = LocaleUtils.toLocale(orcidProfile.getOrcidPreferences().getLocale().value()); } else { locale = LocaleUtils.toLocale("en"); } return locale; }
@Override public OrcidProfile updateOrcidPreferences(OrcidProfile updatedOrcidProfile) { OrcidProfile existingProfile = retrieveOrcidProfile(updatedOrcidProfile.getOrcidIdentifier().getPath()); if (existingProfile == null) { return null; } existingProfile.setOrcidPreferences(updatedOrcidProfile.getOrcidPreferences()); OrcidProfile profileToReturn = updateOrcidProfile(existingProfile); notificationManager.sendAmendEmail(updatedOrcidProfile.getOrcidIdentifier().getPath(), AmendedSection.PREFERENCES, null); return profileToReturn; }
@Override public ProfileEntity toProfileEntity(OrcidProfile profile, ProfileEntity existingProfileEntity, UpdateOptions updateOptions) { Assert.notNull(profile, "Cannot convert a null OrcidProfile"); ProfileEntity profileEntity = existingProfileEntity == null ? new ProfileEntity() : existingProfileEntity; // if orcid-id exist us it String orcidString = profile.getOrcidIdentifier().getPath(); if (profile.retrieveOrcidUriAsString() != null && !profile.retrieveOrcidUriAsString().isEmpty()) { orcidString = OrcidStringUtils.getOrcidNumber(profile.retrieveOrcidUriAsString()); } profileEntity.setId(orcidString); profileEntity.setOrcidType(profile.getType().name()); profileEntity.setGroupType(profile.getGroupType() != null ? profile.getGroupType().name() : null); setBioDetails(profileEntity, profile.getOrcidBio()); setHistoryDetails(profileEntity, profile.getOrcidHistory()); setActivityDetails(profileEntity, profile.getOrcidActivities(), updateOptions); setInternalDetails(profileEntity, profile.getOrcidInternal()); setPreferencesDetails(profileEntity, profile.getOrcidPreferences()); profileEntity.setUserLastIp(profile.getUserLastIp()); profileEntity.setReviewed(profile.isReviewed()); if(profileEntity.getUsedRecaptchaOnRegistration() == null) { profileEntity.setUsedRecaptchaOnRegistration(false); } return profileEntity; }