@JsonValue public String jsonValue() { return this.name(); }
public static Locale fromValue(String v) { for (Locale c : Locale.values()) { if (v.startsWith(c.value)) { return c; } } // if we don't support the specified language return english return Locale.EN; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((locale == null) ? 0 : locale.hashCode()); return result; }
private Locale getLocaleFromProfile(ProfileEntity profile){ org.orcid.jaxb.model.common_v2.Locale orcidLocale = org.orcid.jaxb.model.common_v2.Locale.valueOf(profile.getLocale()); String value = orcidLocale.value(); Locale locale = null; if(value!= null) { if(value.contains("_")){ String [] localeTokens = value.split("_"); locale = new Locale(localeTokens[0], localeTokens[1]); } else { locale = new Locale(value); } } return locale; }
@Override public Locale retrieveLocale(String orcid) { String locale = profileDao.retrieveLocale(orcid); return Locale.valueOf(locale); }
private Locale getUserLocaleFromProfileEntity(ProfileEntity profile) { String locale = profile.getLocale(); if (locale != null) { org.orcid.jaxb.model.common_v2.Locale loc = org.orcid.jaxb.model.common_v2.Locale.valueOf(locale); return LocaleUtils.toLocale(loc.value()); } return LocaleUtils.toLocale("en"); }
private Preferences getPreferences(String orcid) { Preferences preferences = new Preferences(); ProfileEntity profile = profileEntityCacheManager.retrieve(orcid); Locale profileEntityLocale = Locale.valueOf(profile.getLocale()); if (profileEntityLocale != null) { preferences.setLocale(profileEntityLocale); } return preferences; }
private Locale getUserLocaleFromProfileEntity(ProfileEntity profile) { String locale = profile.getLocale(); if (locale != null) { org.orcid.jaxb.model.common_v2.Locale loc = org.orcid.jaxb.model.common_v2.Locale.valueOf(locale); return LocaleUtils.toLocale(loc.value()); } return LocaleUtils.toLocale("en"); }
@Override public void updateLocale(String orcid, Locale locale) { profileDao.updateLocale(orcid, locale.name()); }
public static Locale fromValue(String v) { for (Locale c: Locale.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((locale == null) ? 0 : locale.hashCode()); return result; }
private Locale getUserLocale(String localeStr) { if (PojoUtil.isEmpty(localeStr)) { return LocaleUtils.toLocale("en"); } org.orcid.jaxb.model.common_v2.Locale locale = org.orcid.jaxb.model.common_v2.Locale.valueOf(localeStr); if (locale != null) { return LocaleUtils.toLocale(locale.value()); } return LocaleUtils.toLocale("en"); } }
private void setPreferencesDetails(ProfileEntity profileEntity, OrcidPreferences orcidPreferences) { if (orcidPreferences != null) { if (orcidPreferences.getLocale() != null) profileEntity.setLocale(orcidPreferences.getLocale().name()); else profileEntity.setLocale(org.orcid.jaxb.model.common_v2.Locale.EN.name()); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((locale == null) ? 0 : locale.hashCode()); return result; }
protected Locale getUserLocale(String localeStr) { if(!LOCALIZED) { return Locale.ENGLISH; } if (PojoUtil.isEmpty(localeStr)) { return LocaleUtils.toLocale("en"); } org.orcid.jaxb.model.common_v2.Locale locale = org.orcid.jaxb.model.common_v2.Locale.valueOf(localeStr); if (locale != null) { return LocaleUtils.toLocale(locale.value()); } return LocaleUtils.toLocale("en"); }
profile.setCompletedDate(new Date()); if (locale != null) { profile.setLocale(locale.name());
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((locale == null) ? 0 : locale.hashCode()); return result; }
@Override public void sendAutoDeprecateNotification(String primaryOrcid, String deprecatedOrcid) { ProfileEntity primaryProfileEntity = profileEntityCacheManager.retrieve(primaryOrcid); ProfileEntity deprecatedProfileEntity = profileEntityCacheManager.retrieve(deprecatedOrcid); ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(SourceEntityUtils.getSourceId(deprecatedProfileEntity.getSource())); Locale userLocale = LocaleUtils .toLocale(primaryProfileEntity.getLocale() == null ? org.orcid.jaxb.model.common_v2.Locale.EN.value() : org.orcid.jaxb.model.common_v2.Locale.valueOf(primaryProfileEntity.getLocale()).value()); // Create map of template params Map<String, Object> templateParams = new HashMap<String, Object>(); String subject = getSubject("email.subject.auto_deprecate", userLocale); String assetsUrl = getAssetsUrl(); Date deprecatedAccountCreationDate = deprecatedProfileEntity.getDateCreated(); // Create map of template params templateParams.put("primaryId", primaryOrcid); templateParams.put("name", deriveEmailFriendlyName(primaryProfileEntity)); templateParams.put("assetsUrl", assetsUrl); templateParams.put("subject", subject); templateParams.put("clientName", clientDetails.getClientName()); templateParams.put("deprecatedAccountCreationDate", deprecatedAccountCreationDate); templateParams.put("deprecatedId", deprecatedOrcid); addMessageParams(templateParams, userLocale); // Generate html from template String html = templateManager.processTemplate("auto_deprecated_account_html.ftl", templateParams); NotificationAdministrative notification = new NotificationAdministrative(); notification.setNotificationType(NotificationType.ADMINISTRATIVE); notification.setSubject(subject); notification.setBodyHtml(html); createNotification(primaryOrcid, notification); }
newRecord.setGroupType(MemberType.fromValue(member.getType().getValue()).name()); newRecord.setLastModified(now); newRecord.setLocale(org.orcid.jaxb.model.common_v2.Locale.EN.name()); newRecord.setRecordLocked(false); newRecord.setReviewed(false);
@Override public void sendAutoDeprecateNotification(String primaryOrcid, String deprecatedOrcid) { ProfileEntity primaryProfileEntity = profileEntityCacheManager.retrieve(primaryOrcid); ProfileEntity deprecatedProfileEntity = profileEntityCacheManager.retrieve(deprecatedOrcid); ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(SourceEntityUtils.getSourceId(deprecatedProfileEntity.getSource())); Locale userLocale = LocaleUtils .toLocale(primaryProfileEntity.getLocale() == null ? org.orcid.jaxb.model.common_v2.Locale.EN.value() : org.orcid.jaxb.model.common_v2.Locale.valueOf(primaryProfileEntity.getLocale()).value()); // Create map of template params Map<String, Object> templateParams = new HashMap<String, Object>(); String subject = getSubject("email.subject.auto_deprecate", userLocale); String assetsUrl = getAssetsUrl(); Date deprecatedAccountCreationDate = deprecatedProfileEntity.getDateCreated(); // Create map of template params templateParams.put("primaryId", primaryOrcid); templateParams.put("name", deriveEmailFriendlyName(primaryProfileEntity)); templateParams.put("assetsUrl", assetsUrl); templateParams.put("subject", subject); templateParams.put("clientName", clientDetails.getClientName()); templateParams.put("deprecatedAccountCreationDate", deprecatedAccountCreationDate); templateParams.put("deprecatedId", deprecatedOrcid); addMessageParams(templateParams, userLocale); // Generate html from template String html = templateManager.processTemplate("auto_deprecated_account_html.ftl", templateParams); NotificationAdministrative notification = new NotificationAdministrative(); notification.setNotificationType(NotificationType.ADMINISTRATIVE); notification.setSubject(subject); notification.setBodyHtml(html); createNotification(primaryOrcid, notification); }