org.openmrs.api.db.hibernate
Class HibernateSerializedObjectDAO

java.lang.Object
  extended by org.openmrs.api.db.hibernate.HibernateSerializedObjectDAO
All Implemented Interfaces:
SerializedObjectDAO

public class HibernateSerializedObjectDAO
extends java.lang.Object
implements SerializedObjectDAO

Hibernate specific database access methods for serialized objects


Field Summary
protected  org.apache.commons.logging.Log log
           
 
Method Summary
<T extends OpenmrsObject>
T
convertSerializedObject(java.lang.Class<T> clazz, SerializedObject serializedObject)
          Converts a raw SerializedObject to an OpenmrsObject, using the appropriate Serializer
<T extends OpenmrsObject>
java.util.List<T>
getAllObjects(java.lang.Class<T> type)
          Retrieves all non-retired objects of the passed type from the database that have been saved through serialization
<T extends OpenmrsObject>
java.util.List<T>
getAllObjects(java.lang.Class<T> type, boolean includeRetired)
          Retrieves all objects from the database that match the passed type that have been saved through serialization Returns voided / retired Objects only if includeRetired parameter is true
<T extends OpenmrsMetadata>
java.util.List<T>
getAllObjectsByName(java.lang.Class<T> type, java.lang.String name, boolean exactMatchOnly)
          Retrieves all objects from the database that match the passed type and name that have been saved through serialization
 java.util.List<SerializedObject> getAllSerializedObjects(java.lang.Class<?> type, boolean includeRetired)
          Retrieves all raw Serialized Object from the database that match the passed type and includeRetired flag
 java.util.List<SerializedObject> getAllSerializedObjectsByName(java.lang.Class<?> type, java.lang.String name, boolean exactMatchOnly)
          Retrieves all raw Serialized Objects from the database that match the passed type and name
static HibernateSerializedObjectDAO getInstance()
          Singleton Factory method
<T extends OpenmrsObject>
T
getObject(java.lang.Class<T> baseClass, java.lang.Integer id)
          Retrieves the saved object of the passed type from the database by it's id
<T extends OpenmrsObject>
T
getObjectByUuid(java.lang.Class<T> baseClass, java.lang.String uuid)
          Retrieves the saved object of the passed type from the database by it's uuid
 java.lang.Class<? extends OpenmrsObject> getRegisteredTypeForObject(OpenmrsObject object)
          Returns the registered class for the passed object, or null if none found For example, if the supportedTypes property contains the CohortDefinition.class interface, and a particular implementation of that interface is passed in, then this method would return CohortDefinition.class.
 SerializedObject getSerializedObject(java.lang.Integer id)
          Retrieves the raw SerializedObject from the database by id
 SerializedObject getSerializedObjectByUuid(java.lang.String uuid)
          Retrieves the raw Serialized Object from the database by uuid
 java.util.List<java.lang.Class<? extends OpenmrsObject>> getSupportedTypes()
           
 void purgeObject(java.lang.Integer id)
          Deletes the item from the database with the given primary key id
 void registerSupportedType(java.lang.Class<? extends OpenmrsObject> clazz)
          Registers a class as one that should be supported
<T extends OpenmrsObject>
T
saveObject(T object)
          Saves an object to the database in serialized form
<T extends OpenmrsObject>
T
saveObject(T object, OpenmrsSerializer serializer)
          Saves an object to the database, in serialized form, using the specified OpenmrsSerializer
 void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
          Set session factory
 void setSupportedTypes(java.util.List<java.lang.Class<? extends OpenmrsObject>> supportedTypes)
           
 void unregisterSupportedType(java.lang.Class<? extends OpenmrsObject> clazz)
          Removes this class as one that should be supported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Method Detail

getInstance

public static HibernateSerializedObjectDAO getInstance()
Singleton Factory method

Returns:
a singleton instance of this class

getSerializedObject

public SerializedObject getSerializedObject(java.lang.Integer id)
                                     throws DAOException
Description copied from interface: SerializedObjectDAO
Retrieves the raw SerializedObject from the database by id

Specified by:
getSerializedObject in interface SerializedObjectDAO
Parameters:
id - the id to lookup
Returns:
the SerializedObject with the given id
Throws:
DAOException
See Also:
SerializedObjectDAO.getSerializedObject(Integer)

getObject

public <T extends OpenmrsObject> T getObject(java.lang.Class<T> baseClass,
                                             java.lang.Integer id)
                                  throws DAOException
