org.openmrs.api.db.hibernate
Class HibernatePersonDAO

java.lang.Object
  extended by org.openmrs.api.db.hibernate.HibernatePersonDAO
All Implemented Interfaces:
PersonDAO

public class HibernatePersonDAO
extends java.lang.Object
implements PersonDAO

Hibernate specific Person database methods.

This class should not be used directly. All database calls should go through the Service layer.

Proper use: PersonService ps = Context.getPersonService(); ps.getPeople("name", false);

See Also:
PersonDAO, PersonService, Context

Field Summary
protected static org.apache.commons.logging.Log log
           
 
Constructor Summary
HibernatePersonDAO()
           
 
Method Summary
 void deletePerson(Person person)
           
static void deletePersonAndAttributes(org.hibernate.SessionFactory sessionFactory, Person person)
          Used by deletePerson, deletePatient, and deleteUser to remove all properties of a person before deleting them.
 void deletePersonAttributeType(PersonAttributeType type)
           
 void deleteRelationship(Relationship relationship)
           
 void deleteRelationshipType(RelationshipType relationshipType)
           
 java.util.List<PersonAttributeType> getAllPersonAttributeTypes(boolean includeRetired)
           
 java.util.List<Relationship> getAllRelationships(boolean includeVoided)
           
 java.util.List<RelationshipType> getAllRelationshipTypes(boolean includeRetired)
           
protected static java.lang.Integer getMaximumSearchResults()
          Fetch the max results value from the global properties table
 java.util.List<Person> getPeople(java.lang.String name, java.lang.Boolean dead)
           
 Person getPerson(java.lang.Integer personId)
           
 PersonAddress getPersonAddressByUuid(java.lang.String uuid)
           
 PersonAttribute getPersonAttribute(java.lang.Integer id)
           
 PersonAttribute getPersonAttributeByUuid(java.lang.String uuid)
           
 PersonAttributeType getPersonAttributeType(java.lang.Integer typeId)
           
 PersonAttributeType getPersonAttributeTypeByUuid(java.lang.String uuid)
          Auto generated method comment
 java.util.List<PersonAttributeType> getPersonAttributeTypes(java.lang.String exactName, java.lang.String format, java.lang.Integer foreignKey, java.lang.Boolean searchable)
           
 Person getPersonByUuid(java.lang.String uuid)
          Auto generated method comment
 PersonName getPersonNameByUuid(java.lang.String uuid)
           
 Relationship getRelationship(java.lang.Integer relationshipId)
           
 Relationship getRelationshipByUuid(java.lang.String uuid)
          Auto generated method comment
 java.util.List<Relationship> getRelationships(Person fromPerson, Person toPerson, RelationshipType relType)
           
 RelationshipType getRelationshipType(java.lang.Integer relationshipTypeId)
           
 RelationshipType getRelationshipTypeByUuid(java.lang.String uuid)
          Auto generated method comment
 java.util.List<RelationshipType> getRelationshipTypes(java.lang.String relationshipTypeName, java.lang.Boolean preferred)
           
 java.lang.String getSavedPersonAttributeTypeName(PersonAttributeType personAttributeType)
          Gets the value of name currently saved in the database for the given personAttributeType, bypassing any caches.
 java.util.Set<Person> getSimilarPeople(java.lang.String name, java.lang.Integer birthyear, java.lang.String gender)
           
 Person savePerson(Person person)
           
 PersonAttributeType savePersonAttributeType(PersonAttributeType type)
           
 Relationship saveRelationship(Relationship relationship)
           
 RelationshipType saveRelationshipType(RelationshipType relationshipType)
           
 void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
          Set session factory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.commons.logging.Log log
Constructor Detail

HibernatePersonDAO

public HibernatePersonDAO()
Method Detail

setSessionFactory

public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Set session factory

Parameters:
sessionFactory -

getSimilarPeople

public java.util.Set<Person> getSimilarPeople(java.lang.String name,
                                              java.lang.Integer birthyear,
                                              java.lang.String gender)
                                       throws DAOException
Specified by:
getSimilarPeople in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.getSimilarPeople(java.lang.String,java.lang.Integer,java.lang.String,java.lang.String), org.openmrs.api.db.PersonDAO#getSimilarPeople(java.lang.String,java.lang.Integer,java.lang.String,java.lang.String)

getPeople

public java.util.List<Person> getPeople(java.lang.String name,
                                        java.lang.Boolean dead)
Specified by:
getPeople in interface PersonDAO
See Also:
PersonDAO.getPeople(java.lang.String, java.lang.Boolean)

