Tabnine Logo
AdministrationService.getPresentationLocales
Code IndexAdd Tabnine to your IDE (free)

How to use
getPresentationLocales
method
in
org.openmrs.api.AdministrationService

Best Java code snippets using org.openmrs.api.AdministrationService.getPresentationLocales (Showing top 7 results out of 315)

origin: openmrs/openmrs-core

@Test
@Ignore
//TODO: This test fails for some reason
public void getPresentationLocales_shouldReturnAtLeastOneLocaleIfNoLocalesDefinedInDatabaseYet() {
  assertTrue(adminService.getPresentationLocales().size() > 0);
}

origin: openmrs/openmrs-core

@Test
public void getPresentationLocales_shouldNotReturnMoreLocalesThanMessageSourceServiceLocales() {
  assertFalse(adminService.getPresentationLocales().size() > Context
      .getMessageSourceService().getLocales().size());
}

origin: openmrs/openmrs-core

@Test
public void getPresentationLocales_shouldReturnAllCountryLocalesIfLanguageLocaleAndNoCountryLocalesAreSpecifiedInAllowedList()
    {
  adminService.saveGlobalProperty(
    new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, "en_GB, es"));
  
  List<Locale> locales = new ArrayList<>();
  locales.add(new Locale("pl", "PL"));
  locales.add(new Locale("en"));
  locales.add(new Locale("es"));
  locales.add(new Locale("es", "CL"));
  locales.add(new Locale("es", "SN"));
  
  MutableResourceBundleMessageSource mutableResourceBundleMessageSource = Mockito
      .mock(MutableResourceBundleMessageSource.class);
  Mockito.when(mutableResourceBundleMessageSource.getLocales()).thenReturn(locales);
  
  MutableMessageSource mutableMessageSource = Context.getMessageSourceService().getActiveMessageSource();
  Context.getMessageSourceService().setActiveMessageSource(mutableResourceBundleMessageSource);
  
  Set<Locale> presentationLocales = adminService.getPresentationLocales();
  
  Context.getMessageSourceService().setActiveMessageSource(mutableMessageSource);
  
  assertEquals(3, presentationLocales.size());
  assertTrue("es_CL", presentationLocales.contains(new Locale("es", "CL")));
  assertTrue("es_SN", presentationLocales.contains(new Locale("es", "SN")));
  assertTrue("en", presentationLocales.contains(new Locale("en")));
}

origin: openmrs/openmrs-core

@Test
public void getPresentationLocales_shouldReturnOnlyCountryLocaleIfBothCountryLocaleAndLanguageLocaleAreSpecifiedInAllowedList()
    {
  adminService.saveGlobalProperty(
    new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, "en_GB, es, es_CL"));
  
  List<Locale> locales = new ArrayList<>();
  locales.add(new Locale("pl", "PL"));
  locales.add(new Locale("en"));
  locales.add(new Locale("es"));
  locales.add(new Locale("es", "CL"));
  
  MutableResourceBundleMessageSource mutableResourceBundleMessageSource = Mockito
      .mock(MutableResourceBundleMessageSource.class);
  Mockito.when(mutableResourceBundleMessageSource.getLocales()).thenReturn(locales);
  
  MutableMessageSource mutableMessageSource = Context.getMessageSourceService().getActiveMessageSource();
  Context.getMessageSourceService().setActiveMessageSource(mutableResourceBundleMessageSource);
  
  Set<Locale> presentationLocales = adminService.getPresentationLocales();
  
  Context.getMessageSourceService().setActiveMessageSource(mutableMessageSource);
  
  assertEquals(2, presentationLocales.size());
  assertTrue("en", presentationLocales.contains(new Locale("en")));
  assertTrue("es_CL", presentationLocales.contains(new Locale("es", "CL")));
}

origin: openmrs/openmrs-core

