Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
05/15/08 14:24:20 (4 months ago)
Author:
bwolfe
Message:

Adding multiple locale search option - #713
Author: akollegger

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/trunk/src/api/org/openmrs/User.java

    r4158 r4230  
    1414package org.openmrs; 
    1515 
     16import java.util.ArrayList; 
    1617import java.util.Collection; 
    1718import java.util.Date; 
    1819import java.util.HashSet; 
    1920import java.util.Iterator; 
     21import java.util.List; 
     22import java.util.Locale; 
    2023import java.util.Map; 
    2124import java.util.Set; 
     
    2326import org.apache.commons.logging.Log; 
    2427import org.apache.commons.logging.LogFactory; 
     28import org.openmrs.util.LocaleFactory; 
    2529import org.openmrs.util.OpenmrsConstants; 
    2630import org.openmrs.util.OpenmrsUtil; 
     
    6872        private String voidReason; 
    6973 
     74        private List<Locale> proficientLocales = null; 
     75        private String parsedProficientLocalesProperty = ""; 
     76 
    7077        // Constructors 
    7178 
     
    607614                return; 
    608615        } 
     616 
     617        /** 
     618         * Returns a list of Locales for which the User  
     619         * is considered proficient. 
     620     *  
     621     * @return List of the User's proficient locales 
     622     */ 
     623    public List<Locale> getProficientLocales() { 
     624                String proficientLocalesProperty = getUserProperty(OpenmrsConstants.USER_PROPERTY_PROFICIENT_LOCALES); 
     625 
     626        if ((proficientLocales == null) || (!parsedProficientLocalesProperty.equals(proficientLocalesProperty))) { 
     627                parsedProficientLocalesProperty = proficientLocalesProperty; 
     628                proficientLocales = new ArrayList<Locale>(); 
     629                         
     630                        String[] proficientLocalesArray = proficientLocalesProperty.split(","); 
     631                        for (String proficientLocaleSpec : proficientLocalesArray) { 
     632                                if (proficientLocaleSpec.length() > 0) { 
     633                                        Locale proficientLocale = LocaleFactory.fromSpecification(proficientLocaleSpec); 
     634                                        if (!proficientLocales.contains(proficientLocale)) { 
     635                                                proficientLocales.add(proficientLocale); 
     636                                                if (proficientLocale.getCountry() != "") { 
     637                                                        // add the language also 
     638                                                        Locale languageOnlyLocale = LocaleFactory.fromSpecification(proficientLocale.getLanguage()); 
     639                                                        if (!proficientLocales.contains(languageOnlyLocale)) { 
     640                                                                proficientLocales.add(LocaleFactory.fromSpecification(proficientLocale.getLanguage())); 
     641                                                        } 
     642                                                } 
     643                                        } 
     644                                } 
     645                        } 
     646        } 
     647        return proficientLocales; 
     648    } 
    609649}