getMaximumSearchResults

protected static java.lang.Integer getMaximumSearchResults()
Fetch the max results value from the global properties table

Returns:
Integer value for the person search max results global property

getPerson

public Person getPerson(java.lang.Integer personId)
Specified by:
getPerson in interface PersonDAO
See Also:
PersonService.getPerson(java.lang.Integer), PersonDAO.getPerson(java.lang.Integer)

deletePersonAttributeType

public void deletePersonAttributeType(PersonAttributeType type)
Specified by:
deletePersonAttributeType in interface PersonDAO
See Also:
PersonService.deletePersonAttributeType(org.openmrs.PersonAttributeType), PersonDAO.deletePersonAttributeType(org.openmrs.PersonAttributeType)

savePersonAttributeType

public PersonAttributeType savePersonAttributeType(PersonAttributeType type)
Specified by:
savePersonAttributeType in interface PersonDAO
See Also:
PersonService.savePersonAttributeType(org.openmrs.PersonAttributeType), PersonDAO.savePersonAttributeType(org.openmrs.PersonAttributeType)

getPersonAttributeType

public PersonAttributeType getPersonAttributeType(java.lang.Integer typeId)
Specified by:
getPersonAttributeType in interface PersonDAO
See Also:
PersonService.getPersonAttributeType(java.lang.Integer), PersonDAO.getPersonAttributeType(java.lang.Integer)

getPersonAttribute

public PersonAttribute getPersonAttribute(java.lang.Integer id)
Specified by:
getPersonAttribute in interface PersonDAO
See Also:
PersonService.getPersonAttribute(java.lang.Integer), PersonDAO.getPersonAttribute(java.lang.Integer)

getAllPersonAttributeTypes

public java.util.List<PersonAttributeType> getAllPersonAttributeTypes(boolean includeRetired)
                                                               throws DAOException
Specified by:
getAllPersonAttributeTypes in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.getAllPersonAttributeTypes(boolean), PersonDAO.getAllPersonAttributeTypes(boolean)

getPersonAttributeTypes

public java.util.List<PersonAttributeType> getPersonAttributeTypes(java.lang.String exactName,
                                                                   java.lang.String format,
                                                                   java.lang.Integer foreignKey,
                                                                   java.lang.Boolean searchable)
                                                            throws DAOException
Specified by:
getPersonAttributeTypes in interface PersonDAO
Throws:
DAOException
See Also:
PersonDAO.getPersonAttributeTypes(java.lang.String, java.lang.String, java.lang.Integer, java.lang.Boolean)

getRelationship

public Relationship getRelationship(java.lang.Integer relationshipId)
                             throws DAOException
Specified by:
getRelationship in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.getRelationship(java.lang.Integer), PersonDAO.getRelationship(java.lang.Integer)

getAllRelationships

public java.util.List<Relationship> getAllRelationships(boolean includeVoided)
                                                 throws DAOException
Specified by:
getAllRelationships in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.getAllRelationships(boolean), PersonDAO.getAllRelationships(boolean)

getRelationships

public java.util.List<Relationship> getRelationships(Person fromPerson,
                                                     Person toPerson,
                                                     RelationshipType relType)
Specified by:
getRelationships in interface PersonDAO
See Also:
PersonService.getRelationships(org.openmrs.Person, org.openmrs.Person, org.openmrs.RelationshipType), PersonDAO.getRelationships(org.openmrs.Person, org.openmrs.Person, org.openmrs.RelationshipType)

getRelationshipType

public RelationshipType getRelationshipType(java.lang.Integer relationshipTypeId)
                                     throws DAOException
Specified by:
getRelationshipType in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.getRelationshipType(java.lang.Integer), PersonDAO.getRelationshipType(java.lang.Integer)

getRelationshipTypes

public java.util.List<RelationshipType> getRelationshipTypes(java.lang.String relationshipTypeName,
                                                             java.lang.Boolean preferred)
                                                      throws DAOException
Specified by:
getRelationshipTypes in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.getRelationshipTypes(java.lang.String, java.lang.Boolean), PersonDAO.getRelationshipTypes(java.lang.String, java.lang.Boolean)

saveRelationshipType

public RelationshipType saveRelationshipType(RelationshipType relationshipType)
                                      throws DAOException
Specified by:
saveRelationshipType in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.saveRelationshipType(org.openmrs.RelationshipType), PersonDAO.saveRelationshipType(org.openmrs.RelationshipType)

