Downloads Documentation Community Contribute Demo






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

Merging trunk to api-refactoring [4191]:[4230]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs/branches/api_refactoring/src/api/org/openmrs/api/impl/ConceptServiceImpl.java

    r4198 r4231  
    421421         * @see org.openmrs.api.ConceptService#getConcepts(java.lang.String, java.util.Locale, boolean, java.util.List, java.util.List, java.util.List, java.util.List, int, int) 
    422422         */ 
    423         public List<ConceptWord> getConcepts(String phrase, Locale locale, boolean includeRetired,  
     423        public List<ConceptWord> getConcepts(String phrase, List<Locale> locales, boolean includeRetired,  
    424424                                                List<ConceptClass> requireClasses, List<ConceptClass> excludeClasses, 
    425425                                                List<ConceptDatatype> requireDatatypes,List<ConceptDatatype> excludeDatatypes, 
    426426                                                Integer start, Integer size){ 
    427427                 
    428                 return getConceptDAO().getConcepts(phrase, locale, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes, start, size); 
     428                return getConceptDAO().getConcepts(phrase, locales, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes, start, size); 
    429429        } 
    430430         
     
    443443        public List<ConceptWord> findConcepts(String phrase, Locale locale, 
    444444                        boolean includeRetired, int start, int size) { 
    445                 List<ConceptWord> conceptWords = getConcepts(phrase, locale, 
     445                List<Locale> locales = new Vector<Locale>(); 
     446                locales.add(locale); 
     447                 
     448                List<ConceptWord> conceptWords = getConcepts(phrase, locales, 
    446449                                includeRetired, null, null, null, null, start, size); 
    447450                List<ConceptWord> subList = conceptWords.subList(start, start + size); 
     
    464467        public List<ConceptWord> findConcepts(String phrase, Locale locale, 
    465468                        boolean includeRetired) { 
    466                 return getConcepts(phrase, locale, includeRetired, null, null, null, null, null, null); 
     469                List<Locale> locales = new Vector<Locale>(); 
     470                locales.add(locale); 
     471                 
     472                return getConcepts(phrase, locales, includeRetired, null, null, null, null, null, null); 
    467473        } 
    468474 
     
    486492         * @return 
    487493         * @deprecated 
    488          * @see ConceptService.findConcepts(String,Locale,boolean) 
     494         * @see {@link ConceptService#getConcepts(String, Locale, boolean, List, List, List, List, Integer, Integer)} 
    489495         */ 
    490496        public List<ConceptWord> findConcepts(String phrase, Locale locale, boolean includeRetired,  
     
    501507                        excludeDatatypes = new Vector<ConceptDatatype>(); 
    502508                 
     509                List<Locale> locales = new Vector<Locale>(); 
     510                locales.add(locale); 
     511                 
    503512                List<ConceptWord> conceptWords = getConceptDAO().getConcepts(phrase, 
    504                                 locale, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes, null, null); 
    505  
    506                 return weightWords(phrase, locale, conceptWords); 
     513                                locales, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes, null, null); 
     514                 
     515                return weightWords(phrase, locales, conceptWords); 
    507516        } 
    508517         
     
    10021011        public List<ConceptWord> findConceptAnswers(String phrase, Locale locale, 
    10031012                        Concept concept, boolean includeRetired) { 
     1013                 
    10041014                List<ConceptWord> conceptWords = getConceptDAO().findConceptAnswers( 
    10051015                                phrase, locale, concept, includeRetired); 
    1006  
    1007                 return weightWords(phrase, locale, conceptWords); 
     1016                 
     1017                List<Locale> locales = new Vector<Locale>(); 
     1018                locales.add(locale); 
     1019                 
     1020                return weightWords(phrase, locales, conceptWords); 
    10081021 
    10091022        } 
     
    12551268         * @return 
    12561269         */ 
    1257         protected List<ConceptWord> weightWords(String phrase, Locale locale
     1270        protected List<ConceptWord> weightWords(String phrase, List<Locale> locales
    12581271                        List<ConceptWord> conceptWords) { 
    12591272 
     
    12811294                                String toSplit = initialWord.getSynonym(); 
    12821295                                if (toSplit == null || toSplit.equals("")) { 
    1283                                         ConceptName cn = initialWord.getConcept().getName(locale); 
    1284                                         toSplit = cn.getName(); 
     1296                                        ConceptName cn = null; 
     1297                                        // find which locale provided the concept name 
     1298                                        for (Locale locale : locales) { 
     1299                                                cn = initialWord.getConcept().getName(locale); 
     1300                                                if (cn != null) { 
     1301                                                        toSplit = cn.getName(); 
     1302                                                        break; 
     1303                                                } 
     1304                                        } 
    12851305                                } 
    12861306                                List<String> nameWords = ConceptWord.getUniqueWords(toSplit); 
     
    13101330                                        // We weight name matches higher 
    13111331                                        tmpWord.increaseWeight(2.0); 
    1312                                         matchedString = tmpWord.getConcept().getName(locale) 
    1313                                                         .getName(); 
     1332                                        for (Locale locale : locales) { 
     1333                                                ConceptName cn = tmpWord.getConcept().getName(locale); 
     1334                                                if (cn != null) { 
     1335                                                        matchedString = cn.getName(); 
     1336                                                        break; 
     1337                                                } 
     1338                                        } 
    13141339                                } 
    13151340