org.openmrs.api
Interface LocationService

All Superinterfaces:
OpenmrsService
All Known Implementing Classes:
LocationServiceImpl

@Transactional
public interface LocationService
extends OpenmrsService

API methods for managing Locations

Example Usage:
List locations = Context.getLocationService().getAllLocations();

See Also:
Context, Location

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 interface org.openmrs.api.OpenmrsService
onShutdown, onStartup
 

Method Detail

setLocationDAO

void setLocationDAO(LocationDAO dao)
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

Parameters:
dao -

saveLocation

@Authorized(value="Manage Locations")
Location saveLocation(Location location)
                      throws APIException
Save location to database (create if new or update if changed)

Parameters:
location - is the location to be saved to the database
Throws:
APIException
Expected behavior:
throw APIException if location has no name, overwrite transient tag if tag with same name exists, throw APIException if transient tag is not found, return saved object, remove location tag from location, add location tag to location, remove child location from location, cascade save to child location from location, update location successfully, create location successfully

getLocation

@Transactional(readOnly=true)
@Authorized(value="View Locations")
Location getLocation(java.lang.Integer locationId)
                     throws APIException
Returns a location given that locations primary key locationId A null value is returned if no location exists with this location.

Parameters:
locationId - integer primary key of the location to find
Returns:
Location object that has location.locationId = locationId passed in.
Throws:
APIException
Expected behavior:
return null when no location match given location id

getLocation

@Transactional(readOnly=true)
@Authorized(value="View Locations")
Location getLocation(java.lang.String name)
                     throws APIException
Returns a location given the location's exact name A null value is returned if there is no location with this name

Parameters:
name - the exact name of the location to match on
Returns:
Location matching the name to Location.name
Throws:
APIException
Expected behavior:
return null when no location match given location name

getDefaultLocation

@Transactional(readOnly=true)
@Authorized(value="View Locations")
Location getDefaultLocation()
                            throws APIException
Returns the default location for this implementation.

Returns:
The default location for this implementation.
Throws:
APIException
Expected behavior:
return default location for the implementation

getLocationByUuid

@Transactional(readOnly=true)
@Authorized(value="View Locations")
Location getLocationByUuid(java.lang.String uuid)
                           throws APIException
Returns a location by uuid

Parameters:
uuid - is the uuid of the desired location
Returns:
location with the given uuid
Throws:
APIException
Expected behavior:
find object given valid uuid, return null if no object found with given uuid

getLocationTagByUuid

@Transactional(readOnly=true)
@Authorized(value="View Locations")
LocationTag getLocationTagByUuid(java.lang.String uuid)
                                 throws APIException
Returns a location tag by uuid

Parameters:
uuid - is the uuid of the desired location tag
Returns:
location tag with the given uuid
Throws:
APIException
Expected behavior:
find object given valid uuid, return null if no object found with given uuid

getAllLocations

@Transactional(readOnly=true)
@Authorized(value="View Locations")
java.util.List<Location> getAllLocations()
                                         throws APIException
Returns all locations, includes retired locations. This method delegates to the #getAllLocations(boolean) method

Returns:
locations that are in the database
Throws:
APIException
Expected behavior:
return all locations including retired

getAllLocations

@Transactional(readOnly=true)
@Authorized(value="View Locations")
java.util.List<Location> getAllLocations(boolean includeRetired)
                                         throws APIException
Returns all locations.

Parameters:
includeRetired - whether or not to include retired locations
Throws:
APIException
Expected behavior:
return all locations when includeRetired is true, return only unretired locations when includeRetires is false

getLocations

@Transactional(readOnly=true)
@Authorized(value="View Locations")
java.util.List<Location> getLocations(java.lang.String nameFragment)
                                      throws APIException
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

Parameters:
nameFragment - is the string used to search for locations
Throws:
APIException
Expected behavior:
return empty list when no location match the name fragment

getLocationsByTag

@Transactional(readOnly=true)
@Authorized(value="View Locations")
java.util.List<Location> getLocationsByTag(LocationTag tag)
                                           throws APIException
Returns locations that contain the given tag.

Parameters:
tag - LocationTag criterion
Throws:
APIException
Since:
1.5
Expected behavior:
get locations by tag, return empty list when no locations has the given tag

getLocationsHavingAllTags

@Transactional(readOnly=true)
@Authorized(value="View Locations")
java.util.List<Location> getLocationsHavingAllTags(java.util.List<LocationTag> tags)
                                                   throws APIException
Returns locations that are mapped to all given tags.

Parameters:
tags - Set of LocationTag criteria
Throws:
APIException
Since:
1.5
Expected behavior:
get locations having all tags, return empty list when no location has the given tags, return all unretired locations given an empty tag list

getLocationsHavingAnyTag

@Transactional(readOnly=true)
@Authorized(value="View Locations")
java.util.List<Location> getLocationsHavingAnyTag(java.util.List<LocationTag> tags)
                                                  throws APIException
Returns locations that are mapped to any of the given tags.

Parameters:
tags - Set of LocationTag criteria
Throws:
APIException
Since:
1.5
Expected behavior:
get locations having any tag, return empty list when no location has the given tags, return empty list when given an empty tag list