@Test
public void getPresentationLocales_shouldReturnLanguageLocaleIfCountryLocaleIsSpecifiedInAllowedListButCountryLocaleMessageFileIsMissing()
    {
  adminService.saveGlobalProperty(
    new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, "en_GB, es_CL"));
  
  List<Locale> locales = new ArrayList<>();
  locales.add(new Locale("pl", "PL"));
  locales.add(new Locale("en"));
  locales.add(new Locale("es"));
  
  MutableResourceBundleMessageSource mutableResourceBundleMessageSource = Mockito
      .mock(MutableResourceBundleMessageSource.class);
  Mockito.when(mutableResourceBundleMessageSource.getLocales()).thenReturn(locales);
  
  MutableMessageSource mutableMessageSource = Context.getMessageSourceService().getActiveMessageSource();
  Context.getMessageSourceService().setActiveMessageSource(mutableResourceBundleMessageSource);
  
  Set<Locale> presentationLocales = adminService.getPresentationLocales();
  
  Context.getMessageSourceService().setActiveMessageSource(mutableMessageSource);
  
  assertEquals(2, presentationLocales.size());
  assertTrue("en", presentationLocales.contains(new Locale("en")));
  assertTrue("es", presentationLocales.contains(new Locale("es")));
}

origin: openmrs/openmrs-core

Context.getMessageSourceService().setActiveMessageSource(mutableResourceBundleMessageSource);
List<Locale> presentationLocales = new ArrayList<>(adminService.getPresentationLocales());
origin: openmrs/openmrs-core

@Test
public void getPresentationLocales_shouldReturnLanguageLocaleIfItIsSpecifiedInAllowedListAndThereAreNoCountryLocaleMessageFilesAvailable()
    {
  adminService.saveGlobalProperty(
    new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST, "en_GB, es"));
  
  List<Locale> locales = new ArrayList<>();
  locales.add(new Locale("pl", "PL"));
  locales.add(new Locale("en"));
  locales.add(new Locale("es"));
  
  MutableResourceBundleMessageSource mutableResourceBundleMessageSource = Mockito
      .mock(MutableResourceBundleMessageSource.class);
  Mockito.when(mutableResourceBundleMessageSource.getLocales()).thenReturn(locales);
  
  MutableMessageSource mutableMessageSource = Context.getMessageSourceService().getActiveMessageSource();
  Context.getMessageSourceService().setActiveMessageSource(mutableResourceBundleMessageSource);
  
  Set<Locale> presentationLocales = adminService.getPresentationLocales();
  
  Context.getMessageSourceService().setActiveMessageSource(mutableMessageSource);
  
  assertEquals(2, presentationLocales.size());
  assertTrue("en", presentationLocales.contains(new Locale("en")));
  assertTrue("es", presentationLocales.contains(new Locale("es")));
}

org.openmrs.apiAdministrationServicegetPresentationLocales

Javadoc

Gets the list of locales for which localized messages are available for the user interface (presentation layer). This set includes all the available locales (as indicated by the MessageSourceService) filtered by the allowed locales (as indicated by this AdministrationService).

Popular methods of AdministrationService

  • saveGlobalProperty
    Save the given global property to the database
  • getGlobalProperty
    Gets the global property that has the given propertyName If propertyName is not found in the list of
  • getGlobalPropertyObject
    Gets the global property that has the given propertyName
  • getAllGlobalProperties
    Get a list of all global properties in the system
  • getAllowedLocales
    Gets the list of locales which the administrator has allowed for use on the system. This is specifie
  • executeSQL
    Runs the sql on the database. If selectOnly is flagged then any non-select sql statements will be re
  • getGlobalPropertiesByPrefix
    Gets all global properties that begin with prefix.
  • getGlobalPropertyByUuid
    Get a global property by its uuid. There should be only one of these in the database (well, in the w
  • getGlobalPropertyValue
    Returns a global property according to the type specified
  • purgeGlobalProperty
    Completely remove the given global property from the database
  • addGlobalPropertyListener
    Allows code to be notified when a global property is created/edited/deleted.
  • getSearchLocales
    Returns a list of locales used by the user when searching.
  • addGlobalPropertyListener,
  • getSearchLocales,
  • getSystemVariables,
  • setGlobalProperty,
  • setImplementationId,
  • validate,
  • getGlobalPropertiesBySuffix,
  • getImplementationId,
  • getMaximumPropertyLength

Popular in Java

  • Finding current android device location
  • putExtra (Intent)
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now