org.openmrs
Class Location

java.lang.Object
  extended by org.openmrs.BaseOpenmrsObject
      extended by org.openmrs.BaseOpenmrsMetadata
          extended by org.openmrs.Location
All Implemented Interfaces:
java.io.Serializable, Address, Attributable<Location>, Auditable, OpenmrsMetadata, OpenmrsObject, Retireable

public class Location
extends BaseOpenmrsMetadata
implements java.io.Serializable, Attributable<Location>, Address

A Location is a physical place, such as a hospital, a room, a clinic, or a district. Locations support a single hierarchy, such that each location may have one parent location. A non-geographical grouping of locations, such as "All Community Health Centers" is not a location, and should be modeled using LocationTags.

See Also:
Serialized Form

Field Summary
static int LOCATION_UNKNOWN
           
static long serialVersionUID
           
 
Constructor Summary
Location()
          default constructor
Location(java.lang.Integer locationId)
          constructor with id
 
Method Summary
 void addChildLocation(Location child)
           
 void addTag(LocationTag tag)
          Attaches a tag to the Location.
 boolean equals(java.lang.Object obj)
          Compares two objects for similarity
 java.util.List<Location> findPossibleValues(java.lang.String searchText)
          Search for possible values of this object using the given search string
 java.lang.String getAddress1()
           
 java.lang.String getAddress2()
           
 java.lang.String getAddress3()
          Added for compatibility reasons with 1.8+
 java.lang.String getAddress4()
          Added for compatibility reasons with 1.8+
 java.lang.String getAddress5()
          Added for compatibility reasons with 1.8+
 java.lang.String getAddress6()
          Added for compatibility reasons with 1.8+
 java.util.Set<Location> getChildLocations()
           
 java.util.Set<Location> getChildLocations(boolean includeRetired)
          Returns all childLocations where child.locationId = this.locationId.
 java.lang.String getCityVillage()
           
 java.lang.String getCountry()
           
 java.lang.String getCountyDistrict()
           
 java.lang.String getDisplayString()
          Gets a descriptive String used for display purposes This is meant as an alternative to using the toString() to display this object to a user
 java.lang.Integer getId()
           
 java.lang.String getLatitude()
           
 java.lang.Integer getLocationId()
           
 java.lang.String getLongitude()
           
 java.lang.String getNeighborhoodCell()
           
 Location getParentLocation()
           
 java.util.List<Location> getPossibleValues()
          Find all possible values of this object.
 java.lang.String getPostalCode()
           
 java.lang.String getRegion()
           
 java.lang.String getStateProvince()
           
 java.lang.String getSubregion()
           
 java.util.Set<LocationTag> getTags()
           
 java.lang.String getTownshipDivision()
           
 int hashCode()
           
 java.lang.Boolean hasTag(java.lang.String tagToFind)
          Checks whether the Location has a particular tag.
 Location hydrate(java.lang.String locationId)
          Deserialize the given string into a full object
static java.lang.Boolean isInHierarchy(Location location, Location root)
          Checks whether 'location' is a member of the tree starting at 'root'.
 void removeChildLocation(Location child)
           
 void removeTag(LocationTag tag)
          Remove the tag from the Location.
 java.lang.String serialize()
          Turn the current object into an identifying string that can be retrieved later
 void setAddress1(java.lang.String address1)
           
 void setAddress2(java.lang.String address2)
           
 void setAddress3(java.lang.String address3)
          Added for compatibility reasons with 1.8+
 void setAddress4(java.lang.String address4)
          Added for compatibility reasons with 1.8+
 void setAddress5(java.lang.String address5)
          Added for compatibility reasons with 1.8+
 void setAddress6(java.lang.String address6)
          Added for compatibility reasons with 1.8+
 void setChildLocations(java.util.Set<Location> childLocations)
           
 void setCityVillage(java.lang.String cityVillage)
           
 void setCountry(java.lang.String country)
           
 void setCountyDistrict(java.lang.String countyDistrict)
           
 void setId(java.lang.Integer id)
           
 void setLatitude(java.lang.String latitude)
           
 void setLocationId(java.lang.Integer locationId)
           
 void setLongitude(java.lang.String longitude)
           
 void setNeighborhoodCell(java.lang.String neighborhoodCell)
           
 void setParentLocation(Location parentLocationId)
           
 void setPostalCode(java.lang.String postalCode)
           
 void setRegion(java.lang.String region)
           
 void setStateProvince(java.lang.String stateProvince)
           
 void setSubregion(java.lang.String subregion)
           
 void setTags(java.util.Set<LocationTag> tags)
          Set the tags which are attached to this Location.
 void setTownshipDivision(java.lang.String townshipDivision)
           
 java.lang.String toString()
           
 
Methods inherited from class org.openmrs.BaseOpenmrsMetadata
getChangedBy, getCreator, getDateChanged, getDateCreated, getDateRetired, getDescription, getName, getRetired, getRetiredBy, getRetireReason, isRetired, setChangedBy, setCreator, setDateChanged, setDateCreated, setDateRetired, setDescription, setName, setRetired, setRetiredBy, setRetireReason
 