retireLocation

@Authorized(value="Manage Locations")
Location retireLocation(Location location,
                                        java.lang.String reason)
                        throws APIException
Retires the given location. This effectively removes the location from circulation or use.

Parameters:
location - location to be retired
reason - is the reason why the location is being retired
Throws:
APIException
Expected behavior:
retire location successfully, throw IllegalArgumentException when no reason is given

unretireLocation

@Authorized(value="Manage Locations")
Location unretireLocation(Location location)
                          throws APIException
Unretire the given location. This restores a previously retired location back into circulation and use.

Parameters:
location -
Returns:
the newly unretired location
Throws:
APIException
Expected behavior:
unretire retired location

purgeLocation

@Authorized(value="Purge Locations")
void purgeLocation(Location location)
                   throws APIException
Completely remove a location from the database (not reversible) This method delegates to #purgeLocation(location, boolean) method

Parameters:
location - the Location to clean out of the database.
Throws:
APIException
Expected behavior:
delete location successfully

saveLocationTag

@Authorized(value="Manage Location Tags")
LocationTag saveLocationTag(LocationTag tag)
                            throws APIException
Save location tag to database (create if new or update if changed)

Parameters:
tag - is the tag to be saved to the database
Throws:
APIException
Since:
1.5
Expected behavior:
throw APIException if tag has no name, return saved object, update location tag successfully, create location tag successfully

getLocationTag

@Transactional(readOnly=true)
@Authorized(value="View Locations")
LocationTag getLocationTag(java.lang.Integer locationTagId)
                           throws APIException
Returns a location tag given that locations primary key locationTagId. A null value is returned if no tag exists with this ID.

Parameters:
locationTagId - integer primary key of the location tag to find
Returns:
LocationTag object that has LocationTag.locationTagId = locationTagId passed in.
Throws:
APIException
Since:
1.5
Expected behavior:
return null when no location tag match given id

getLocationTagByName

@Transactional(readOnly=true)
@Authorized(value="View Locations")
LocationTag getLocationTagByName(java.lang.String tag)
                                 throws APIException
Returns a location tag given the location's exact name (tag). A null value is returned if there is no tag with this name.

Parameters:
tag - the exact name of the tag to match on
Returns:
LocationTag matching the name to LocationTag.tag
Throws:
APIException
Since:
1.5
Expected behavior:
get location tag by name, return null when no location tag match given name

getAllLocationTags

@Transactional(readOnly=true)
@Authorized(value="View Locations")
java.util.List<LocationTag> getAllLocationTags()
                                               throws APIException
Returns all location tags, includes retired location tags. This method delegates to the #getAllLocationTags(boolean) method.

Returns:
location tags that are in the database
Throws:
APIException
Since:
1.5
Expected behavior:
return all location tags including retired

getAllLocationTags

@Transactional(readOnly=true)
@Authorized(value="View Locations")
java.util.List<LocationTag> getAllLocationTags(boolean includeRetired)
                                               throws APIException
Returns all location tags.

Parameters:
includeRetired - whether or not to include retired location tags
Throws:
APIException
Since:
1.5
Expected behavior:
return all location tags if includeRetired is true, return only unretired location tags if includeRetired is false

getLocationTags

@Transactional(readOnly=true)
@Authorized(value="View Locations")
java.util.List<LocationTag> getLocationTags(java.lang.String search)
                                            throws APIException
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

Parameters:
search - is the string used to search for tags
Throws:
APIException
Since:
1.5
Expected behavior:
return empty list when no location tag match given search string

retireLocationTag

@Authorized(value="Manage Location Tags")
LocationTag retireLocationTag(LocationTag tag,
                                              java.lang.String reason)
                              throws APIException
Retire the given location tag. This effectively removes the tag from circulation or use.

Parameters:
tag - location tag to be retired
reason - is the reason why the location tag is being retired
Throws:
APIException
Since:
1.5
Expected behavior:
retire location tag successfully, retire location tag with given reason, throw IllegalArgumentException when no reason is given

unretireLocationTag

@Authorized(value="Manage Location Tags")
LocationTag unretireLocationTag(LocationTag tag)
                                throws APIException
Unretire the given location tag. This restores a previously retired tag back into circulation and use.

Parameters:
tag -
Returns:
the newly unretired location tag
Throws:
APIException
Since:
1.5
Expected behavior:
unretire retired location tag

purgeLocationTag

@Authorized(value="Purge Location Tags")
void purgeLocationTag(LocationTag tag)
                      throws APIException
Completely remove a location tag from the database (not reversible).

Parameters:
tag - the LocationTag to clean out of the database.
Throws:
APIException
Since:
1.5
Expected behavior:
delete location tag

getPossibleAddressValues

java.util.List<java.lang.String> getPossibleAddressValues(Address incomplete,
                                                          java.lang.String fieldName)
                                                          throws APIException
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.

Parameters:
incomplete - the incomplete address
field - the address field we are looking for possible values for
Returns:
a list of possible address values for the specified field
Throws:
APIException
Since:
1.7.2
Expected behavior:
return empty list if no possible address matches, return null if method not implemented, return null by default

OpenMRS-1.7.x

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