package eu.etaxonomy.cdm.persistence.dao.common;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Locale;
+
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.cdm.model.common.Language;
* @return the Language or null
*/
public Language getLangaugeByIso(String iso639);
+
+ public List<Language> getLangaugesByIso(List<String> iso639List);
+
+ public List<Language> getLangaugesByLocale(Enumeration<Locale> locales);
}
package eu.etaxonomy.cdm.persistence.dao.hibernate.common;
+import java.util.ArrayList;
+import java.util.Enumeration;
import java.util.List;
+import java.util.Locale;
import java.util.UUID;
import org.apache.log4j.Logger;
query.setParameter("isoCode", iso639);
return (Language) query.uniqueResult();
}
+
+ public List<Language> getLangaugesByIso(List<String> iso639List) {
+ List<Language> languages = new ArrayList<Language>(iso639List.size());
+ for (String iso639 : iso639List) {
+ languages.add(getLangaugeByIso(iso639));
+ }
+ return languages;
+ }
+
+ public List<Language> getLangaugesByLocale(Enumeration<Locale> locales) {
+ List<Language> languages = new ArrayList<Language>();
+ while(locales.hasMoreElements()) {
+ Locale locale = locales.nextElement();
+ languages.add(getLangaugeByIso(locale.getLanguage()));
+ }
+ return languages;
+ }
// @Override
// public List<DefinedTermBase> list(int limit, int start) {