Description copied from interface: SerializedObjectDAO
Retrieves the saved object of the passed type from the database by it's id

Specified by:
getObject in interface SerializedObjectDAO
Parameters:
baseClass - The class of the object to retrieve
id - The primary key id of the object to retrieve
Returns:
the saved object
Throws:
DAOException
See Also:
SerializedObjectDAO.getObject(Class, Integer)

getSerializedObjectByUuid

public SerializedObject getSerializedObjectByUuid(java.lang.String uuid)
                                           throws DAOException
Description copied from interface: SerializedObjectDAO
Retrieves the raw Serialized Object from the database by uuid

Specified by:
getSerializedObjectByUuid in interface SerializedObjectDAO
Parameters:
uuid - The UUID of the object to retrieve
Returns:
the SerializedObject with the given uuid
Throws:
DAOException
See Also:
SerializedObjectDAO.getSerializedObjectByUuid(String)

getObjectByUuid

public <T extends OpenmrsObject> T getObjectByUuid(java.lang.Class<T> baseClass,
                                                   java.lang.String uuid)
                                        throws DAOException
Description copied from interface: SerializedObjectDAO
Retrieves the saved object of the passed type from the database by it's uuid

Specified by:
getObjectByUuid in interface SerializedObjectDAO
Parameters:
baseClass - The class of the object to retrieve
uuid - The UUID of the object to retrieve
Returns:
the saved object
Throws:
DAOException
See Also:
SerializedObjectDAO.getObjectByUuid(Class, String)

getAllSerializedObjectsByName

public java.util.List<SerializedObject> getAllSerializedObjectsByName(java.lang.Class<?> type,
                                                                      java.lang.String name,
                                                                      boolean exactMatchOnly)
                                                               throws DAOException
Description copied from interface: SerializedObjectDAO
Retrieves all raw Serialized Objects from the database that match the passed type and name

Specified by:
getAllSerializedObjectsByName in interface SerializedObjectDAO
Parameters:
type - The class of the object to retrieve
name - the name of the item to retrieve
exactMatchOnly - if true will only return exact matches
Returns:
T A list of all the saved objects that match the passed type and name
Throws:
DAOException
See Also:
SerializedObjectDAO#getAllObjectsByName(Class, String)

getAllObjectsByName

public <T extends OpenmrsMetadata> java.util.List<T> getAllObjectsByName(java.lang.Class<T> type,
                                                                         java.lang.String name,
                                                                         boolean exactMatchOnly)
                                                              throws DAOException
Description copied from interface: SerializedObjectDAO
Retrieves all objects from the database that match the passed type and name that have been saved through serialization

Specified by:
getAllObjectsByName in interface SerializedObjectDAO
Parameters:
type - The class of the object to retrieve
name - the name of the item to retrieve
exactMatchOnly - if true will only return exact matches
Returns:
T A list of all the saved objects that match the passed type and name
Throws:
DAOException
See Also:
SerializedObjectDAO#getAllObjectsByName(Class, String)

getAllSerializedObjects

public java.util.List<SerializedObject> getAllSerializedObjects(java.lang.Class<?> type,
                                                                boolean includeRetired)
                                                         throws DAOException
Description copied from interface: SerializedObjectDAO
Retrieves all raw Serialized Object from the database that match the passed type and includeRetired flag

Specified by:
getAllSerializedObjects in interface SerializedObjectDAO
Parameters:
type - The class of the object to retrieve
includeRetired - if true includes retired/voided objects, otherwise does not
Returns:
T A list of all the saved objects that match the passed type
Throws:
DAOException
See Also:
SerializedObjectDAO.getAllObjects(Class, boolean)

getAllObjects

public <T extends OpenmrsObject> java.util.List<T> getAllObjects(java.lang.Class<T> type,
                                                                 boolean includeRetired)
                                                      throws DAOException
Description copied from interface: SerializedObjectDAO
Retrieves all objects from the database that match the passed type that have been saved through serialization Returns voided / retired Objects only if includeRetired parameter is true

Specified by:
getAllObjects in interface SerializedObjectDAO
Parameters:
type - The class of the object to retrieve
includeRetired - includeRetired If true, returns voided/retired objects as well
Returns:
T A list of all the saved objects that match the passed type
Throws:
DAOException
See Also:
SerializedObjectDAO.getAllObjects(Class, boolean)

getAllObjects

public <T extends OpenmrsObject> java.util.List<T> getAllObjects(java.lang.Class<T> type)
                                                      throws DAOException
