Package mc.core.domain.i18n.dobj
Class LocaleDO
java.lang.Object
mc.core.system.base.BaseBean
-
Nested Class Summary
Nested classes/interfaces inherited from class mc.core.domain.base.dobj.AbstractBaseDO
AbstractBaseDO.Initializer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfromJavaLocale(String javaLocaleString) Returns a active Locale according to the following rules:
if a locale whose java locale string is an exact match to the given string is found in db this is returned.
as fallback a locale whose language part is a match with the langauge part of the given string is returned if country and/or extension do not differ explicitly, e.g.fromJavaLocale(Locale javaLocale) Searches mediacockpit locales by example.getFromKey(Object key) get entity by key through entity specific property matchinggetJavaLocale(Locale locale) Gets all locales marked as isActive and isUILocale and not as isSystem (default and undefined locale).map data to entity if any, validate and savemc.core.domain.i18n.dobj.LocaleDO.LocaleValidatorfor persistent entity copy constructor be used, the copy of entity be mapped and validated
WARNING: in error case param map be changed! non valid fields be deleted from it
all error be collect as ValidationResults in ValidationException and throw only by validate() call
Examples to use:
1.Methods inherited from class mc.core.domain.base.dobj.AbstractSimpleEntityDO
changeOrder, getAllActive, getUserRole, toggleActivationMethods inherited from class mc.core.domain.base.dobj.AbstractEntityBaseDO
addDefaultSearchCriteria, copy, copyToCollection, getFromInternalDescription, prepareSearchFilter, sendEvent, sendEventMethods inherited from class mc.core.domain.base.dobj.AbstractBaseDO
delete, delete, getAll, getEntityDisplay, getFromId, getOne, map, map, save
-
Constructor Details
-
LocaleDO
public LocaleDO()
-
-
Method Details
-
save
Description copied from interface:IBaseDOmap data to entity if any, validate and save- Specified by:
savein interfaceIBaseDO<Locale>- Overrides:
savein classAbstractEntityBaseDO<Locale>- Parameters:
locale- mandatorymap- optional- Returns:
- mapped entity
- Throws:
ApplicationException
-
getJavaLocale
-
getUIActive
Gets all locales marked as isActive and isUILocale and not as isSystem (default and undefined locale).- Returns:
- list of Locale entities
-
getDefault
- Returns:
- Locale.DEFAULT
- Throws:
mc.core.system.configuration.ConfigurationException- (RuntimeException) if locale default does not exist.
-
getUiDefault
-
getUndefined
- Returns:
- Locale.UNDEFINED
- Throws:
mc.core.system.configuration.ConfigurationException- (RuntimeException) if locale undefined does not exist.
-
getFromKey
Description copied from interface:IBaseDOget entity by key through entity specific property matching- Specified by:
getFromKeyin interfaceIBaseDO<Locale>- Overrides:
getFromKeyin classAbstractBaseDO<Locale>- Parameters:
key- mandatory, can be the java locale code, the id (long or String) or internalDescription- Returns:
- entity if found and unique
- Throws:
EntityNotFoundException- if no locale can be found for this keyNotUniqueResultException- if more than one locale are found for id or internalDescription (does not apply to java locale string due to fallback strategy when no exact match is possible)
-
fromJavaLocale
Returns a active Locale according to the following rules:
if a locale whose java locale string is an exact match to the given string is found in db this is returned.
as fallback a locale whose language part is a match with the langauge part of the given string is returned if country and/or extension do not differ explicitly, e.g. a different country is set in both.
If no matching locale can be found returns the default locale. Example:- in DB: fr, fr_CH
fr -> fr
fr_CH -> fr_CH
fr_FR -> fr (fallback)
- in DB: fr_FR, fr_CH
fr_FR -> fr_FR
fr_CH -> fr_CH
fr -> fr_FR (fallback, first found) + warning
- in DB: fr
fr -> fr
fr_CH -> fr (fallback)
- in DB: fr_CH
fr -> fr_CH (fallback)
fr_CH -> fr_CH
fr_FR -> Default-Locale in fromJavaLocale, EntityNotFoundEx in getFromKey
- Parameters:
javaLocaleString- Language, country and variant separated by underscore. For exampleen_GB.
- in DB: fr, fr_CH
-
fromJavaLocale
public Locale fromJavaLocale(Locale javaLocale) throws EntityNotFoundException, NotUniqueResultException Searches mediacockpit locales by example. Does not perform any fallbacks or fuzzy searching.- Parameters:
javaLocale- JavaLocaleobject.- Returns:
- mediacockpit representation of an equal locale.
- Throws:
EntityNotFoundExceptionNotUniqueResultException
-
validator
public mc.core.domain.i18n.dobj.LocaleDO.LocaleValidator validator(Locale locale, DataMap map) throws ApplicationException Description copied from class:AbstractBaseDOfor persistent entity copy constructor be used, the copy of entity be mapped and validated
WARNING: in error case param map be changed! non valid fields be deleted from it
all error be collect as ValidationResults in ValidationException and throw only by validate() call
Examples to use:
1. validator( navigationHrc, dataMap).thatValidField( NavigationHrc.Field.navigationHrcType).validate(); 2. validator( navigation, dataMap).thatValidField( Navigation.Field.navigationType, Navigation.Field.navigationHrc) .thatNotNullIf( HrcEntity.Field.parent, n -> n.getNavigationType().getParentNavigationType() != null).validate(); 3. validator( entity, dataMap).thatValidField( Country.Field.iso2Code, "message.validate.Country.iso2Code.missing").thatUnique( Country.Field.iso2Code).validate();- Overrides:
validatorin classAbstractBaseDO<Locale>- Parameters:
locale- mandatorymap- optional- Returns:
- the validator
- Throws:
ApplicationException- the application exception
-