@Transactional public class LocationServiceImpl extends BaseOpenmrsService implements LocationService
LocationService
This class should not be instantiated alone, get a service class from the Context: Context.getLocationService();
Context
,
LocationService
,
Location
Constructor and Description |
---|
LocationServiceImpl() |
Modifier and Type | Method and Description |
---|---|
String |
getAddressTemplate()
Returns the xml of default address template.
|
List<LocationAttributeType> |
getAllLocationAttributeTypes() |
List<Location> |
getAllLocations()
Returns all locations, includes retired locations.
|
List<Location> |
getAllLocations(boolean includeRetired)
Returns all locations.
|
List<LocationTag> |
getAllLocationTags()
Returns all location tags, includes retired location tags.
|
List<LocationTag> |
getAllLocationTags(boolean includeRetired)
Returns all location tags.
|
Integer |
getCountOfLocations(String nameFragment,
Boolean includeRetired)
Return the number of all locations that start with the given name fragment, if the name
fragment is null or an empty string, then the number of all locations will be returned
|
Location |
getDefaultLocation()
Returns the default location for this implementation.
|
Location |
getLocation(Integer locationId)
Returns a location given that locations primary key
locationId A null value is
returned if no location exists with this location. |
Location |
getLocation(String name)
Returns a location given the location's exact
name A null value is returned if
there is no location with this name |
LocationAttribute |
getLocationAttributeByUuid(String uuid) |
LocationAttributeType |
getLocationAttributeType(Integer id) |
LocationAttributeType |
getLocationAttributeTypeByName(String name)
Retrieves a LocationAttributeType object based on the name provided
|
LocationAttributeType |
getLocationAttributeTypeByUuid(String uuid) |
Location |
getLocationByUuid(String uuid)
Returns a location by uuid
|
List<Location> |
getLocations(String nameFragment)
Returns locations that match the beginning of the given string.
|
List<Location> |
getLocations(String nameFragment,
Location parent,
Map<LocationAttributeType,Object> attributeValues,
boolean includeRetired,
Integer start,
Integer length)
Gets the locations matching the specified arguments.
|
List<Location> |
getLocationsByTag(LocationTag tag)
Returns locations that contain the given tag.
|
List<Location> |
getLocationsHavingAllTags(List<LocationTag> tags)
Returns locations that are mapped to all given tags.
|
List<Location> |
getLocationsHavingAnyTag(List<LocationTag> tags)
Returns locations that are mapped to any of the given tags.
|
LocationTag |
getLocationTag(Integer locationTagId)
Returns a location tag given that locations primary key
locationTagId . |
LocationTag |
getLocationTagByName(String tag)
Returns a location tag given the location's exact name (tag).
|
LocationTag |
getLocationTagByUuid(String uuid)
Returns a location tag by uuid
|
List<LocationTag> |
getLocationTags(String search)
Returns location tags that match the beginning of the given string.
|
List<String> |
getPossibleAddressValues(Address incomplete,
String fieldName)
Given an Address object, returns all the possible values for the specified AddressField.
|
List<Location> |
getRootLocations(boolean includeRetired)
Returns all root locations (i.e. those who have no parentLocation), optionally including
retired ones.
|
void |
purgeLocation(Location location)
Completely remove a location from the database (not reversible) This method delegates to
#purgeLocation(location, boolean) method
|
void |
purgeLocationAttributeType(LocationAttributeType locationAttributeType)
Completely removes a location attribute type from the database
|
void |
purgeLocationTag(LocationTag tag)
Completely remove a location tag from the database (not reversible).
|
Location |
retireLocation(Location location,
String reason)
Retires the given location.
|
LocationAttributeType |
retireLocationAttributeType(LocationAttributeType locationAttributeType,
String reason)
Retires the given location attribute type in the database
|
LocationTag |
retireLocationTag(LocationTag tag,
String reason)
Retire the given location tag.
|
void |
saveAddressTemplate(String xml)
Saved default address template to global properties
|
Location |
saveLocation(Location location)
Save location to database (create if new or update if changed)
|
LocationAttributeType |
saveLocationAttributeType(LocationAttributeType locationAttributeType)
Creates or updates the given location attribute type in the database
|
LocationTag |
saveLocationTag(LocationTag tag)
Save location tag to database (create if new or update if changed)
|
void |
setLocationDAO(LocationDAO dao)
Set the data access object that the service will use to interact with the database.
|
Location |
unretireLocation(Location location)
Unretire the given location.
|
LocationAttributeType |
unretireLocationAttributeType(LocationAttributeType locationAttributeType)
Restores a location attribute type that was previous retired in the database
|
LocationTag |
unretireLocationTag(LocationTag tag)
Unretire the given location tag.
|
onShutdown, onStartup
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onShutdown, onStartup
public void setLocationDAO(LocationDAO dao)
LocationService
setLocationDAO
in interface LocationService
LocationService.setLocationDAO(org.openmrs.api.db.LocationDAO)
public Location saveLocation(Location location) throws APIException
LocationService
saveLocation
in interface LocationService
location
- is the location to be saved to the database
Should throw APIException if location has no name
Should overwrite transient tag if tag with same name exists
Should throw APIException if transient tag is not found
Should return saved object
Should remove location tag from location
Should add location tag to location
Should remove child location from location
Should cascade save to child location from location
Should update location successfully
Should create location successfullyAPIException
LocationService.saveLocation(org.openmrs.Location)
@Transactional(readOnly=true) public Location getLocation(Integer locationId) throws APIException
LocationService
locationId
A null value is
returned if no location exists with this location.getLocation
in interface LocationService
locationId
- integer primary key of the location to findlocationId
passed in.
Should return null when no location match given location idAPIException
LocationService.getLocation(java.lang.Integer)
@Transactional(readOnly=true) public Location getLocation(String name) throws APIException
LocationService
name
A null value is returned if
there is no location with this namegetLocation
in interface LocationService
name
- the exact name of the location to match onname
to Location.name
Should return null when no location match given location nameAPIException
LocationService.getLocation(java.lang.String)
@Transactional(readOnly=true) public Location getDefaultLocation() throws APIException
LocationService
getDefaultLocation
in interface LocationService
APIException
LocationService.getDefaultLocation()
@Transactional(readOnly=true) public Location getLocationByUuid(String uuid) throws APIException
LocationService
getLocationByUuid
in interface LocationService
uuid
- is the uuid of the desired locationAPIException
LocationService.getLocationByUuid(java.lang.String)
@Transactional(readOnly=true) public LocationTag getLocationTagByUuid(String uuid) throws APIException
LocationService
getLocationTagByUuid
in interface LocationService
uuid
- is the uuid of the desired location tagAPIException
LocationService.getLocationTagByUuid(java.lang.String)
@Transactional(readOnly=true) public List<Location> getAllLocations() throws APIException
LocationService
getAllLocations
in interface LocationService
APIException
LocationService.getAllLocations()
@Transactional(readOnly=true) public List<Location> getAllLocations(boolean includeRetired) throws APIException
LocationService
getAllLocations
in interface LocationService
includeRetired
- whether or not to include retired locations
Should return all locations when includeRetired is true
Should return only unretired locations when includeRetires is falseAPIException
LocationService.getAllLocations(boolean)
@Transactional(readOnly=true) public List<Location> getLocations(String nameFragment) throws APIException
LocationService
nameFragment
getLocations
in interface LocationService
nameFragment
- is the string used to search for locations
Should return empty list when no location match the name fragmentAPIException
LocationService.getLocations(java.lang.String)
@Transactional(readOnly=true) public List<Location> getLocationsByTag(LocationTag tag) throws APIException
LocationService
getLocationsByTag
in interface LocationService
tag
- LocationTag criterion
Should get locations by tag
Should return empty list when no locations has the given tagAPIException
LocationService.getLocationsByTag(LocationTag)
@Transactional(readOnly=true) public List<Location> getLocationsHavingAllTags(List<LocationTag> tags) throws APIException
LocationService
getLocationsHavingAllTags
in interface LocationService
tags
- Set of LocationTag criteria
Should get locations having all tags
Should return all unretired locations given an empty tag listAPIException
LocationService.getLocationsHavingAllTags(List)
@Transactional(readOnly=true) public List<Location> getLocationsHavingAnyTag(List<LocationTag> tags) throws APIException
LocationService
getLocationsHavingAnyTag
in interface LocationService
tags
- Set of LocationTag criteria
Should get locations having any tag
Should return empty list when no location has the given tags
Should return empty list when given an empty tag listAPIException
LocationService.getLocationsHavingAnyTag(List)
public Location retireLocation(Location location, String reason) throws APIException
LocationService
retireLocation
in interface LocationService
location
- location to be retiredreason
- is the reason why the location is being retired
Should retire location successfullyAPIException
LocationService.retireLocation(Location, String)
public Location unretireLocation(Location location) throws APIException
LocationService
unretireLocation
in interface LocationService
APIException
- Should unretire retired locationLocationService.unretireLocation(org.openmrs.Location)
public void purgeLocation(Location location) throws APIException
LocationService
purgeLocation
in interface LocationService
location
- the Location to clean out of the database.
Should delete location successfullyAPIException
LocationService.purgeLocation(org.openmrs.Location)
public LocationTag saveLocationTag(LocationTag tag) throws APIException
LocationService
saveLocationTag
in interface LocationService
tag
- is the tag to be saved to the database
Should throw APIException if tag has no name
Should return saved object
Should update location tag successfully
Should create location tag successfully
Should throw exception if tag name is nullAPIException
LocationService.saveLocationTag(org.openmrs.LocationTag)
@Transactional(readOnly=true) public LocationTag getLocationTag(Integer locationTagId) throws APIException
LocationService
locationTagId
. A null
value is returned if no tag exists with this ID.getLocationTag
in interface LocationService
locationTagId
- integer primary key of the location tag to findlocationTagId
passed in.
Should return null when no location tag match given idAPIException
LocationService.getLocationTag(java.lang.Integer)
@Transactional(readOnly=true) public LocationTag getLocationTagByName(String tag) throws APIException
LocationService
getLocationTagByName
in interface LocationService
tag
- the exact name of the tag to match onAPIException
LocationService.getLocationTagByName(java.lang.String)
@Transactional(readOnly=true) public List<LocationTag> getAllLocationTags() throws APIException
LocationService
getAllLocationTags
in interface LocationService
APIException
LocationService.getAllLocationTags()
@Transactional(readOnly=true) public List<LocationTag> getAllLocationTags(boolean includeRetired) throws APIException
LocationService
getAllLocationTags
in interface LocationService
includeRetired
- whether or not to include retired location tags
Should return all location tags if includeRetired is true
Should return only unretired location tags if includeRetired is falseAPIException
LocationService.getAllLocationTags(boolean)
@Transactional(readOnly=true) public List<LocationTag> getLocationTags(String search) throws APIException
LocationService
search
getLocationTags
in interface LocationService
search
- is the string used to search for tags
Should return empty list when no location tag match given search stringAPIException
LocationService.getLocationTags(java.lang.String)
public LocationTag retireLocationTag(LocationTag tag, String reason) throws APIException
LocationService
retireLocationTag
in interface LocationService
tag
- location tag to be retiredreason
- is the reason why the location tag is being retired
Should retire location tag successfully
Should retire location tag with given reasonAPIException
LocationService.retireLocationTag(LocationTag, String)
public LocationTag unretireLocationTag(LocationTag tag) throws APIException
LocationService
unretireLocationTag
in interface LocationService
APIException
- Should unretire retired location tagLocationService.unretireLocationTag(org.openmrs.LocationTag)
public void purgeLocationTag(LocationTag tag) throws APIException
LocationService
purgeLocationTag
in interface LocationService
tag
- the LocationTag to clean out of the database.
Should delete location tagAPIException
LocationService.purgeLocationTag(org.openmrs.LocationTag)
@Transactional(readOnly=true) public Integer getCountOfLocations(String nameFragment, Boolean includeRetired)
LocationService
getCountOfLocations
in interface LocationService
nameFragment
- is the string used to search for locationsincludeRetired
- Specifies if retired locations should be counted or ignoredLocationService.getCountOfLocations(String, Boolean)
public List<Location> getLocations(String nameFragment, Location parent, Map<LocationAttributeType,Object> attributeValues, boolean includeRetired, Integer start, Integer length)
LocationService
nameFragment
. If start
and length are not specified, then all matches are returned.getLocations
in interface LocationService
nameFragment
- is the string used to search for locationsparent
- only return children of this parentattributeValues
- the attribute valuesincludeRetired
- specifies if retired locations should also be returnedstart
- the beginning indexlength
- the number of matching locations to returnLocationService.getLocations(String, org.openmrs.Location, java.util.Map, boolean,
Integer, Integer)
@Transactional(readOnly=true) public List<Location> getRootLocations(boolean includeRetired) throws APIException
LocationService
getRootLocations
in interface LocationService
APIException
LocationService.getRootLocations(boolean)
public List<String> getPossibleAddressValues(Address incomplete, String fieldName) throws APIException
LocationService
getPossibleAddressValues
in interface LocationService
incomplete
- the incomplete addressfieldName
- the address field we are looking for possible values forAPIException
LocationService.getPossibleAddressValues(Address, String)
@Transactional(readOnly=true) public List<LocationAttributeType> getAllLocationAttributeTypes()
getAllLocationAttributeTypes
in interface LocationService
LocationAttributeType
sLocationService.getAllLocationAttributeTypes()
@Transactional(readOnly=true) public LocationAttributeType getLocationAttributeType(Integer id)
getLocationAttributeType
in interface LocationService
LocationAttributeType
with the given internal idLocationService.getLocationAttributeType(java.lang.Integer)
@Transactional(readOnly=true) public LocationAttributeType getLocationAttributeTypeByUuid(String uuid)
getLocationAttributeTypeByUuid
in interface LocationService
LocationAttributeType
with the given uuidLocationService.getLocationAttributeTypeByUuid(java.lang.String)
public LocationAttributeType saveLocationAttributeType(LocationAttributeType locationAttributeType)
LocationService
saveLocationAttributeType
in interface LocationService
LocationService.saveLocationAttributeType(org.openmrs.LocationAttributeType)
public LocationAttributeType retireLocationAttributeType(LocationAttributeType locationAttributeType, String reason)
LocationService
retireLocationAttributeType
in interface LocationService
LocationService.retireLocationAttributeType(org.openmrs.LocationAttributeType,
java.lang.String)
public LocationAttributeType unretireLocationAttributeType(LocationAttributeType locationAttributeType)
LocationService
unretireLocationAttributeType
in interface LocationService
LocationService.unretireLocationAttributeType(org.openmrs.LocationAttributeType)
public void purgeLocationAttributeType(LocationAttributeType locationAttributeType)
LocationService
purgeLocationAttributeType
in interface LocationService
LocationService.purgeLocationAttributeType(org.openmrs.LocationAttributeType)
@Transactional(readOnly=true) public LocationAttribute getLocationAttributeByUuid(String uuid)
getLocationAttributeByUuid
in interface LocationService
LocationAttribute
with the given uuidLocationService.getLocationAttributeByUuid(java.lang.String)
@Transactional(readOnly=true) public String getAddressTemplate() throws APIException
LocationService
getAddressTemplate
in interface LocationService
APIException
LocationService.getAddressTemplate()
public void saveAddressTemplate(String xml) throws APIException
LocationService
saveAddressTemplate
in interface LocationService
xml
- is a string to be saved as address template
Should throw APIException if the string is empty
Should update default address template successfully
Should create default address template successfullyAPIException
LocationService.saveAddressTemplate(String)
@Transactional(readOnly=true) public LocationAttributeType getLocationAttributeTypeByName(String name)
LocationService
getLocationAttributeTypeByName
in interface LocationService
LocationAttributeType
with the specified nameLocationService.getLocationAttributeTypeByName(java.lang.String)
Copyright © 2024 OpenMRS Inc.. All rights reserved.