public interface AdministrationService extends OpenmrsService
Use:
List<GlobalProperty> globalProperties = Context.getAdministrationService().getGlobalProperties();
Context
Modifier and Type | Field and Description |
---|---|
static String |
GP_SERIALIZER_WHITELIST_HIERARCHY_TYPES_PREFIX |
static String |
GP_SUFFIX_SERIALIZER_WHITELIST_TYPES |
Modifier and Type | Method and Description |
---|---|
void |
addGlobalPropertyListener(GlobalPropertyListener listener)
Allows code to be notified when a global property is created/edited/deleted.
|
List<List<Object>> |
executeSQL(String sql,
boolean selectOnly)
Runs the
sql on the database. |
List<GlobalProperty> |
getAllGlobalProperties()
Get a list of all global properties in the system
|
List<Locale> |
getAllowedLocales()
Gets the list of locales which the administrator has allowed for use on the system.
|
List<GlobalProperty> |
getGlobalPropertiesByPrefix(String prefix)
Gets all global properties that begin with
prefix . |
List<GlobalProperty> |
getGlobalPropertiesBySuffix(String suffix)
Gets all global properties that end with
suffix . |
String |
getGlobalProperty(String propertyName)
Gets the global property that has the given
propertyName . |
String |
getGlobalProperty(String propertyName,
String defaultValue)
Gets the global property that has the given
propertyName
If propertyName is not found in the list of Global Properties currently in the database, a
defaultValue is returned
This method should not have any authorization check |
GlobalProperty |
getGlobalPropertyByUuid(String uuid)
Get a global property by its uuid.
|
GlobalProperty |
getGlobalPropertyObject(String propertyName)
Gets the global property that has the given
propertyName |
<T> T |
getGlobalPropertyValue(String propertyName,
T defaultValue)
Returns a global property according to the type specified
|
ImplementationId |
getImplementationId()
Get the implementation id stored for this server Returns null if no implementation id has
been successfully set yet
|
int |
getMaximumPropertyLength(Class<? extends OpenmrsObject> aClass,
String fieldName) |
Set<Locale> |
getPresentationLocales()
Gets the list of locales for which localized messages are available for the user interface
(presentation layer).
|
List<Locale> |
getSearchLocales()
Returns a list of locales used by the user when searching.
|
List<Locale> |
getSearchLocales(Locale currentLocale,
User user)
Returns a list of locales used by the user when searching.
|
List<String> |
getSerializerWhitelistTypes()
Returns a list of packages and/or individual classes including hierarchy of OpenmrsObject, OpenmmrsMetadata,
OpenmrsData and other common OpenMRS classes as well as any whitelists defined through GPs with the
'.serializer.whitelist.types' suffix that are considered to be safe for deserializing.
|
Map<String,Map<String,String>> |
getSystemInformation()
Get a map of all the System Information.
|
SortedMap<String,String> |
getSystemVariables()
Get a listing or important variables used in openmrs
|
boolean |
isDatabaseStringComparisonCaseSensitive()
Reads a GP which specifies if database string comparison is case sensitive.
|
void |
purgeGlobalProperties(List<GlobalProperty> globalProperties)
Completely remove the given global properties from the database
|
void |
purgeGlobalProperty(GlobalProperty globalProperty)
Completely remove the given global property from the database
|
void |
removeGlobalPropertyListener(GlobalPropertyListener listener)
Removes a GlobalPropertyListener previously registered by
addGlobalPropertyListener(GlobalPropertyListener) |
List<GlobalProperty> |
saveGlobalProperties(List<GlobalProperty> props)
Save the given list of global properties to the database.
|
GlobalProperty |
saveGlobalProperty(GlobalProperty gp)
Save the given global property to the database
|
void |
setAdministrationDAO(AdministrationDAO dao)
Used by Spring to set the specific/chosen database access implementation
|
void |
setGlobalProperty(String propertyName,
String propertyValue)
Save the given global property to the database.
|
void |
setImplementationId(ImplementationId implementationId)
Set the given
implementationId as this implementation's unique id |
void |
setImplementationIdHttpClient(HttpClient implementationHttpClient)
Used by Spring to set the http client for accessing the openmrs implementation service
|
void |
updateGlobalProperty(String propertyName,
String propertyValue)
Overwrites the value of the global property if it already exists.
|
void |
updatePostgresSequence()
Unlike MySQL which uses identifier strategy, PostgreSQL follows sequence strategy
So as to bridge the gap between these two strategies, this method has been created.
|
void |
validate(Object object,
org.springframework.validation.Errors errors)
Performs validation in the manual flush mode to prevent any premature flushes.
|
onShutdown, onStartup
static final String GP_SUFFIX_SERIALIZER_WHITELIST_TYPES
static final String GP_SERIALIZER_WHITELIST_HIERARCHY_TYPES_PREFIX
void setAdministrationDAO(AdministrationDAO dao)
dao
- The dao implementation to use@Authorized(value="Get Global Properties") GlobalProperty getGlobalPropertyByUuid(String uuid)
@Authorized(value="View Administration Functions") SortedMap<String,String> getSystemVariables()
@Authorized(value="View Administration Functions") Map<String,Map<String,String>> getSystemInformation()
@Authorized(value="Get Global Properties") String getGlobalProperty(String propertyName)
propertyName
.
If propertyName
is not found in the list of Global Properties currently in the
database, a null value is returned. This method should not have any authorization check.
propertyName
- property key to look forShould not fail with null propertyName
Should get property value given valid property name
Should get property in case insensitive way
@Authorized(value="Get Global Properties") String getGlobalProperty(String propertyName, String defaultValue)
propertyName
If propertyName is not found in the list of Global Properties currently in the database, a
defaultValue
is returned
This method should not have any authorization check
propertyName
- property key to look fordefaultValue
- value to return if propertyName is not found@Authorized(value="Get Global Properties") GlobalProperty getGlobalPropertyObject(String propertyName)
propertyName
propertyName
- property key to look forpropertyName
Should return null when no global property match given property name@Authorized(value="Get Global Properties") List<GlobalProperty> getGlobalPropertiesByPrefix(String prefix)
prefix
.prefix
- The beginning of the property name to match.List
of GlobalProperty
s that match prefix
@Authorized(value="Get Global Properties") List<GlobalProperty> getGlobalPropertiesBySuffix(String suffix)
suffix
.suffix
- The end of the property name to match.List
of GlobalProperty
s that match .*suffix
@Authorized(value="Get Global Properties") List<GlobalProperty> getAllGlobalProperties()
@Authorized(value="Manage Global Properties") List<GlobalProperty> saveGlobalProperties(List<GlobalProperty> props)
props
- list of GlobalProperty objects to save@Authorized(value="Purge Global Properties") void purgeGlobalProperty(GlobalProperty globalProperty)
globalProperty
- the global property to delete/remove from the databaseAPIException
- Should delete global property from database@Authorized(value="Purge Global Properties") void purgeGlobalProperties(List<GlobalProperty> globalProperties)
globalProperties
- the global properties to delete/remove from the databaseAPIException
- Should delete global properties from database@Authorized(value="Manage Global Properties") void setGlobalProperty(String propertyName, String propertyValue)
propertyName
- the name of the global property to savepropertyValue
- the value of the global property to save
Should create global property in database
Should overwrite global property if exists
Should save a global property whose typed value is handled by a custom datatype@Authorized(value="Manage Global Properties") void updateGlobalProperty(String propertyName, String propertyValue)
propertyName
- the name of the global property to overwritepropertyValue
- the value of the global property to overwriteIllegalStateException
- Should update global property in database
Should fail if global property being updated does not already exist
Should update a global property whose typed value is handled by a custom datatype@Authorized(value="Manage Global Properties") GlobalProperty saveGlobalProperty(GlobalProperty gp)
gp
- global property to saveAPIException
- Should create global property in database
Should overwrite global property if exists
Should not allow different properties to have the same string with different case
Should save a global property whose typed value is handled by a custom datatype
Should evict all entries of search locale cachevoid addGlobalPropertyListener(GlobalPropertyListener listener)
listener
- The listener to registerGlobalPropertyListener
void removeGlobalPropertyListener(GlobalPropertyListener listener)
addGlobalPropertyListener(GlobalPropertyListener)
listener
- @Authorized(value="SQL Level Access") List<List<Object>> executeSQL(String sql, boolean selectOnly)
sql
on the database. If selectOnly
is flagged then any
non-select sql statements will be rejected.sql
- selectOnly
- APIException
- Should execute sql containing group by@Authorized(value="Manage Implementation Id") ImplementationId getImplementationId()
@Authorized(value="Manage Implementation Id") void setImplementationId(ImplementationId implementationId)
implementationId
as this implementation's unique idimplementationId
- the ImplementationId to saveAPIException
- if implementationId is empty or is invalid according to central id
server
Should create implementation id in database
Should overwrite implementation id in database if exists
Should not fail if given implementationId is null
Should throw APIException if given empty implementationId object
Should throw APIException if given a caret in the implementationId code
Should throw APIException if given a pipe in the implementationId code
Should set uuid on implementation id global propertyList<Locale> getAllowedLocales()
OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST
.Set<Locale> getPresentationLocales()
@Authorized(value="Get Global Properties") <T> T getGlobalPropertyValue(String propertyName, T defaultValue)
T
- propertyName
- Should get property value in the proper type specified
Should return default value if property name does not existint getMaximumPropertyLength(Class<? extends OpenmrsObject> aClass, String fieldName)
aClass
- class of object getting length forfieldName
- name of the field to get the length forvoid validate(Object object, org.springframework.validation.Errors errors)
Used by ValidateUtil.validate(Object)
.
object
- errors
- Should pass for a valid object
Should fail for an invalid object
Should throw throw APIException if the input is nullList<Locale> getSearchLocales(Locale currentLocale, User user)
currentLocale
- currently selected localeuser
- authenticated userAPIException
List<Locale> getSearchLocales()
The list is constructed from a currently selected locale and allowed user proficient locales.
APIException
void setImplementationIdHttpClient(HttpClient implementationHttpClient)
implementationHttpClient
- The implementation http clientboolean isDatabaseStringComparisonCaseSensitive()
It is an optimisation parameter for MySQL, which can speed up searching if set to false. See http://dev.mysql.com/doc/refman/5.7/en/case-sensitivity.html
It is set to true by default.
void updatePostgresSequence()
List<String> getSerializerWhitelistTypes()
Copyright © 2024 OpenMRS Inc.. All rights reserved.