/** * Convenience constructor to create a ConceptStopWord object with default * locale English * * @param value */ public ConceptStopWord(String value) { this(value, Context.getLocale()); }
/** * Gets the simple date format for the current user's locale. The format will be similar in size * to mm/dd/yyyy * * @return SimpleDateFormat for the user's current locale * @see org.openmrs.util.OpenmrsUtil#getDateFormat(Locale) * @should return a pattern with four y characters in it */ public static SimpleDateFormat getDateFormat() { return OpenmrsUtil.getDateFormat(getLocale()); }
/** * Gets the simple datetime format for the current user's locale. The format will be similar to * mm/dd/yyyy hh:mm a * * @return SimpleDateFormat for the user's current locale * @see org.openmrs.util.OpenmrsUtil#getDateTimeFormat(Locale) * @should return a pattern with four y characters and two h characters in it */ public static SimpleDateFormat getDateTimeFormat() { return OpenmrsUtil.getDateTimeFormat(getLocale()); }
/** * Delegates to {@link EncounterVisitHandler#getDisplayName(java.util.Locale)} with * {@link Context#getLocale()} as a parameter. * * @return a displayable string so that users can pick between different assignment handlers */ @Override public String getDisplayName() { return getDisplayName(Context.getLocale()); }
/** * @see org.openmrs.api.db.ConceptDAO#getConceptStopWords(java.util.Locale) */ @Override public List<String> getConceptStopWords(Locale locale) throws DAOException { locale = (locale == null ? Context.getLocale() : locale); Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ConceptStopWord.class); criteria.setProjection(Projections.property("value")); criteria.add(Restrictions.eq("locale", locale)); return (List<String>) criteria.list(); }
private void validateModuleConfigVersion(String version, File moduleFile) { if (!validConfigVersions.contains(version)) { throw new ModuleException(Context.getMessageSourceService().getMessage("Module.error.invalidConfigVersion", new Object[] { version, String.join(", ", validConfigVersions) }, Context.getLocale()), moduleFile.getName()); } }
/** * Gets the error message of cyclic dependencies between modules * * @return the message text. */ private static String getCyclicDependenciesMessage(String message) { return Context.getMessageSourceService().getMessage("Module.error.cyclicDependencies", new Object[]{ message }, Context.getLocale()); }
/** * @see AdministrationService#getSearchLocales() */ @Override @Transactional(readOnly = true) public List<Locale> getSearchLocales(){ //call it via interface, so cache interceptor is invoked return Context.getAdministrationService().getSearchLocales(Context.getLocale(), Context.getAuthenticatedUser()); }
@Test public void setBlankShortName_shouldVoidTheOldOne() { Concept concept = new Concept(); ConceptName cn = new ConceptName("some name", Context.getLocale()); ConceptName FullySpecName = new ConceptName("fully spec name", Context.getLocale()); concept.addName(FullySpecName); concept.setShortName(cn); concept.setShortName(new ConceptName(" ", Context.getLocale())); assertThat(concept.getShortNameInLocale(Context.getLocale()), is(nullValue())); }
/** * @see Concept#addName(ConceptName) */ @Test public void addName_shouldMarkTheFirstNameAddedAsFullySpecified() { Concept concept = new Concept(); concept.addName(new ConceptName("some name", Context.getLocale())); Assert.assertEquals("some name", concept.getFullySpecifiedName(Context.getLocale()).getName()); }
/** * @see Concept#getShortestName(Locale,Boolean) */ @Test public void getShortestName_shouldReturnNullIfTheirAreNoNamesInTheSpecifiedLocaleAndExactIsTrue() { Concept concept = new Concept(); concept.addName(new ConceptName("shortName123", Context.getLocale())); concept.addName(new ConceptName("shortName12", Context.getLocale())); concept.addName(new ConceptName("shortName1", Locale.US)); Assert.assertNull(concept.getShortestName(new Locale("fr"), true)); }
/** * @see Concept#getShortestName(Locale,Boolean) */ @Test public void getShortestName_shouldReturnTheShortestNameInAGivenLocaleForAConceptIfExactIsTrue() { Concept concept = new Concept(); concept.addName(new ConceptName("shortName123", Context.getLocale())); concept.addName(new ConceptName("shortName12", Context.getLocale())); concept.addName(new ConceptName("shortName1", Locale.US)); concept.addName(new ConceptName("shortName", Locale.FRANCE)); Assert.assertEquals("shortName12", concept.getShortestName(Context.getLocale(), true).getName()); }
/** * @see Concept#getShortestName(Locale,Boolean) */ @Test public void getShortestName_shouldReturnTheShortestNameForTheConceptFromAnyLocaleIfExactIsFalse() { Concept concept = new Concept(); concept.addName(new ConceptName("shortName123", Context.getLocale())); concept.addName(new ConceptName("shortName12", Context.getLocale())); concept.addName(new ConceptName("shortName1", Locale.US)); concept.addName(new ConceptName("shortName", Locale.FRANCE)); Assert.assertEquals("shortName", concept.getShortestName(Context.getLocale(), false).getName()); }
private Cache.ValueWrapper getCacheForCurrentUser(){ Object[] params = { Context.getLocale(), Context.getAuthenticatedUser() }; Object key = (new SimpleKeyGenerator()).generate(null, null, params); return cacheManager.getCache("userSearchLocales").get(key); }
@Test public void notifySuperUsers_shouldAddAnAlertWithMessageTextIfCauseIsNull() { Context.getAlertService().notifySuperUsers("Module.startupError.notification.message", null, "test"); Alert lastAlert = Context.getAlertService().getAlertsByUser(null).iterator().next(); String expectedText = Context.getMessageSourceService().getMessage("Module.startupError.notification.message", new Object[] { "test" }, Context.getLocale()); Assert.assertEquals(expectedText, lastAlert.getText()); }
@Test public void validate_shouldFailIfAnyNameIsAnEmptyString() { concept.addDescription(new ConceptDescription("some description", null)); concept.setConceptClass(new ConceptClass(1)); concept.setDatatype(new ConceptDatatype(1)); concept.addName(new ConceptName("name", Context.getLocale())); concept.addName(new ConceptName("", Context.getLocale())); validator.validate(concept, errors); assertThat(errors, hasGlobalErrors("Concept.name.empty")); }
/** * @see Concept#getShortestName(Locale,Boolean) */ @Test public void getShortestName_shouldReturnTheNameMarkedAsTheShortNameForTheLocaleIfItIsPresent() { Concept concept = new Concept(); concept.addName(new ConceptName("shortName123", Context.getLocale())); concept.setShortName(new ConceptName("shortName12", Context.getLocale())); concept.setShortName(new ConceptName("shortName1", Locale.US)); Assert.assertEquals("shortName1", concept.getShortestName(Locale.US, null).getName()); }
/** * @see Concept#setFullySpecifiedName(ConceptName) */ @Test public void setFullySpecifiedName_shouldSetTheConceptNameTypeOfTheSpecifiedNameToFullySpecified() { Concept concept = new Concept(); ConceptName cn = new ConceptName("some name", Context.getLocale()); concept.setFullySpecifiedName(cn); Assert.assertEquals(ConceptNameType.FULLY_SPECIFIED, cn.getConceptNameType()); }
@Test public void validate_shouldFailIfTheConceptDatatypeIsNull() { concept.addName(new ConceptName("some name", Context.getLocale())); concept.addDescription(new ConceptDescription("some description", null)); concept.setConceptClass(new ConceptClass(1)); validator.validate(concept, errors); assertThat(errors, hasFieldErrors("datatype", "Concept.datatype.empty")); }
@Test public void validate_shouldPassIfNoneofTheConceptDescriptionsIsNull() { concept.addName(new ConceptName("some name",Context.getLocale())); concept.addDescription(new ConceptDescription("some description",null)); concept.setConceptClass(new ConceptClass()); concept.setDatatype(new ConceptDatatype()); validator.validate(concept, errors); Assert.assertFalse(errors.hasErrors()); }