deleteRelationshipType

public void deleteRelationshipType(RelationshipType relationshipType)
                            throws DAOException
Specified by:
deleteRelationshipType in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.deleteRelationshipType(org.openmrs.RelationshipType), PersonDAO.deleteRelationshipType(org.openmrs.RelationshipType)

deletePerson

public void deletePerson(Person person)
                  throws DAOException
Specified by:
deletePerson in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.purgePerson(org.openmrs.Person), PersonDAO.deletePerson(org.openmrs.Person)

savePerson

public Person savePerson(Person person)
                  throws DAOException
Specified by:
savePerson in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.savePerson(org.openmrs.Person), PersonDAO.savePerson(org.openmrs.Person)

saveRelationship

public Relationship saveRelationship(Relationship relationship)
                              throws DAOException
Specified by:
saveRelationship in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.saveRelationship(org.openmrs.Relationship), PersonDAO.saveRelationship(org.openmrs.Relationship)

deleteRelationship

public void deleteRelationship(Relationship relationship)
                        throws DAOException
Specified by:
deleteRelationship in interface PersonDAO
Throws:
DAOException
See Also:
PersonService.purgeRelationship(org.openmrs.Relationship), PersonDAO.deleteRelationship(org.openmrs.Relationship)

deletePersonAndAttributes

public static void deletePersonAndAttributes(org.hibernate.SessionFactory sessionFactory,
                                             Person person)
Used by deletePerson, deletePatient, and deleteUser to remove all properties of a person before deleting them.

Parameters:
sessionFactory - the session factory from which to pull the current session
person - the person to delete

getPersonAttributeTypeByUuid

public PersonAttributeType getPersonAttributeTypeByUuid(java.lang.String uuid)
Description copied from interface: PersonDAO
Auto generated method comment

Specified by:
getPersonAttributeTypeByUuid in interface PersonDAO
Returns:
See Also:
PersonDAO.getPersonAttributeTypeByUuid(java.lang.String)

getSavedPersonAttributeTypeName

public java.lang.String getSavedPersonAttributeTypeName(PersonAttributeType personAttributeType)
Description copied from interface: PersonDAO
Gets the value of name currently saved in the database for the given personAttributeType, bypassing any caches. This is used prior to saving an personAttributeType, so that we can change the vlaue of any global property which is in OpenmrsConstants.GLOBAL_PROPERTIES_OF_PERSON_ATTRIBUTES and reference the given personAttributeType.

Specified by:
getSavedPersonAttributeTypeName in interface PersonDAO
Parameters:
personAttributeType - the personAttributeType get the the name of
Returns:
the name currently in the database for this personAttributeType
See Also:
PersonDAO.getSavedPersonAttributeTypeName(org.openmrs.PersonAttributeType)

getPersonByUuid

public Person getPersonByUuid(java.lang.String uuid)
Description copied from interface: PersonDAO
Auto generated method comment

Specified by:
getPersonByUuid in interface PersonDAO
Returns:
See Also:
PersonDAO.getPersonByUuid(java.lang.String)

getPersonAddressByUuid

public PersonAddress getPersonAddressByUuid(java.lang.String uuid)
Specified by:
getPersonAddressByUuid in interface PersonDAO

getPersonAttributeByUuid

public PersonAttribute getPersonAttributeByUuid(java.lang.String uuid)
Specified by:
getPersonAttributeByUuid in interface PersonDAO

getPersonNameByUuid

public PersonName getPersonNameByUuid(java.lang.String uuid)
Specified by:
getPersonNameByUuid in interface PersonDAO

getRelationshipByUuid

public Relationship getRelationshipByUuid(java.lang.String uuid)
Description copied from interface: PersonDAO
Auto generated method comment

Specified by:
getRelationshipByUuid in interface PersonDAO
Returns:
See Also:
PersonDAO.getRelationshipByUuid(java.lang.String)

getRelationshipTypeByUuid

public RelationshipType getRelationshipTypeByUuid(java.lang.String uuid)
Description copied from interface: PersonDAO
Auto generated method comment

Specified by:
getRelationshipTypeByUuid in interface PersonDAO
Returns:
See Also:
PersonDAO.getRelationshipTypeByUuid(java.lang.String)

getAllRelationshipTypes

public java.util.List<RelationshipType> getAllRelationshipTypes(boolean includeRetired)
Specified by:
getAllRelationshipTypes in interface PersonDAO
See Also:
PersonDAO.getAllRelationshipTypes(boolean)

OpenMRS-1.7.x

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