/** * Finds the description of the concept in the given locale. Returns null if none found. * * @param locale * @return ConceptDescription attributed to the Concept in the given locale */ public ConceptDescription getDescription(Locale locale) { return getDescription(locale, false); }
/** * Finds the description of the concept using the current locale in Context.getLocale(). Returns * null if none found. * * @return ConceptDescription attributed to the Concept in the given locale */ public ConceptDescription getDescription() { return getDescription(Context.getLocale()); }
/** * Get the concept description that is tied to the concept name that was used when making this * observation * * @return ConceptDescription the description used */ public ConceptDescription getConceptDescription() { // if we don't have a question for this concept, // then don't bother looking for a description if (getConcept() == null) { return null; } // ABKTOD: description in which locale? return concept.getDescription(); }
/** * @see org.openmrs.BaseOpenmrsMetadata#getName() */ @Override public String getDescription() { if (getConcept() != null && getConcept().getDescription() != null) { return getConcept().getDescription().getDescription(); } return null; }
/** * @see Concept#getDescription(Locale,null) */ @Test public void getDescription_shouldNotReturnLanguageOnlyMatchForExactMatches() { Concept mockConcept = new Concept(); mockConcept.addDescription(new ConceptDescription("en desc", new Locale("en"))); Assert.assertNull(mockConcept.getDescription(new Locale("en", "US"), true)); }
/** * @see Concept#getDescription(Locale,null) */ @Test public void getDescription_shouldReturnMatchOnLanguageOnly() { Concept mockConcept = new Concept(); mockConcept.addDescription(new ConceptDescription("en desc", new Locale("en"))); Assert.assertEquals("en desc", mockConcept.getDescription(new Locale("en", "US"), false).getDescription()); }
/** * @see Concept#getDescription(Locale,null) */ @Test public void getDescription_shouldReturnMatchOnLocaleExactly() { Concept mockConcept = new Concept(); mockConcept.addDescription(new ConceptDescription("en_US desc", new Locale("en", "US"))); Assert.assertEquals("en_US desc", mockConcept.getDescription(new Locale("en", "US"), false).getDescription()); }
/** * @see Concept#getDescription(Locale,null) */ @Test public void getDescription_shouldNotReturnMatchOnLanguageOnlyIfExactMatchExists() { Concept mockConcept = new Concept(); mockConcept.addDescription(new ConceptDescription("en desc", new Locale("en"))); mockConcept.addDescription(new ConceptDescription("en_US desc", new Locale("en", "US"))); Concept mockConcept2 = new Concept(); mockConcept2.addDescription(new ConceptDescription("en_US desc", new Locale("en", "US"))); mockConcept2.addDescription(new ConceptDescription("en desc", new Locale("en"))); Assert.assertEquals("en_US desc", mockConcept.getDescription(new Locale("en", "US"), false).getDescription()); Assert.assertEquals("en_US desc", mockConcept2.getDescription(new Locale("en", "US"), false).getDescription()); }
public String getChildrenString(Concept concept, Set<Concept> children ){ ArrayList<String> returnedStrings = new ArrayList<>(); for (Concept node : children){ String nodeString = getPath(node, hierarchy.getChildrens(node), entity, hierarchy); returnedStrings.add(nodeString); } StringBuilder fullList = new StringBuilder(); for (String s: returnedStrings){ fullList.append(s+""); } return "{'id':" + concept.getId() + "," + "'title':'" + concept.getDescription() + "'," + "'nodes':[" + fullList.toString() + "]}"; }
/** * @see ConceptService#saveConcept(Concept) */ @Test public void saveConcept_shouldSetAuditInfoIfAnyItemInTheChildCollectionsIsEdited() { Concept concept = conceptService.getConcept(3); Assert.assertNull(concept.getDateChanged()); Assert.assertNull(concept.getChangedBy()); ConceptDescription description = concept.getDescription(); Assert.assertNotNull(description); description.setDescription("changed to something else"); conceptService.saveConcept(concept); Assert.assertNotNull(concept.getDateChanged()); Assert.assertNotNull(concept.getChangedBy()); }