Methods inherited from class org.openmrs.BaseOpenmrsObject
getUuid, setUuid
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openmrs.OpenmrsObject
getUuid, setUuid
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

LOCATION_UNKNOWN

public static final int LOCATION_UNKNOWN
See Also:
Constant Field Values
Constructor Detail

Location

public Location()
default constructor


Location

public Location(java.lang.Integer locationId)
constructor with id

Method Detail

equals

public boolean equals(java.lang.Object obj)
Compares two objects for similarity

Overrides:
equals in class java.lang.Object
Parameters:
obj -
Returns:
boolean true/false whether or not they are the same objects

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getAddress1

public java.lang.String getAddress1()
Specified by:
getAddress1 in interface Address
Returns:
Returns the address1.

setAddress1

public void setAddress1(java.lang.String address1)
Specified by:
setAddress1 in interface Address
Parameters:
address1 - The address1 to set.

getAddress2

public java.lang.String getAddress2()
Specified by:
getAddress2 in interface Address
Returns:
Returns the address2.

setAddress2

public void setAddress2(java.lang.String address2)
Specified by:
setAddress2 in interface Address
Parameters:
address2 - The address2 to set.

getCityVillage

public java.lang.String getCityVillage()
Specified by:
getCityVillage in interface Address
Returns:
Returns the cityVillage.

setCityVillage

public void setCityVillage(java.lang.String cityVillage)
Specified by:
setCityVillage in interface Address
Parameters:
cityVillage - The cityVillage to set.

getCountry

public java.lang.String getCountry()
Specified by:
getCountry in interface Address
Returns:
Returns the country.

setCountry

public void setCountry(java.lang.String country)
Specified by:
setCountry in interface Address
Parameters:
country - The country to set.

getLatitude

public java.lang.String getLatitude()
Specified by:
getLatitude in interface Address
Returns:
Returns the latitude.

setLatitude

public void setLatitude(java.lang.String latitude)
Specified by:
setLatitude in interface Address
Parameters:
latitude - The latitude to set.

getLocationId

public java.lang.Integer getLocationId()
Returns:
Returns the locationId.

setLocationId

public void setLocationId(java.lang.Integer locationId)
Parameters:
locationId - The locationId to set.

getLongitude

public java.lang.String getLongitude()
Specified by:
getLongitude in interface Address
Returns:
Returns the longitude.

setLongitude

public void setLongitude(java.lang.String longitude)
Specified by:
setLongitude in interface Address
Parameters:
longitude - The longitude to set.

getPostalCode

public java.lang.String getPostalCode()
Specified by:
getPostalCode in interface Address
Returns:
Returns the postalCode.

setPostalCode

public void setPostalCode(java.lang.String postalCode)
Specified by:
setPostalCode in interface Address
Parameters:
postalCode - The postalCode to set.

getStateProvince

public java.lang.String getStateProvince()
Specified by:
getStateProvince in interface Address
Returns:
Returns the stateProvince.

setStateProvince

public void setStateProvince(java.lang.String stateProvince)
Specified by:
setStateProvince in interface Address
Parameters:
stateProvince - The stateProvince to set.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getCountyDistrict

public java.lang.String getCountyDistrict()
Specified by:
getCountyDistrict in interface Address
Returns:
Returns the countyDistrict.

setCountyDistrict

public void setCountyDistrict(java.lang.String countyDistrict)
Specified by:
setCountyDistrict in interface Address
Parameters:
countyDistrict - The countyDistrict to set.

getNeighborhoodCell

public java.lang.String getNeighborhoodCell()
Returns:
Returns the neighborhoodCell.

setNeighborhoodCell

public void setNeighborhoodCell(java.lang.String neighborhoodCell)
Parameters:
neighborhoodCell - The neighborhoodCell to set.

findPossibleValues

public java.util.List<Location> findPossibleValues(java.lang.String searchText)
Description copied from interface: Attributable
Search for possible values of this object using the given search string

Specified by:
findPossibleValues in interface Attributable<Location>
Parameters:
searchText - String to search on
Returns:
List of possible objects that can be assigned
See Also:
Attributable.findPossibleValues(java.lang.String)

getPossibleValues

public java.util.List<Location> getPossibleValues()
Description copied from interface: Attributable
Find all possible values of this object. For example, if this object is a Location, the database is delved into and all Location objects should be returned

Specified by:
getPossibleValues in interface Attributable<Location>
Returns:
List of objects that can be assigned
See Also:
Attributable.getPossibleValues()

hydrate

public Location hydrate(java.lang.String locationId)
Description copied from interface: Attributable
Deserialize the given string into a full object

Specified by:
hydrate in interface Attributable<Location>
Parameters:
locationId - String to deserialize
Returns:
hydrated object
See Also:
Attributable.hydrate(java.lang.String)

serialize

public java.lang.String serialize()
Description copied from interface: Attributable
Turn the current object into an identifying string that can be retrieved later

Specified by:
serialize in interface Attributable<Location>
Returns:
String representing this object (Usually an identifier or primary key)
See Also:
Attributable.serialize()

