org.openmrs.api.impl
Class LocationServiceImpl

java.lang.Object
  extended by org.openmrs.api.impl.BaseOpenmrsService
      extended by org.openmrs.api.impl.LocationServiceImpl
All Implemented Interfaces:
LocationService, OpenmrsService

public class LocationServiceImpl
extends BaseOpenmrsService
implements LocationService

Default implementation of the LocationService

This class should not be instantiated alone, get a service class from the Context: Context.getLocationService();

See Also:
Context, LocationService, Location

Constructor Summary
LocationServiceImpl()
           
 
Method Summary
 java.util.List<Location> getAllLocations()
          Returns all locations, includes retired locations.
 java.util.List<Location> getAllLocations(boolean includeRetired)
          Returns all locations.
 java.util.List<LocationTag> getAllLocationTags()
          Returns all location tags, includes retired location tags.
 java.util.List<LocationTag> getAllLocationTags(boolean includeRetired)
          Returns all location tags.
 Location getDefaultLocation()
          Returns the default location for this implementation.
 Location getLocation(java.lang.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(java.lang.String name)
          Returns a location given the location's exact name A null value is returned if there is no location with this name
 Location getLocationByUuid(java.lang.String uuid)
          Returns a location by uuid
 java.util.List<Location> getLocations(java.lang.String nameFragment)
          Returns locations that match the beginning of the given string.
 java.util.List<Location> getLocationsByTag(LocationTag tag)
          Returns locations that contain the given tag.
 java.util.List<Location> getLocationsHavingAllTags(java.util.List<LocationTag> tags)
          Returns locations that are mapped to all given tags.
 java.util.List<Location> getLocationsHavingAnyTag(java.util.List<LocationTag> tags)
          Returns locations that are mapped to any of the given tags.
 LocationTag getLocationTag(java.lang.Integer locationTagId)
          Returns a location tag given that locations primary key locationTagId.
 LocationTag getLocationTagByName(java.lang.String tag)
          Returns a location tag given the location's exact name (tag).
 LocationTag getLocationTagByUuid(java.lang.String uuid)
          Returns a location tag by uuid
 java.util.List<LocationTag> getLocationTags(java.lang.String search)
          Returns location tags that match the beginning of the given string.
 java.util.List<java.lang.String> getPossibleAddressValues(Address incomplete, java.lang.String fieldName)
          Given an Address object, returns all the possible values for the specified AddressField.
 void purgeLocation(Location location)
          Completely remove a location from the database (not reversible) This method delegates to #purgeLocation(location, boolean) method
 void purgeLocationTag(LocationTag tag)
          Completely remove a location tag from the database (not reversible).
 Location retireLocation(Location location, java.lang.String reason)
          Retires the given location.
 LocationTag retireLocationTag(LocationTag tag, java.lang.String reason)
          Retire the given location tag.
 Location saveLocation(Location location)
          Save location to database (create if new or update if changed)
 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.
 LocationTag unretireLocationTag(LocationTag tag)
          Unretire the given location tag.
 
Methods inherited from class org.openmrs.api.impl.BaseOpenmrsService
onShutdown, onStartup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openmrs.api.OpenmrsService
onShutdown, onStartup
 

Constructor Detail

LocationServiceImpl

public LocationServiceImpl()
Method Detail

setLocationDAO

public void setLocationDAO(LocationDAO dao)
Description copied from interface: LocationService
Set the data access object that the service will use to interact with the database. This is set by spring in the applicationContext-service.xml file

Specified by:
setLocationDAO in interface LocationService
See Also:
LocationService.setLocationDAO(org.openmrs.api.db.LocationDAO)

saveLocation

public Location saveLocation(Location location)
                      throws APIException
Description copied from interface: LocationService
Save location to database (create if new or update if changed)

Specified by:
saveLocation in interface LocationService
Parameters:
location - is the location to be saved to the database
Throws:
APIException
See Also:
LocationService.saveLocation(org.openmrs.Location)

getLocation

public Location getLocation(java.lang.Integer locationId)
                     throws APIException
Description copied from interface: LocationService
Returns a location given that locations primary key locationId A null value is returned if no location exists with this location.

Specified by:
getLocation in interface LocationService
Parameters:
locationId - integer primary key of the location to find
Returns:
Location object that has location.locationId = locationId passed in.
Throws:
APIException
See Also:
LocationService.getLocation(java.lang.Integer)

getLocation

public Location getLocation(java.lang.String name)
                     throws APIException
Description copied from interface: LocationService
Returns a location given the location's exact name A null value is returned if there is no location with this name

Specified by:
getLocation in interface LocationService
Parameters:
name - the exact name of the location to match on
Returns:
Location matching the name to Location.name
Throws:
APIException
See Also:
LocationService.getLocation(java.lang.String)

getDefaultLocation

public Location getDefaultLocation()
                            throws APIException
Description copied from interface: LocationService
Returns the default location for this implementation.

Specified by:
getDefaultLocation in interface LocationService
Returns:
The default location for this implementation.
Throws:
APIException
See Also:
LocationService.getDefaultLocation()

getLocationByUuid

public Location getLocationByUuid(java.lang.String uuid)
                           throws APIException
Description copied from interface: LocationService
Returns a location by uuid

Specified by:
getLocationByUuid in interface LocationService
Parameters:
uuid - is the uuid of the desired location
Returns:
location with the given uuid
Throws:
APIException
See Also:
LocationService.getLocationByUuid(java.lang.String)

getLocationTagByUuid

public LocationTag getLocationTagByUuid(java.lang.String uuid)
                                 throws APIException
Description copied from interface: LocationService
Returns a location tag by uuid

Specified by:
getLocationTagByUuid in interface LocationService
Parameters:
uuid - is the uuid of the desired location tag
Returns:
location tag with the given uuid
Throws:
APIException
See Also:
LocationService.getLocationTagByUuid(java.lang.String)

getAllLocations

public java.util.List<Location> getAllLocations()
                                         throws APIException
Description copied from interface: LocationService
Returns all locations, includes retired locations. This method delegates to the #getAllLocations(boolean) method

Specified by:
getAllLocations in interface LocationService
Returns:
locations that are in the database
Throws:
APIException
See Also:
LocationService.getAllLocations()

getAllLocations

public java.util.List<Location> getAllLocations(boolean includeRetired)
                                         throws APIException
Description copied from interface: LocationService
Returns all locations.

Specified by:
getAllLocations in interface LocationService
Parameters:
includeRetired - whether or not to include retired locations
Throws:
APIException
See Also:
LocationService.getAllLocations(boolean)

getLocations

public java.util.List<Location> getLocations(java.lang.String nameFragment)
                                      throws APIException
Description copied from interface: LocationService
Returns locations that match the beginning of the given string. A null list will never be returned. An empty list will be returned if there are no locations. Search is case insensitive. matching this nameFragment

Specified by:
getLocations in interface LocationService
Parameters:
nameFragment - is the string used to search for locations
Throws:
APIException
See Also:
LocationService.getLocations(java.lang.String)

getLocationsByTag

public java.util.List<Location> getLocationsByTag(LocationTag tag)
                                           throws APIException
Description copied from interface: LocationService
Returns locations that contain the given tag.

Specified by:
getLocationsByTag in interface LocationService
Parameters:
tag - LocationTag criterion
Throws:
APIException
See Also:
LocationService.getLocationsByTag(LocationTag)

getLocationsHavingAllTags

public java.util.List<Location> getLocationsHavingAllTags(java.util.List<LocationTag> tags)
                                                   throws APIException
Description copied from interface: LocationService
Returns locations that are mapped to all given tags.

Specified by:
getLocationsHavingAllTags in interface LocationService
Parameters:
tags - Set of LocationTag criteria
Throws:
APIException
See Also:
LocationService.getLocationsHavingAllTags(List)

getLocationsHavingAnyTag

public java.util.List<Location> getLocationsHavingAnyTag(java.util.List<LocationTag> tags)
                                                  throws APIException
Description copied from interface: LocationService
Returns locations that are mapped to any of the given tags.

Specified by:
getLocationsHavingAnyTag in interface LocationService
Parameters:
tags - Set of LocationTag criteria
Throws:
APIException
See Also:
LocationService.getLocationsHavingAnyTag(List)

retireLocation

public Location retireLocation(Location location,
                               java.lang.String reason)
                        throws APIException
Description copied from interface: LocationService
Retires the given location. This effectively removes the location from circulation or use.

Specified by:
retireLocation in interface LocationService
Parameters:
location - location to be retired
reason - is the reason why the location is being retired
Throws:
APIException
See Also:
LocationService.retireLocation(Location, String)

unretireLocation

public Location unretireLocation(Location location)
                          throws APIException
Description copied from interface: LocationService
Unretire the given location. This restores a previously retired location back into circulation and use.

Specified by:
unretireLocation in interface LocationService
Returns:
the newly unretired location
Throws:
APIException
See Also:
LocationService.unretireLocation(org.openmrs.Location)

purgeLocation

public void purgeLocation(Location location)
                   throws APIException
Description copied from interface: LocationService
Completely remove a location from the database (not reversible) This method delegates to #purgeLocation(location, boolean) method

Specified by:
purgeLocation in interface LocationService
Parameters:
location - the Location to clean out of the database.
Throws:
APIException
See Also:
LocationService.purgeLocation(org.openmrs.Location)

saveLocationTag

public LocationTag saveLocationTag(LocationTag tag)
                            throws APIException
Description copied from interface: LocationService
Save location tag to database (create if new or update if changed)

Specified by:
saveLocationTag in interface LocationService
Parameters:
tag - is the tag to be saved to the database
Throws:
APIException
See Also:
LocationService.saveLocationTag(org.openmrs.LocationTag)

getLocationTag

public LocationTag getLocationTag(java.lang.Integer locationTagId)
                           throws APIException
Description copied from interface: LocationService
Returns a location tag given that locations primary key locationTagId. A null value is returned if no tag exists with this ID.

Specified by:
getLocationTag in interface LocationService
Parameters:
locationTagId - integer primary key of the location tag to find
Returns:
LocationTag object that has LocationTag.locationTagId = locationTagId passed in.
Throws:
APIException
See Also:
LocationService.getLocationTag(java.lang.Integer)

getLocationTagByName

public LocationTag getLocationTagByName(java.lang.String tag)
                                 throws APIException
Description copied from interface: LocationService
Returns a location tag given the location's exact name (tag). A null value is returned if there is no tag with this name.

Specified by:
getLocationTagByName in interface LocationService
Parameters:
tag - the exact name of the tag to match on
Returns:
LocationTag matching the name to LocationTag.tag
Throws:
APIException
See Also:
LocationService.getLocationTagByName(java.lang.String)

getAllLocationTags

public java.util.List<LocationTag> getAllLocationTags()
                                               throws APIException
Description copied from interface: LocationService
Returns all location tags, includes retired location tags. This method delegates to the #getAllLocationTags(boolean) method.

Specified by:
getAllLocationTags in interface LocationService
Returns:
location tags that are in the database
Throws:
APIException
See Also:
LocationService.getAllLocationTags()

getAllLocationTags

public java.util.List<LocationTag> getAllLocationTags(boolean includeRetired)
                                               throws APIException
Description copied from interface: LocationService
Returns all location tags.

Specified by:
getAllLocationTags in interface LocationService
Parameters:
includeRetired - whether or not to include retired location tags
Throws:
APIException
See Also:
LocationService.getAllLocationTags(boolean)

getLocationTags

public java.util.List<LocationTag> getLocationTags(java.lang.String search)
                                            throws APIException
Description copied from interface: LocationService
Returns location tags that match the beginning of the given string. A null list will never be returned. An empty list will be returned if there are no tags. Search is case insensitive. matching this search

Specified by:
getLocationTags in interface LocationService
Parameters:
search - is the string used to search for tags
Throws:
APIException
See Also:
LocationService.getLocationTags(java.lang.String)

retireLocationTag

public LocationTag retireLocationTag(LocationTag tag,
                                     java.lang.String reason)
                              throws APIException
Description copied from interface: LocationService
Retire the given location tag. This effectively removes the tag from circulation or use.

Specified by:
retireLocationTag in interface LocationService
Parameters:
tag - location tag to be retired
reason - is the reason why the location tag is being retired
Throws:
APIException
See Also:
LocationService.retireLocationTag(LocationTag, String)

unretireLocationTag

public LocationTag unretireLocationTag(LocationTag tag)
                                throws APIException
Description copied from interface: LocationService
Unretire the given location tag. This restores a previously retired tag back into circulation and use.

Specified by:
unretireLocationTag in interface LocationService
Returns:
the newly unretired location tag
Throws:
APIException
See Also:
LocationService.unretireLocationTag(org.openmrs.LocationTag)

purgeLocationTag

public void purgeLocationTag(LocationTag tag)
                      throws APIException
Description copied from interface: LocationService
Completely remove a location tag from the database (not reversible).

Specified by:
purgeLocationTag in interface LocationService
Parameters:
tag - the LocationTag to clean out of the database.
Throws:
APIException
See Also:
LocationService.purgeLocationTag(org.openmrs.LocationTag)

getPossibleAddressValues

public java.util.List<java.lang.String> getPossibleAddressValues(Address incomplete,
                                                                 java.lang.String fieldName)
                                                          throws APIException
Description copied from interface: LocationService
Given an Address object, returns all the possible values for the specified AddressField. This method is not implemented in core, but is meant to overridden by implementing modules such as the Address Hierarchy module.

Specified by:
getPossibleAddressValues in interface LocationService
Parameters:
incomplete - the incomplete address
Returns:
a list of possible address values for the specified field
Throws:
APIException
See Also:
org.openmrs.api.LocationService#getPossibleAddressValues(org.openmrs.Address, org.openmrs.AddressField)

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change