@Transactional public class AdministrationServiceImpl extends BaseOpenmrsService implements AdministrationService, GlobalPropertyListener
AdministrationService
,
Context
Modifier and Type | Field and Description |
---|---|
protected AdministrationDAO |
dao |
protected SortedMap<String,String> |
systemVariables
Static-ish variable used to cache the system variables.
|
GP_SERIALIZER_WHITELIST_HIERARCHY_TYPES_PREFIX, GP_SUFFIX_SERIALIZER_WHITELIST_TYPES
Constructor and Description |
---|
AdministrationServiceImpl()
Default empty constructor
|
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.
|
static List<Class<?>> |
getSerializerDefaultWhitelistHierarchyTypes() |
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
|
void |
globalPropertyChanged(GlobalProperty newValue)
Called after a global property is created or updated
|
void |
globalPropertyDeleted(String propertyName)
Called after a global property is deleted
|
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
AdministrationService.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 |
setEventListeners(EventListeners eventListeners) |
void |
setGlobalLocaleList(GlobalLocaleList gll)
Used by spring to set the GlobalLocaleList on this 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 implementationIdHttpClient)
Used by Spring to set the http client for accessing the openmrs implementation service
|
boolean |
supportsPropertyName(String propertyName)
Asks this listener whether it wants to be notified about the given property name
|
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onShutdown, onStartup
protected AdministrationDAO dao
public AdministrationServiceImpl()
public void setAdministrationDAO(AdministrationDAO dao)
AdministrationService
setAdministrationDAO
in interface AdministrationService
dao
- The dao implementation to useAdministrationService.setAdministrationDAO(org.openmrs.api.db.AdministrationDAO)
public void setEventListeners(EventListeners eventListeners)
@Transactional(readOnly=true) public SortedMap<String,String> getSystemVariables() throws APIException
AdministrationService
getSystemVariables
in interface AdministrationService
APIException
AdministrationService.getSystemVariables()
@Transactional(readOnly=true) public String getGlobalProperty(String propertyName) throws APIException
AdministrationService
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.
getGlobalProperty
in interface AdministrationService
propertyName
- property key to look forAPIException
AdministrationService.getGlobalProperty(java.lang.String)
@Transactional(readOnly=true) public String getGlobalProperty(String propertyName, String defaultValue) throws APIException
AdministrationService
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
getGlobalProperty
in interface AdministrationService
propertyName
- property key to look fordefaultValue
- value to return if propertyName is not foundAPIException
AdministrationService.getGlobalProperty(java.lang.String,
java.lang.String)
@Transactional(readOnly=true) public GlobalProperty getGlobalPropertyObject(String propertyName)
AdministrationService
propertyName
getGlobalPropertyObject
in interface AdministrationService
propertyName
- property key to look forpropertyName
Should return null when no global property match given property nameAdministrationService.getGlobalPropertyObject(java.lang.String)
public void setGlobalProperty(String propertyName, String propertyValue) throws APIException
AdministrationService
setGlobalProperty
in interface AdministrationService
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 datatypeAPIException
AdministrationService.setGlobalProperty(java.lang.String,
java.lang.String)
public void updateGlobalProperty(String propertyName, String propertyValue) throws IllegalStateException
AdministrationService
updateGlobalProperty
in interface AdministrationService
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 datatypeAdministrationService.updateGlobalProperty(java.lang.String,
java.lang.String)
@Transactional(readOnly=true) public List<GlobalProperty> getAllGlobalProperties() throws APIException
AdministrationService
getAllGlobalProperties
in interface AdministrationService
APIException
AdministrationService.getAllGlobalProperties()
@Transactional(readOnly=true) public List<GlobalProperty> getGlobalPropertiesByPrefix(String prefix)
AdministrationService
prefix
.getGlobalPropertiesByPrefix
in interface AdministrationService
prefix
- The beginning of the property name to match.List
of GlobalProperty
s that match prefix
AdministrationService.getGlobalPropertiesByPrefix(java.lang.String)
@Transactional(readOnly=true) public List<GlobalProperty> getGlobalPropertiesBySuffix(String suffix)
AdministrationService
suffix
.getGlobalPropertiesBySuffix
in interface AdministrationService
suffix
- The end of the property name to match.List
of GlobalProperty
s that match .*suffix
AdministrationService.getGlobalPropertiesBySuffix(java.lang.String)
public void purgeGlobalProperty(GlobalProperty globalProperty) throws APIException
AdministrationService
purgeGlobalProperty
in interface AdministrationService
globalProperty
- the global property to delete/remove from the databaseAPIException
- Should delete global property from databaseAdministrationService.purgeGlobalProperty(org.openmrs.GlobalProperty)
@CacheEvict(value="userSearchLocales", allEntries=true) public List<GlobalProperty> saveGlobalProperties(List<GlobalProperty> props) throws APIException
AdministrationService
saveGlobalProperties
in interface AdministrationService
props
- list of GlobalProperty objects to saveAPIException
AdministrationService.saveGlobalProperties(java.util.List)
@CacheEvict(value="userSearchLocales", allEntries=true) public GlobalProperty saveGlobalProperty(GlobalProperty gp) throws APIException
AdministrationService
saveGlobalProperty
in interface AdministrationService
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 cacheAdministrationService.saveGlobalProperty(org.openmrs.GlobalProperty)
public List<List<Object>> executeSQL(String sql, boolean selectOnly) throws APIException
AdministrationService
sql
on the database. If selectOnly
is flagged then any
non-select sql statements will be rejected.executeSQL
in interface AdministrationService
APIException
- Should execute sql containing group byAdministrationService.executeSQL(java.lang.String, boolean)
public void addGlobalPropertyListener(GlobalPropertyListener listener)
AdministrationService
addGlobalPropertyListener
in interface AdministrationService
listener
- The listener to registerAdministrationService.addGlobalPropertyListener(GlobalPropertyListener)
public void removeGlobalPropertyListener(GlobalPropertyListener listener)
AdministrationService
AdministrationService.addGlobalPropertyListener(GlobalPropertyListener)
removeGlobalPropertyListener
in interface AdministrationService
AdministrationService.removeGlobalPropertyListener(GlobalPropertyListener)
@Transactional(readOnly=true) public ImplementationId getImplementationId() throws APIException
AdministrationService
getImplementationId
in interface AdministrationService
APIException
AdministrationService.getImplementationId()
public void setImplementationId(ImplementationId implementationId) throws APIException
AdministrationService
implementationId
as this implementation's unique idsetImplementationId
in interface AdministrationService
implementationId
- 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 propertyAdministrationService.setImplementationId(org.openmrs.ImplementationId)
@Transactional(readOnly=true) public List<Locale> getAllowedLocales()
AdministrationService
OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST
.getAllowedLocales
in interface AdministrationService
AdministrationService.getAllowedLocales()
public void setGlobalLocaleList(GlobalLocaleList gll)
gll
- the GlobalLocaleList object that is registered to the GlobalPropertyListeners as
well@Transactional(readOnly=true) public Set<Locale> getPresentationLocales()
AdministrationService
getPresentationLocales
in interface AdministrationService
AdministrationService.getPresentationLocales()
public void globalPropertyChanged(GlobalProperty newValue)
GlobalPropertyListener
globalPropertyChanged
in interface GlobalPropertyListener
newValue
- the new value of the property that was just savedGlobalPropertyListener.globalPropertyChanged(org.openmrs.GlobalProperty)
public void globalPropertyDeleted(String propertyName)
GlobalPropertyListener
globalPropertyDeleted
in interface GlobalPropertyListener
propertyName
- the name of the property that was just deletedGlobalPropertyListener.globalPropertyDeleted(java.lang.String)
public boolean supportsPropertyName(String propertyName)
GlobalPropertyListener
supportsPropertyName
in interface GlobalPropertyListener
GlobalPropertyListener.supportsPropertyName(java.lang.String)
@Transactional(readOnly=true) public GlobalProperty getGlobalPropertyByUuid(String uuid)
AdministrationService
getGlobalPropertyByUuid
in interface AdministrationService
AdministrationService.getGlobalPropertyByUuid(java.lang.String)
public <T> T getGlobalPropertyValue(String propertyName, T defaultValue) throws APIException
AdministrationService
getGlobalPropertyValue
in interface AdministrationService
propertyName
- Should get property value in the proper type specified
Should return default value if property name does not existAPIException
AdministrationService.getGlobalPropertyValue(java.lang.String,
java.lang.Object)
@Transactional(readOnly=true) public Map<String,Map<String,String>> getSystemInformation() throws APIException
AdministrationService
getSystemInformation
in interface AdministrationService
APIException
AdministrationService.getSystemInformation()
public void purgeGlobalProperties(List<GlobalProperty> globalProperties) throws APIException
AdministrationService
purgeGlobalProperties
in interface AdministrationService
globalProperties
- the global properties to delete/remove from the databaseAPIException
- Should delete global properties from databaseAdministrationService.purgeGlobalProperties(java.util.List)
@Transactional(readOnly=true) public int getMaximumPropertyLength(Class<? extends OpenmrsObject> aClass, String fieldName)
getMaximumPropertyLength
in interface AdministrationService
aClass
- class of object getting length forfieldName
- name of the field to get the length forAdministrationService.getMaximumPropertyLength(Class, String)
@Transactional(readOnly=true) public void validate(Object object, org.springframework.validation.Errors errors) throws APIException
AdministrationService
Used by ValidateUtil.validate(Object)
.
validate
in interface AdministrationService
errors
- Should pass for a valid object
Should fail for an invalid object
Should throw throw APIException if the input is nullAPIException
AdministrationService.validate(java.lang.Object, Errors)
@Cacheable(value="userSearchLocales") public List<Locale> getSearchLocales(Locale currentLocale, User user) throws APIException
AdministrationService
getSearchLocales
in interface AdministrationService
currentLocale
- currently selected localeuser
- authenticated userAPIException
@Transactional(readOnly=true) public List<Locale> getSearchLocales()
AdministrationService
The list is constructed from a currently selected locale and allowed user proficient locales.
getSearchLocales
in interface AdministrationService
AdministrationService.getSearchLocales()
public void setImplementationIdHttpClient(HttpClient implementationIdHttpClient)
AdministrationService
setImplementationIdHttpClient
in interface AdministrationService
implementationIdHttpClient
- The implementation http clientpublic boolean isDatabaseStringComparisonCaseSensitive()
AdministrationService
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.
isDatabaseStringComparisonCaseSensitive
in interface AdministrationService
AdministrationService.isDatabaseStringComparisonCaseSensitive()
public void updatePostgresSequence()
AdministrationService
updatePostgresSequence
in interface AdministrationService
AdministrationService.updatePostgresSequence()
public List<String> getSerializerWhitelistTypes()
AdministrationService
getSerializerWhitelistTypes
in interface AdministrationService
Copyright © 2024 OpenMRS Inc.. All rights reserved.