Description copied from interface: SerializedObjectDAO
Retrieves all non-retired objects of the passed type from the database that have been saved through serialization

Specified by:
getAllObjects in interface SerializedObjectDAO
Parameters:
type - The class of the object to retrieve
Returns:
T A list of all the saved objects that match the passed type
Throws:
DAOException
See Also:
SerializedObjectDAO.getAllObjects(Class)

saveObject

public <T extends OpenmrsObject> T saveObject(T object)
                                   throws DAOException
Description copied from interface: SerializedObjectDAO
Saves an object to the database in serialized form

Specified by:
saveObject in interface SerializedObjectDAO
Parameters:
object - The object to save
Returns:
the saved object
Throws:
DAOException
See Also:
SerializedObjectDAO.saveObject(OpenmrsObject)

saveObject

public <T extends OpenmrsObject> T saveObject(T object,
                                              OpenmrsSerializer serializer)
                                   throws DAOException
Description copied from interface: SerializedObjectDAO
Saves an object to the database, in serialized form, using the specified OpenmrsSerializer

Specified by:
saveObject in interface SerializedObjectDAO
Parameters:
object - The object to save
serializer - The OpenmrsSerializer to use
Returns:
the saved object
Throws:
DAOException
See Also:
SerializedObjectDAO.saveObject(OpenmrsObject, OpenmrsSerializer)

purgeObject

public void purgeObject(java.lang.Integer id)
                 throws DAOException
Description copied from interface: SerializedObjectDAO
Deletes the item from the database with the given primary key id

Specified by:
purgeObject in interface SerializedObjectDAO
Parameters:
id - The id of the item to delete from the database
Throws:
DAOException
See Also:
SerializedObjectDAO.purgeObject(Integer)

registerSupportedType

public void registerSupportedType(java.lang.Class<? extends OpenmrsObject> clazz)
                           throws DAOException
Description copied from interface: SerializedObjectDAO
Registers a class as one that should be supported

Specified by:
registerSupportedType in interface SerializedObjectDAO
Parameters:
clazz - The class to register
Throws:
DAOException
See Also:
SerializedObjectDAO.registerSupportedType(Class)

unregisterSupportedType

public void unregisterSupportedType(java.lang.Class<? extends OpenmrsObject> clazz)
                             throws DAOException
Description copied from interface: SerializedObjectDAO
Removes this class as one that should be supported

Specified by:
unregisterSupportedType in interface SerializedObjectDAO
Parameters:
clazz - The class to un-register
Throws:
DAOException
See Also:
SerializedObjectDAO.unregisterSupportedType(Class)

getRegisteredTypeForObject

public java.lang.Class<? extends OpenmrsObject> getRegisteredTypeForObject(OpenmrsObject object)
Description copied from interface: SerializedObjectDAO
Returns the registered class for the passed object, or null if none found For example, if the supportedTypes property contains the CohortDefinition.class interface, and a particular implementation of that interface is passed in, then this method would return CohortDefinition.class.

Specified by:
getRegisteredTypeForObject in interface SerializedObjectDAO
Parameters:
object - The object to check for the registered type
Returns:
The registered type for the passed object, or null if not found
See Also:
SerializedObjectDAO.getRegisteredTypeForObject(OpenmrsObject)

convertSerializedObject

public <T extends OpenmrsObject> T convertSerializedObject(java.lang.Class<T> clazz,
                                                           SerializedObject serializedObject)
                                                throws DAOException
Description copied from interface: SerializedObjectDAO
Converts a raw SerializedObject to an OpenmrsObject, using the appropriate Serializer

Specified by:
convertSerializedObject in interface SerializedObjectDAO
Parameters:
clazz - the OpenmrsObject class to retrieve
serializedObject - the raw SerializedObject to deserialize into an OpenmrsObject
Returns:
an OpenmrsObject of the passed clazz from the passed SerializedObject
Throws:
DAOException
See Also:
SerializedObjectDAO.convertSerializedObject(Class, SerializedObject)

setSessionFactory

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

Parameters:
sessionFactory -

getSupportedTypes

public java.util.List<java.lang.Class<? extends OpenmrsObject>> getSupportedTypes()
Specified by:
getSupportedTypes in interface SerializedObjectDAO
Returns:
the supportedTypes

setSupportedTypes

public void setSupportedTypes(java.util.List<java.lang.Class<? extends OpenmrsObject>> supportedTypes)
Parameters:
supportedTypes - the supportedTypes to set

OpenMRS-1.7.x

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