@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, onStartupclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonShutdown, onStartupprotected AdministrationDAO dao
public AdministrationServiceImpl()
public void setAdministrationDAO(AdministrationDAO dao)
AdministrationServicesetAdministrationDAO in interface AdministrationServicedao - 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
AdministrationServicegetSystemVariables in interface AdministrationServiceAPIExceptionAdministrationService.getSystemVariables()@Transactional(readOnly=true) public String getGlobalProperty(String propertyName) throws APIException
AdministrationServicepropertyName.
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 AdministrationServicepropertyName - property key to look forAPIExceptionAdministrationService.getGlobalProperty(java.lang.String)@Transactional(readOnly=true) public String getGlobalProperty(String propertyName, String defaultValue) throws APIException
AdministrationServicepropertyName
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 AdministrationServicepropertyName - property key to look fordefaultValue - value to return if propertyName is not foundAPIExceptionAdministrationService.getGlobalProperty(java.lang.String,
java.lang.String)@Transactional(readOnly=true) public GlobalProperty getGlobalPropertyObject(String propertyName)
AdministrationServicepropertyNamegetGlobalPropertyObject in interface AdministrationServicepropertyName - 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
AdministrationServicesetGlobalProperty in interface AdministrationServicepropertyName - 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 datatypeAPIExceptionAdministrationService.setGlobalProperty(java.lang.String,
java.lang.String)public void updateGlobalProperty(String propertyName, String propertyValue) throws IllegalStateException
AdministrationServiceupdateGlobalProperty in interface AdministrationServicepropertyName - 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
AdministrationServicegetAllGlobalProperties in interface AdministrationServiceAPIExceptionAdministrationService.getAllGlobalProperties()@Transactional(readOnly=true) public List<GlobalProperty> getGlobalPropertiesByPrefix(String prefix)
AdministrationServiceprefix.getGlobalPropertiesByPrefix in interface AdministrationServiceprefix - The beginning of the property name to match.List of GlobalPropertys that match prefixAdministrationService.getGlobalPropertiesByPrefix(java.lang.String)@Transactional(readOnly=true) public List<GlobalProperty> getGlobalPropertiesBySuffix(String suffix)
AdministrationServicesuffix.getGlobalPropertiesBySuffix in interface AdministrationServicesuffix - The end of the property name to match.List of GlobalPropertys that match .*suffixAdministrationService.getGlobalPropertiesBySuffix(java.lang.String)public void purgeGlobalProperty(GlobalProperty globalProperty) throws APIException
AdministrationServicepurgeGlobalProperty in interface AdministrationServiceglobalProperty - 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
AdministrationServicesaveGlobalProperties in interface AdministrationServiceprops - list of GlobalProperty objects to saveAPIExceptionAdministrationService.saveGlobalProperties(java.util.List)@CacheEvict(value="userSearchLocales",
allEntries=true)
public GlobalProperty saveGlobalProperty(GlobalProperty gp)
throws APIException
AdministrationServicesaveGlobalProperty in interface AdministrationServicegp - 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
AdministrationServicesql on the database. If selectOnly is flagged then any
non-select sql statements will be rejected.executeSQL in interface AdministrationServiceAPIException - Should execute sql containing group byAdministrationService.executeSQL(java.lang.String, boolean)public void addGlobalPropertyListener(GlobalPropertyListener listener)
AdministrationServiceaddGlobalPropertyListener in interface AdministrationServicelistener - The listener to registerAdministrationService.addGlobalPropertyListener(GlobalPropertyListener)public void removeGlobalPropertyListener(GlobalPropertyListener listener)
AdministrationServiceAdministrationService.addGlobalPropertyListener(GlobalPropertyListener)removeGlobalPropertyListener in interface AdministrationServiceAdministrationService.removeGlobalPropertyListener(GlobalPropertyListener)@Transactional(readOnly=true) public ImplementationId getImplementationId() throws APIException
AdministrationServicegetImplementationId in interface AdministrationServiceAPIExceptionAdministrationService.getImplementationId()public void setImplementationId(ImplementationId implementationId) throws APIException
AdministrationServiceimplementationId as this implementation's unique idsetImplementationId in interface AdministrationServiceimplementationId - 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()
AdministrationServiceOpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST.getAllowedLocales in interface AdministrationServiceAdministrationService.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()
AdministrationServicegetPresentationLocales in interface AdministrationServiceAdministrationService.getPresentationLocales()public void globalPropertyChanged(GlobalProperty newValue)
GlobalPropertyListenerglobalPropertyChanged in interface GlobalPropertyListenernewValue - the new value of the property that was just savedGlobalPropertyListener.globalPropertyChanged(org.openmrs.GlobalProperty)public void globalPropertyDeleted(String propertyName)
GlobalPropertyListenerglobalPropertyDeleted in interface GlobalPropertyListenerpropertyName - the name of the property that was just deletedGlobalPropertyListener.globalPropertyDeleted(java.lang.String)public boolean supportsPropertyName(String propertyName)
GlobalPropertyListenersupportsPropertyName in interface GlobalPropertyListenerGlobalPropertyListener.supportsPropertyName(java.lang.String)@Transactional(readOnly=true) public GlobalProperty getGlobalPropertyByUuid(String uuid)
AdministrationServicegetGlobalPropertyByUuid in interface AdministrationServiceAdministrationService.getGlobalPropertyByUuid(java.lang.String)public <T> T getGlobalPropertyValue(String propertyName, T defaultValue) throws APIException
AdministrationServicegetGlobalPropertyValue in interface AdministrationServicepropertyName - Should get property value in the proper type specified
Should return default value if property name does not existAPIExceptionAdministrationService.getGlobalPropertyValue(java.lang.String,
java.lang.Object)@Transactional(readOnly=true) public Map<String,Map<String,String>> getSystemInformation() throws APIException
AdministrationServicegetSystemInformation in interface AdministrationServiceAPIExceptionAdministrationService.getSystemInformation()public void purgeGlobalProperties(List<GlobalProperty> globalProperties) throws APIException
AdministrationServicepurgeGlobalProperties in interface AdministrationServiceglobalProperties - 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 AdministrationServiceaClass - 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 AdministrationServiceerrors - Should pass for a valid object
Should fail for an invalid object
Should throw throw APIException if the input is nullAPIExceptionAdministrationService.validate(java.lang.Object, Errors)@Cacheable(value="userSearchLocales") public List<Locale> getSearchLocales(Locale currentLocale, User user) throws APIException
AdministrationServicegetSearchLocales in interface AdministrationServicecurrentLocale - currently selected localeuser - authenticated userAPIException@Transactional(readOnly=true) public List<Locale> getSearchLocales()
AdministrationServiceThe list is constructed from a currently selected locale and allowed user proficient locales.
getSearchLocales in interface AdministrationServiceAdministrationService.getSearchLocales()public void setImplementationIdHttpClient(HttpClient implementationIdHttpClient)
AdministrationServicesetImplementationIdHttpClient in interface AdministrationServiceimplementationIdHttpClient - The implementation http clientpublic boolean isDatabaseStringComparisonCaseSensitive()
AdministrationServiceIt 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 AdministrationServiceAdministrationService.isDatabaseStringComparisonCaseSensitive()public void updatePostgresSequence()
AdministrationServiceupdatePostgresSequence in interface AdministrationServiceAdministrationService.updatePostgresSequence()public List<String> getSerializerWhitelistTypes()
AdministrationServicegetSerializerWhitelistTypes in interface AdministrationServiceCopyright © 2024 OpenMRS Inc.. All rights reserved.