getDisplayString

public java.lang.String getDisplayString()
Description copied from interface: Attributable
Gets a descriptive String used for display purposes This is meant as an alternative to using the toString() to display this object to a user

Specified by:
getDisplayString in interface Attributable<Location>
Returns:
String acceptable to display on a page
See Also:
Attributable.getDisplayString()

getRegion

public java.lang.String getRegion()
Returns:
the region

setRegion

public void setRegion(java.lang.String region)
Parameters:
region - the region to set

getSubregion

public java.lang.String getSubregion()
Returns:
the subregion

setSubregion

public void setSubregion(java.lang.String subregion)
Parameters:
subregion - the subregion to set

getTownshipDivision

public java.lang.String getTownshipDivision()
Returns:
the townshipDivision

setTownshipDivision

public void setTownshipDivision(java.lang.String townshipDivision)
Parameters:
townshipDivision - the townshipDivision to set

getParentLocation

public Location getParentLocation()
Returns:
Returns the parentLocation.
Since:
1.5

setParentLocation

public void setParentLocation(Location parentLocationId)
Parameters:
parentLocationId - The parentLocation to set.
Since:
1.5

getChildLocations

public java.util.Set<Location> getChildLocations()
Returns:
Returns the childLocations.
Since:
1.5

getChildLocations

public java.util.Set<Location> getChildLocations(boolean includeRetired)
Returns all childLocations where child.locationId = this.locationId.

Parameters:
includeRetired - specifies whether or not to include voided childLocations
Returns:
Returns a Set of all the childLocations.
Since:
1.5
Expected behavior:
return a set of locations

setChildLocations

public void setChildLocations(java.util.Set<Location> childLocations)
Parameters:
childLocations - The childLocations to set.
Since:
1.5

addChildLocation

public void addChildLocation(Location child)
Parameters:
child - The child location to add.
Since:
1.5
Expected behavior:
return null given null parameter, throw APIException given same object as child, throw APIException if child already in hierarchy

isInHierarchy

public static java.lang.Boolean isInHierarchy(Location location,
                                              Location root)
Checks whether 'location' is a member of the tree starting at 'root'.

Parameters:
location - The location to be tested.
root - Location node from which to start the testing (down in the hierarchy).
Since:
1.5
Expected behavior:
return false given any null parameter, return true given same object in both parameters, return true given location that is already somewhere in hierarchy, return false given location that is not in hierarchy, should find location in hierarchy

removeChildLocation

public void removeChildLocation(Location child)
Parameters:
child - The child location to remove.
Since:
1.5

getTags

public java.util.Set<LocationTag> getTags()
Returns:
Returns the tags which have been attached to this Location.
Since:
1.5

setTags

public void setTags(java.util.Set<LocationTag> tags)
Set the tags which are attached to this Location.

Parameters:
tags - The tags to set.
Since:
1.5

addTag

public void addTag(LocationTag tag)
Attaches a tag to the Location.

Parameters:
tag - The tag to add.
Since:
1.5

removeTag

public void removeTag(LocationTag tag)
Remove the tag from the Location.

Parameters:
tag - The tag to remove.
Since:
1.5

hasTag

public java.lang.Boolean hasTag(java.lang.String tagToFind)
Checks whether the Location has a particular tag.

Parameters:
tagToFind - the string of the tag for which to check
Returns:
true if the tags include the specified tag, false otherwise
Since:
1.5
Expected behavior:
not fail given null parameter, return false given empty string parameter

getId

public java.lang.Integer getId()
Specified by:
getId in interface OpenmrsObject
Returns:
id - The unique Identifier for the object
Since:
1.5
See Also:
OpenmrsObject.getId()

setId

public void setId(java.lang.Integer id)
Specified by:
setId in interface OpenmrsObject
Parameters:
id - - The unique Identifier for the object
Since:
1.5
See Also:
OpenmrsObject.setId(java.lang.Integer)

getAddress3

public java.lang.String getAddress3()
Added for compatibility reasons with 1.8+

Specified by:
getAddress3 in interface Address

setAddress3

public void setAddress3(java.lang.String address3)
Added for compatibility reasons with 1.8+

Specified by:
setAddress3 in interface Address

getAddress4

public java.lang.String getAddress4()
Added for compatibility reasons with 1.8+

Specified by:
getAddress4 in interface Address

setAddress4

public void setAddress4(java.lang.String address4)
Added for compatibility reasons with 1.8+

Specified by:
setAddress4 in interface Address

getAddress5

public java.lang.String getAddress5()
Added for compatibility reasons with 1.8+

Specified by:
getAddress5 in interface Address

setAddress5

public void setAddress5(java.lang.String address5)
Added for compatibility reasons with 1.8+

Specified by:
setAddress5 in interface Address

setAddress6

public void setAddress6(java.lang.String address6)
Added for compatibility reasons with 1.8+

Specified by:
setAddress6 in interface Address

getAddress6

public java.lang.String getAddress6()
Added for compatibility reasons with 1.8+

Specified by:
getAddress6 in interface Address

OpenMRS-1.7.x

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