Changeset 4231 for openmrs/branches/api_refactoring/src/api/org/openmrs/api/impl/ConceptServiceImpl.java
- Timestamp:
- 05/15/08 20:15:52 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs/branches/api_refactoring/src/api/org/openmrs/api/impl/ConceptServiceImpl.java
r4198 r4231 421 421 * @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) 422 422 */ 423 public List<ConceptWord> getConcepts(String phrase, L ocale locale, boolean includeRetired,423 public List<ConceptWord> getConcepts(String phrase, List<Locale> locales, boolean includeRetired, 424 424 List<ConceptClass> requireClasses, List<ConceptClass> excludeClasses, 425 425 List<ConceptDatatype> requireDatatypes,List<ConceptDatatype> excludeDatatypes, 426 426 Integer start, Integer size){ 427 427 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); 429 429 } 430 430 … … 443 443 public List<ConceptWord> findConcepts(String phrase, Locale locale, 444 444 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, 446 449 includeRetired, null, null, null, null, start, size); 447 450 List<ConceptWord> subList = conceptWords.subList(start, start + size); … … 464 467 public List<ConceptWord> findConcepts(String phrase, Locale locale, 465 468 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); 467 473 } 468 474 … … 486 492 * @return 487 493 * @deprecated 488 * @see ConceptService.findConcepts(String,Locale,boolean)494 * @see {@link ConceptService#getConcepts(String, Locale, boolean, List, List, List, List, Integer, Integer)} 489 495 */ 490 496 public List<ConceptWord> findConcepts(String phrase, Locale locale, boolean includeRetired, … … 501 507 excludeDatatypes = new Vector<ConceptDatatype>(); 502 508 509 List<Locale> locales = new Vector<Locale>(); 510 locales.add(locale); 511 503 512 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); 507 516 } 508 517 … … 1002 1011 public List<ConceptWord> findConceptAnswers(String phrase, Locale locale, 1003 1012 Concept concept, boolean includeRetired) { 1013 1004 1014 List<ConceptWord> conceptWords = getConceptDAO().findConceptAnswers( 1005 1015 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); 1008 1021 1009 1022 } … … 1255 1268 * @return 1256 1269 */ 1257 protected List<ConceptWord> weightWords(String phrase, L ocale locale,1270 protected List<ConceptWord> weightWords(String phrase, List<Locale> locales, 1258 1271 List<ConceptWord> conceptWords) { 1259 1272 … … 1281 1294 String toSplit = initialWord.getSynonym(); 1282 1295 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 } 1285 1305 } 1286 1306 List<String> nameWords = ConceptWord.getUniqueWords(toSplit); … … 1310 1330 // We weight name matches higher 1311 1331 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 } 1314 1339 } 1315 1340