Ticket #713: locale_update.patch
| File locale_update.patch, 83.4 kB (added by akollegger, 8 months ago) |
|---|
-
.classpath
old new 5 5 <classpathentry kind="src" path="src/web"/> 6 6 <classpathentry kind="src" path="test/api"/> 7 7 <classpathentry kind="src" path="test/web"/> 8 <classpathentry kind="lib" path="lib/ant-contrib/ant-contrib-1.0b2.jar"/>9 8 <classpathentry kind="lib" path="lib/antlr/antlr_2.7.6.jar"/> 10 9 <classpathentry kind="lib" path="lib/cglib/cglib-2.1_3.jar"/> 11 10 <classpathentry kind="lib" path="lib/commons-beanutils/commons-beanutils-1.7.0.jar"/> … … 57 56 <classpathentry kind="lib" path="metadata/api/spring"/> 58 57 <classpathentry kind="lib" path="metadata/api/hibernate"/> 59 58 <classpathentry kind="lib" path="metadata/api/log4j"/> 59 <classpathentry kind="lib" path="lib/ant-contrib/ant-contrib-1.0b2.jar"/> 60 60 <classpathentry kind="output" path="build/"/> 61 61 </classpath> -
metadata/api/hibernate/org/openmrs/api/db/hibernate/ConceptWord.hbm.xml
old new 11 11 <key-many-to-one name="concept" column="concept_id" 12 12 class="Concept" /> 13 13 <key-property name="word" type="java.lang.String" length="255" /> 14 <key-property name="synonym" type="java.lang.String" length="255" /> 15 <key-property name="locale" type="java. lang.String" length="255" />14 <key-property name="synonym" type="java.lang.String" length="255" /> 15 <key-property name="locale" type="java.util.Locale" length="255" /> 16 16 </composite-id> 17 17 18 18 <many-to-one name="concept" column="concept_id" class="Concept" -
metadata/api/hibernate/org/openmrs/api/db/hibernate/Concept.hbm.xml
old new 39 39 <composite-element class="ConceptName"> 40 40 <parent name="concept" /> 41 41 <property name="name" type="java.lang.String" length="255" not-null="true"/> 42 <property name="locale" type="java. lang.String" length="50" not-null="true"/>42 <property name="locale" type="java.util.Locale" length="50" not-null="true"/> 43 43 <property name="shortName" type="java.lang.String" length="255" column="short_name" /> 44 44 <property name="description" type="java.lang.String" length="65535" not-null="true" /> 45 45 <property name="dateCreated" type="java.util.Date" column="date_created" not-null="true"/> … … 73 73 <composite-element class="ConceptSynonym"> 74 74 <parent name="concept" /> 75 75 <property name="synonym" type="java.lang.String" not-null="true" /> 76 <property name="locale" type="java. lang.String" not-null="true" />76 <property name="locale" type="java.util.Locale" not-null="true" /> 77 77 <property name="dateCreated" type="java.util.Date" column="date_created" not-null="true"/> 78 78 <many-to-one name="creator" class="User" column="creator" not-null="true"/> 79 79 </composite-element> -
src/api/org/openmrs/ConceptWord.java
old new 15 15 16 16 import java.util.HashSet; 17 17 import java.util.List; 18 import java.util.Locale; 18 19 import java.util.Set; 19 20 import java.util.Vector; 20 21 … … 36 37 37 38 private String synonym; 38 39 39 private Stringlocale;40 private Locale locale; 40 41 41 42 private Double weight = 0.0; 42 43 … … 46 47 public ConceptWord() { 47 48 } 48 49 49 public ConceptWord(String word, Concept concept, Stringlocale,50 public ConceptWord(String word, Concept concept, Locale locale, 50 51 String synonym) { 51 52 this.concept = concept; 52 53 this.word = word; … … 95 96 /** 96 97 * @return Returns the locale. 97 98 */ 98 public StringgetLocale() {99 public Locale getLocale() { 99 100 return locale; 100 101 } 101 102 … … 103 104 * @param locale 104 105 * The locale to set. 105 106 */ 106 public void setLocale( Stringlocale) {107 public void setLocale(Locale locale) { 107 108 this.locale = locale; 108 109 } 109 110 -
src/api/org/openmrs/ConceptSynonym.java
old new 32 32 33 33 private Concept concept; 34 34 private String synonym; 35 private Stringlocale;35 private Locale locale; 36 36 private User creator; 37 37 private Date dateCreated; 38 38 … … 45 45 public ConceptSynonym(Concept c, String s, Locale l) { 46 46 setConcept(c); 47 47 setSynonym(s); 48 setLocale(l .getLanguage().substring(0, 2));48 setLocale(l); 49 49 } 50 50 51 51 public boolean equals(Object obj) { … … 107 107 /** 108 108 * @return Returns the locale. 109 109 */ 110 public StringgetLocale() {110 public Locale getLocale() { 111 111 return locale; 112 112 } 113 113 114 114 /** 115 115 * @param locale The locale to set. 116 116 */ 117 public void setLocale( Stringlocale) {117 public void setLocale(Locale locale) { 118 118 this.locale = locale; 119 119 //id.setLocale(locale); 120 120 } -
src/api/org/openmrs/ConceptName.java
old new 30 30 private String name; 31 31 private String shortName; 32 32 private String description; 33 private Stringlocale;33 private Locale locale; 34 34 private User creator; 35 35 private Date dateCreated; 36 36 … … 104 104 /** 105 105 * 106 106 */ 107 public StringgetLocale() {107 public Locale getLocale() { 108 108 return locale; 109 109 } 110 110 111 public void setLocale( Stringlocale) {111 public void setLocale(Locale locale) { 112 112 this.locale = locale; 113 113 } 114 115 public void setLocale(Locale locale) {116 this.locale = locale.getLanguage().substring(0, 2);117 }118 114 119 115 /** 120 116 * @return Returns the shortName. -
src/api/org/openmrs/util/OpenmrsConstants.java
old new 532 532 public static final String USER_PROPERTY_NOTIFICATION = "notification"; 533 533 public static final String USER_PROPERTY_NOTIFICATION_ADDRESS = "notificationAddress"; 534 534 public static final String USER_PROPERTY_NOTIFICATION_FORMAT = "notificationFormat"; // text/plain, text/html 535 536 /** 537 * A user property name. The value should be a comma-separated ordered 538 * list of fully qualified locales within which the user is a proficient 539 * speaker. The list should be ordered from the most to the least proficiency. 540 * 541 * Example: 542 * <code>proficientLocales = en_US, en_GB, en, fr_RW</code> 543 */ 544 public static final String USER_PROPERTY_PROFICIENT_LOCALES = "proficientLocales"; 535 545 536 546 /* 537 547 * Report object properties -
src/api/org/openmrs/util/LocaleFactory.java
old new 1 package org.openmrs.util; 2 3 4 import java.util.Collection; 5 import java.util.List; 6 import java.util.Locale; 7 import java.util.Vector; 8 9 /** 10 * A factory for creating Locales. 11 * 12 * @author <a href="mailto:akollegger@tembopublic.org">Andreas Kollegger</a> 13 */ 14 public class LocaleFactory { 15 16 /** 17 * Default internal locale. 18 * 19 * ABKTODO: this should be defined/configured somewhere else 20 */ 21 public static final Locale DEFAULT_LOCALE = Locale.ENGLISH; 22 23 /** 24 * Creates a locale based on a string specification. The specification 25 * must be conform with the following format: ll_CC_vv 26 * 27 * Where: 28 * ll two-character lowercase ISO-639 language code 29 * CC two-character uppercase ISO-3166 country code optional 30 * vv arbitrary length variant code 31 * 32 * For example: 33 * en_US_Traditional_WIN 34 * ...represents English language in the United States with the traditional collation for windows. 35 * 36 * @param localeSpecification encoded locale specification 37 * @return the representative Locale, or null if the specification is invalid 38 */ 39 public static Locale fromSpecification(String localeSpecification) 40 { 41 Locale createdLocale = null; 42 43 localeSpecification = localeSpecification.trim(); 44 45 String[] localeComponents = localeSpecification.split("_"); 46 if (localeComponents.length == 1) 47 { 48 createdLocale = new Locale(localeComponents[0]); 49 } 50 else if (localeComponents.length == 2) 51 { 52 createdLocale = new Locale(localeComponents[0], localeComponents[1]); 53 } 54 else if (localeComponents.length > 2) 55 { 56 String variant = localeSpecification.substring(localeSpecification.indexOf(localeComponents[2])); 57 createdLocale = new Locale(localeComponents[0], localeComponents[1], variant); 58 } 59 60 return createdLocale; 61 } 62 } -
src/api/org/openmrs/User.java
old new 13 13 */ 14 14 package org.openmrs; 15 15 16 import java.util.ArrayList; 16 17 import java.util.Collection; 17 18 import java.util.Date; 18 19 import java.util.HashSet; 19 20 import java.util.Iterator; 21 import java.util.List; 22 import java.util.Locale; 20 23 import java.util.Map; 21 24 import java.util.Set; 22 25 23 26 import org.apache.commons.logging.Log; 24 27 import org.apache.commons.logging.LogFactory; 28 import org.openmrs.util.LocaleFactory; 25 29 import org.openmrs.util.OpenmrsConstants; 26 30 27 31 /** … … 62 66 private Date dateVoided; 63 67 private String voidReason; 64 68 69 private List<Locale> proficientLocales = null; 70 private String parsedProficientLocalesProperty = ""; 71 65 72 // Constructors 66 73 67 74 /** default constructor */ … … 548 555 public String getLastName() { 549 556 return getFamilyName(); 550 557 } 558 559 /** 560 * Returns a list of Locales for which the User 561 * is considered proficient. 562 * 563 * @return List of the User's proficient locales 564 */ 565 public List<Locale> getProficientLocales() { 566 String proficientLocalesProperty = getUserProperty(OpenmrsConstants.USER_PROPERTY_PROFICIENT_LOCALES); 567 568 if ((proficientLocales == null) || (!parsedProficientLocalesProperty.equals(proficientLocalesProperty))) { 569 parsedProficientLocalesProperty = proficientLocalesProperty; 570 proficientLocales = new ArrayList<Locale>(); 571 572 String[] proficientLocalesArray = proficientLocalesProperty.split(","); 573 for (String proficientLocaleSpec : proficientLocalesArray) { 574 if (proficientLocaleSpec.length() > 0) { 575 Locale proficientLocale = LocaleFactory.fromSpecification(proficientLocaleSpec); 576 if (!proficientLocales.contains(proficientLocale)) { 577 proficientLocales.add(proficientLocale); 578 if (proficientLocale.getCountry() != "") { 579 // add the language also 580 Locale languageOnlyLocale = LocaleFactory.fromSpecification(proficientLocale.getLanguage()); 581 if (!proficientLocales.contains(languageOnlyLocale)) { 582 proficientLocales.add(LocaleFactory.fromSpecification(proficientLocale.getLanguage())); 583 } 584 } 585 } 586 } 587 } 588 } 589 return proficientLocales; 590 } 551 591 } -
src/api/org/openmrs/Concept.java
old new 311 311 */ 312 312 public ConceptName getName(Locale locale, boolean exact) { 313 313 log.debug("Getting conceptName for locale: " + locale); 314 314 315 ConceptName bestMatch = null; // name from compatible locale (not exactly exact) 316 ConceptName defaultName = null; // any available name for the concept 317 315 318 if (locale == null) 316 locale = Locale.US; 317 318 String loc = locale.getLanguage(); 319 if (loc.length() > 2) 320 loc = loc.substring(0, 2); 321 ConceptName defaultName = null; 319 locale = Context.getLocale(); // Don't presume en_US; 320 321 String desiredLanguage = locale.getLanguage(); 322 String desiredCountry = locale.getCountry(); 323 322 324 for (Iterator<ConceptName> i = getNames().iterator(); i.hasNext();) { 323 ConceptName name = i.next(); 324 String lang = name.getLocale(); 325 if (lang.equals(loc)) 326 return name; 327 if (lang.equals("en")) 328 defaultName = name; 325 ConceptName possibleName = i.next(); 326 327 if (possibleName.getLocale().equals(locale)) { 328 bestMatch = possibleName; 329 break; 330 } else { 331 if (defaultName == null) 332 defaultName = possibleName; 333 if (bestMatch == null) { 334 if (possibleName.getLocale() 335 .getLanguage() 336 .equals(desiredLanguage)) { 337 bestMatch = possibleName; 338 } 339 } 340 } 329 341 } 330 331 //no name with the given locale was found. 332 // return null if exact match desired 342 333 343 if (exact) { 334 log.warn("No concept name found for concept id " + conceptId + " for locale " + loc); 335 return null; 344 if (bestMatch == null) 345 log.warn("No concept name found for concept id " + conceptId 346 + " for locale " + locale.toString()); 347 return bestMatch; 336 348 } 337 338 // returning default name locale ("en") if exact match not desired 339 if (defaultName == null) 340 log.warn("No concept name found for default locale for concept id " + conceptId); 341 349 350 if (bestMatch != null) 351 return bestMatch; 352 353 log.warn("No compatible concept name found for default locale for concept id " 354 + conceptId); 355 356 if (defaultName == null) { 357 log.error("No concept names exist for concept id: " + conceptId); 358 } 359 342 360 return defaultName; 343 361 } 344 362 … … 420 438 * @return Collection of ConceptSynonym attributed to the Concept in the given locale 421 439 */ 422 440 public Collection<ConceptSynonym> getSynonyms(Locale locale) { 423 String loc= locale.getLanguage().substring(0, 2);441 String conceptLanguage = locale.getLanguage().substring(0, 2); 424 442 Collection<ConceptSynonym> syns = new Vector<ConceptSynonym>(); 425 443 for (ConceptSynonym syn : getSynonyms()) { 426 String lang = syn.getLocale();427 if ( lang == null) lang = "en";428 if ( lang.equals(loc))444 String synLanguage = syn.getLocale().getLanguage().substring(0, 2); 445 if (synLanguage == null) synLanguage = Context.getLocale().getLanguage().substring(0, 2); 446 if (synLanguage.equals(conceptLanguage)) 429 447 syns.add(syn); 430 448 } 431 449 log.debug("returning: " + syns); -
src/api/org/openmrs/api/db/ConceptDAO.java
old new 212 212 /** 213 213 * Searches on given phrase via the concept word table 214 214 * @param phrase/search/words String 215 * @param locale Locale215 * @param locales Locales to include in search 216 216 * @param includeRetired boolean 217 217 * @param requireClasses List<ConceptClass> 218 218 * @param excludeClasses List<ConceptClass> … … 220 220 * @param excludeDatatypes List<ConceptDatatype> 221 221 * @return 222 222 */ 223 public List<ConceptWord> findConcepts(String phrase, L ocale locale, boolean includeRetired,223 public List<ConceptWord> findConcepts(String phrase, List<Locale> locales, boolean includeRetired, 224 224 List<ConceptClass> requireClasses, List<ConceptClass> excludeClasses, 225 225 List<ConceptDatatype> requireDatatypes, List<ConceptDatatype> excludeDatatypes); 226 226 -
src/api/org/openmrs/api/db/hibernate/HibernateConceptDAO.java
old new 14 14 package org.openmrs.api.db.hibernate; 15 15 16 16 import java.math.BigInteger; 17 import java.util.ArrayList; 17 18 import java.util.Date; 18 19 import java.util.Iterator; 19 20 import java.util.List; … … 499 500 } 500 501 501 502 // TODO below are functions worthy of a second tier 502 503 503 504 /** 504 505 * @see org.openmrs.api.db.ConceptService#findConcepts(java.lang.String,java.util.Locale,boolean) 505 506 */ 506 507 @SuppressWarnings("unchecked") 507 public List<ConceptWord> findConcepts(String phrase, L ocale loc, boolean includeRetired,508 public List<ConceptWord> findConcepts(String phrase, List<Locale> locales, boolean includeRetired, 508 509 List<ConceptClass> requireClasses, List<ConceptClass> excludeClasses, 509 510 List<ConceptDatatype> requireDatatypes, List<ConceptDatatype> excludeDatatypes) 510 511 { 511 String locale = loc.getLanguage().substring(0, 2); //only get language portion of locale512 512 513 List<String> words = ConceptWord.getUniqueWords(phrase); //assumes getUniqueWords() removes quote(') characters. (otherwise we would have a security leak) 513 514 514 515 List<ConceptWord> conceptWords = new Vector<ConceptWord>(); 515 516 516 517 if (words.size() > 0) { 517 518 518 519 Criteria searchCriteria = sessionFactory.getCurrentSession().createCriteria(ConceptWord.class, "cw1"); 519 searchCriteria.add(Restrictions.eq("locale", locale)); 520 searchCriteria.add(Expression.in("locale", locales)); 521 // searchCriteria.add(Restrictions.eq("locale", locale)); 520 522 if (includeRetired == false) { 521 523 searchCriteria.createAlias("concept", "concept"); 522 524 searchCriteria.add(Expression.eq("concept.retired", false)); … … 531 533 .setProjection(Property.forName("concept")) 532 534 .add(Expression.eqProperty("concept", "cw1.concept")) 533 535 .add(Restrictions.like("word", w, MatchMode.START)) 534 .add( Restrictions.eq("locale", locale));536 .add(Expression.in("locale", locales)); 535 537 junction.add(Subqueries.exists(crit)); 536 538 } 537 539 searchCriteria.add(junction); … … 560 562 561 563 return conceptWords; 562 564 } 565 563 566 564 567 /** 565 568 * @see org.openmrs.api.db.ConceptService#findConcepts(java.lang.String,java.util.Locale,org.openmrs.Concept,boolean) -
src/api/org/openmrs/api/ConceptService.java
old new 350 350 List<ConceptClass> requireClasses, List<ConceptClass> excludeClasses, 351 351 List<ConceptDatatype> requireDatatypes,List<ConceptDatatype> excludeDatatypes); 352 352 353 353 354 /** 355 * Searches on given phrase via the concept word table within a sorted list of Locales 354 356 * 357 * @param phrase/search/words 358 * String 359 * @param searchLocales 360 * ordered List of Locales within which to search 361 * @param includeRetired 362 * boolean 363 * @param requireClasses 364 * List<ConceptClass> 365 * @param excludeClasses 366 * List<ConceptClass> 367 * @param requireDatatypes 368 * List<ConceptDatatype> 369 * @param excludeDatatypes 370 * List<ConceptDatatype> 371 * @return 372 * 373 * @see ConceptService.findConcepts(String,Locale,boolean) 374 */ 375 @Transactional(readOnly=true) 376 @Authorized({"View Concepts"}) 377 public List<ConceptWord> findConcepts(String phrase, List<Locale> searchLocales, boolean includeRetired, 378 List<ConceptClass> requireClasses, List<ConceptClass> excludeClasses, 379 List<ConceptDatatype> requireDatatypes,List<ConceptDatatype> excludeDatatypes); 380 381 /** 382 * 355 383 * Finds concepts but only returns the given range 356 384 * 357 385 * @param phrase -
src/api/org/openmrs/api/impl/AdministrationServiceImpl.java
old new 584 584 585 585 Context.getConceptService().checkIfLocked(); 586 586 587 int count = 0; 588 for (Concept concept : Context.getConceptService().getConceptsByName("")) { 589 updateConceptWord(concept); 590 if (count++ > 1000) { 591 Context.clearSession(); 592 count = 0; 593 } 587 // Run the operation in batches 588 ConceptService cs = Context.getConceptService(); 589 int batchStartId = 0; 590 int endId = cs.getNextAvailableId(); 591 int batchSize = 1000; 592 593 while (batchStartId < endId) 594 { 595 updateConceptWords(batchStartId, batchStartId + batchSize); 596 Context.clearSession(); 597 batchStartId += batchSize; 594 598 } 595 599 596 600 } -
src/api/org/openmrs/api/impl/ConceptServiceImpl.java
old new 476 476 requireDatatypes = new Vector<ConceptDatatype>(); 477 477 if (excludeDatatypes == null) 478 478 excludeDatatypes = new Vector<ConceptDatatype>(); 479 480 List<Locale> searchLocales = new ArrayList<Locale>(); 481 searchLocales.add(locale); 479 482 480 483 List<ConceptWord> conceptWords = getConceptDAO().findConcepts(phrase, 481 locale, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes);484 searchLocales, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes); 482 485 483 486 return weightWords(phrase, locale, conceptWords); 484 487 } 485 488 486 489 /** 490 * @see org.openmrs.api.ConceptService#findConcepts(java.lang.String, java.util.List, boolean, java.util.List, java.util.List, java.util.List, java.util.List) 491 */ 492 public List<ConceptWord> findConcepts(String phrase, 493 List<Locale> searchLocales, boolean includeRetired, 494 List<ConceptClass> requireClasses, 495 List<ConceptClass> excludeClasses, 496 List<ConceptDatatype> requireDatatypes, 497 List<ConceptDatatype> excludeDatatypes) { 498 499 if (requireClasses == null) 500 requireClasses = new Vector<ConceptClass>(); 501 if (excludeClasses == null) 502 excludeClasses = new Vector<ConceptClass>(); 503 if (requireDatatypes == null) 504 requireDatatypes = new Vector<ConceptDatatype>(); 505 if (excludeDatatypes == null) 506 excludeDatatypes = new Vector<ConceptDatatype>(); 507 508 List<ConceptWord> conceptWords = getConceptDAO(). 509 findConcepts(phrase, searchLocales, includeRetired, requireClasses, 510 excludeClasses, requireDatatypes, excludeDatatypes); 511 512 return weightWords(phrase, searchLocales, conceptWords); 513 } 514 515 /** 487 516 * 488 517 * Finds concepts but only returns the given range 489 518 * … … 529 558 530 559 /** 531 560 * This will weight and sort the concepts we are assuming the hits are 532 * sorted with synonym matches at the bottom 561 * sorted with synonym matches at the bottom. 533 562 * 563 * @deprecated use weightWords() with multiple locales instead 564 * 534 565 * @param phrase 535 566 * that was used to get this search 536 567 * @param locale … … 540 571 */ 541 572 protected List<ConceptWord> weightWords(String phrase, Locale locale, 542 573 List<ConceptWord> conceptWords) { 574 List<Locale> locales = new ArrayList<Locale>(); 575 locales.add(locale); 576 return weightWords(phrase, locales, conceptWords); 577 } 578 579 /** 580 * This will weight and sort the concepts we are assuming the hits are 581 * sorted with synonym matches at the bottom 582 * 583 * @param phrase 584 * that was used to get this search 585 * @param locales 586 * that were used to get this search 587 * @param conceptWords 588 * @return 589 */ 590 protected List<ConceptWord> weightWords(String phrase, List<Locale> locales, 591 List<ConceptWord> conceptWords) { 543 592 544 593 // Map<ConceptId, ConceptWord> 545 594 Map<Integer, ConceptWord> uniqueConcepts = new HashMap<Integer, ConceptWord>(); … … 564 613 // check synonym in case we have multiple synonym hits 565 614 String toSplit = initialWord.getSynonym(); 566 615 if (toSplit == null || toSplit.equals("")) { 567 ConceptName cn = initialWord.getConcept().getName(locale); 568 toSplit = cn.getName(); 616 ConceptName cn = null; 617 // find which locale provided the concept name 618 for (Locale locale : locales) { 619 cn = initialWord.getConcept().getName(locale); 620 if (cn != null) { 621 toSplit = cn.getName(); 622 break; 623 } 624 } 569 625 } 570 626 List<String> nameWords = ConceptWord.getUniqueWords(toSplit); 571 627 … … 593 649 if (matchedString.length() == 0) { 594 650 // We weight name matches higher 595 651 tmpWord.increaseWeight(2.0); 596 matchedString = tmpWord.getConcept().getName(locale) 597 .getName(); 652 for (Locale locale : locales) { 653 ConceptName cn = tmpWord.getConcept().getName(locale); 654 if (cn != null) { 655 matchedString = cn.getName(); 656 break; 657 } 658 } 598 659 } 599 660 600 661 // increase the weight by a factor of the % of words matched -
src/web/org/openmrs/web/OptionsForm.java
old new 17 17 18 18 private String defaultLocation = ""; 19 19 private String defaultLocale = ""; 20 private String proficientLocales = ""; 20 21 private Boolean showRetiredMessage = true; 21 22 private Boolean verbose = false; 22 23 … … 160 161 this.verbose = verbose; 161 162 } 162 163 163 164 /** 165 * Sets the locales within which the user is proficient. 166 * 167 * @param proficientLocales a comma-separated list of locales 168 */ 169 public void setProficientLocales(String proficientLocales) { 170 this.proficientLocales = proficientLocales; 171 } 164 172 173 /** 174 * Returns the locales within which the user is proficient. 175 * 176 */ 177 public String getProficientLocales() { 178 return proficientLocales; 179 } 180 165 181 } -
src/web/org/openmrs/web/controller/OptionsFormController.java
old new 29 29 import org.openmrs.api.EncounterService; 30 30 import org.openmrs.api.UserService; 31 31 import org.openmrs.api.context.Context; 32 import org.openmrs.util.LocaleFactory; 32 33 import org.openmrs.util.OpenmrsConstants; 33 34 import org.openmrs.web.OptionsForm; 34 35 import org.openmrs.web.WebConstants; … … 101 102 102 103 properties.put(OpenmrsConstants.USER_PROPERTY_DEFAULT_LOCATION, opts.getDefaultLocation()); 103 104 properties.put(OpenmrsConstants.USER_PROPERTY_DEFAULT_LOCALE, opts.getDefaultLocale()); 105 properties.put(OpenmrsConstants.USER_PROPERTY_PROFICIENT_LOCALES, opts.getProficientLocales()); 104 106 properties.put(OpenmrsConstants.USER_PROPERTY_SHOW_RETIRED, opts.getShowRetiredMessage().toString()); 105 107 properties.put(OpenmrsConstants.USER_PROPERTY_SHOW_VERBOSE, opts.getVerbose().toString()); 106 108 properties.put(OpenmrsConstants.USER_PROPERTY_NOTIFICATION, opts.getNotification() == null ? "" : opts.getNotification().toString()); … … 197 199 Map<String, String> props = user.getUserProperties(); 198 200 opts.setDefaultLocation(props.get(OpenmrsConstants.USER_PROPERTY_DEFAULT_LOCATION)); 199 201 opts.setDefaultLocale(props.get(OpenmrsConstants.USER_PROPERTY_DEFAULT_LOCALE)); 202 opts.setProficientLocales(props.get(OpenmrsConstants.USER_PROPERTY_PROFICIENT_LOCALES)); 200 203 opts.setShowRetiredMessage(new Boolean(props.get(OpenmrsConstants.USER_PROPERTY_SHOW_RETIRED))); 201 204 opts.setVerbose(new Boolean(props.get(OpenmrsConstants.USER_PROPERTY_SHOW_VERBOSE))); 202 205 opts.setUsername(user.getUsername()); -
src/web/org/openmrs/web/dwr/ConceptListItem.java
old new 52 52 if (word != null) { 53 53 54 54 Concept concept = word.getConcept(); 55 Locale locale = new Locale(word.getLocale());55 Locale locale = word.getLocale(); 56 56 initialize(concept, locale); 57 57 synonym = word.getSynonym(); 58 58 } -
src/web/org/openmrs/web/dwr/DWRConceptService.java
old new 75 75 76 76 log.info(userId + "|" + phrase + "|" + includeClassNames.toString()); 77 77 78 Locale locale = Context.getLocale(); 78 Locale defaultLocale = Context.getLocale(); 79 List<Locale> searchLocales = u.getProficientLocales(); 80 if (searchLocales.size() == 0) { 81 searchLocales.add(defaultLocale); 82 83 // if country is specified, also add the generic language locale 84 if (defaultLocale.getCountry() != "") { 85 searchLocales.add(new Locale(defaultLocale.getLanguage())); 86 } 87 88 } 89 StringBuffer searchLocalesString = new StringBuffer(); 90 for (Locale loc : searchLocales) { 91 searchLocalesString.append(loc.toString() + " "); 92 } 93 log.info("searching locales: " + searchLocalesString); 94 79 95 if (includeClassNames == null) 80 96 includeClassNames = new Vector<String>(); 81 97 if (excludeClassNames == null) … … 94 110 // corresponding conceptId 95 111 Concept c = cs.getConcept(Integer.valueOf(phrase)); 96 112 if (c != null) { 97 ConceptWord word = new ConceptWord(phrase, c, locale 98 .getLanguage(), "Concept Id #" + phrase); 113 ConceptWord word = new ConceptWord(phrase, c, defaultLocale, "Concept Id #" + phrase); 99 114