public class HibernateSerializedObjectDAO extends Object implements SerializedObjectDAO
Modifier and Type | Method and Description |
---|---|
<T extends OpenmrsObject> |
convertSerializedObject(Class<T> clazz,
SerializedObject serializedObject)
Converts a raw SerializedObject to an OpenmrsObject, using the appropriate Serializer
|
<T extends OpenmrsObject> |
getAllObjects(Class<T> type)
Retrieves all non-retired objects of the passed type from the database that have been saved
through serialization
|
<T extends OpenmrsObject> |
getAllObjects(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> |
getAllObjectsByName(Class<T> type,
String name,
boolean exactMatchOnly)
Retrieves all objects from the database that match the passed type and name that have been
saved through serialization
|
List<SerializedObject> |
getAllSerializedObjects(Class<?> type,
boolean includeRetired)
Retrieves all raw Serialized Object from the database that match the passed type and
includeRetired flag
|
List<SerializedObject> |
getAllSerializedObjectsByName(Class<?> type,
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> |
getObject(Class<T> baseClass,
Integer id)
Retrieves the saved object of the passed type from the database by it's id
|
<T extends OpenmrsObject> |
getObjectByUuid(Class<T> baseClass,
String uuid)
Retrieves the saved object of the passed type from the database by it's uuid
|
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(Integer id)
Retrieves the raw SerializedObject from the database by id
|
SerializedObject |
getSerializedObjectByUuid(String uuid)
Retrieves the raw Serialized Object from the database by uuid
|
List<Class<? extends OpenmrsObject>> |
getSupportedTypes() |
void |
purgeObject(Integer id)
Deletes the item from the database with the given primary key id
|
void |
registerSupportedType(Class<? extends OpenmrsObject> clazz)
Registers a class as one that should be supported
|
<T extends OpenmrsObject> |
saveObject(T object)
Saves an object to the database in serialized form
|
<T extends OpenmrsObject> |
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(List<Class<? extends OpenmrsObject>> supportedTypes) |
void |
unregisterSupportedType(Class<? extends OpenmrsObject> clazz)
Removes this class as one that should be supported
|
public static HibernateSerializedObjectDAO getInstance()
public SerializedObject getSerializedObject(Integer id) throws DAOException
SerializedObjectDAO
getSerializedObject
in interface SerializedObjectDAO
id
- the id to lookupDAOException
- Should return the saved serialized objectSerializedObjectDAO.getSerializedObject(Integer)
public <T extends OpenmrsObject> T getObject(Class<T> baseClass, Integer id) throws DAOException
SerializedObjectDAO
getObject
in interface SerializedObjectDAO
baseClass
- The class of the object to retrieveid
- The primary key id of the object to retrieveDAOException
- Should return the saved objectSerializedObjectDAO.getObject(Class, Integer)
public SerializedObject getSerializedObjectByUuid(String uuid) throws DAOException
SerializedObjectDAO
getSerializedObjectByUuid
in interface SerializedObjectDAO
uuid
- The UUID of the object to retrieveDAOException
- Should return the saved serialized objectSerializedObjectDAO.getSerializedObjectByUuid(String)
public <T extends OpenmrsObject> T getObjectByUuid(Class<T> baseClass, String uuid) throws DAOException
SerializedObjectDAO
getObjectByUuid
in interface SerializedObjectDAO
baseClass
- The class of the object to retrieveuuid
- The UUID of the object to retrieveDAOException
- Should return the saved objectSerializedObjectDAO.getObjectByUuid(Class, String)
public List<SerializedObject> getAllSerializedObjectsByName(Class<?> type, String name, boolean exactMatchOnly) throws DAOException
SerializedObjectDAO
getAllSerializedObjectsByName
in interface SerializedObjectDAO
type
- The class of the object to retrievename
- the name of the item to retrieveexactMatchOnly
- if true will only return exact matchesDAOException
- Should return all saved objects with the given type and exact name
Should return all saved objects with the given type and partial nameSerializedObjectDAO.getAllSerializedObjectsByName(Class, String, boolean)
public <T extends OpenmrsMetadata> List<T> getAllObjectsByName(Class<T> type, String name, boolean exactMatchOnly) throws DAOException
SerializedObjectDAO
getAllObjectsByName
in interface SerializedObjectDAO
type
- The class of the object to retrievename
- the name of the item to retrieveexactMatchOnly
- if true will only return exact matchesDAOException
- Should return all saved objects with the given type and exact name
Should return all saved objects with the given type and partial nameSerializedObjectDAO.getAllObjectsByName(Class, String, boolean)
public List<SerializedObject> getAllSerializedObjects(Class<?> type, boolean includeRetired)
SerializedObjectDAO
getAllSerializedObjects
in interface SerializedObjectDAO
type
- The class of the object to retrieveincludeRetired
- if true includes retired/voided objects, otherwise does notSerializedObjectDAO.getAllObjects(Class, boolean)
public <T extends OpenmrsObject> List<T> getAllObjects(Class<T> type, boolean includeRetired) throws DAOException
SerializedObjectDAO
getAllObjects
in interface SerializedObjectDAO
type
- The class of the object to retrieveincludeRetired
- includeRetired If true, returns voided/retired objects as wellDAOException
- Should return all saved objects of the passed type if includeRetired
Should return only non-retired objects of the passed type if not includeRetiredSerializedObjectDAO.getAllObjects(Class, boolean)
public <T extends OpenmrsObject> List<T> getAllObjects(Class<T> type) throws DAOException
SerializedObjectDAO
getAllObjects
in interface SerializedObjectDAO
type
- The class of the object to retrieveDAOException
- Should return all non-retired objects of the passed typeSerializedObjectDAO.getAllObjects(Class)
public <T extends OpenmrsObject> T saveObject(T object) throws DAOException
SerializedObjectDAO
saveObject
in interface SerializedObjectDAO
object
- The object to saveDAOException
- Should save the passed object if supported
Should throw an exception if object not supportedSerializedObjectDAO.saveObject(OpenmrsObject)
public <T extends OpenmrsObject> T saveObject(T object, OpenmrsSerializer serializer) throws DAOException
SerializedObjectDAO
OpenmrsSerializer
saveObject
in interface SerializedObjectDAO
object
- The object to saveserializer
- The OpenmrsSerializer
to useDAOException
- Should save the passed object if supported
Should throw an exception if object not supported
Should set auditable fields before serializingSerializedObjectDAO.saveObject(OpenmrsObject, OpenmrsSerializer)
public void purgeObject(Integer id) throws DAOException
SerializedObjectDAO
purgeObject
in interface SerializedObjectDAO
id
- The id of the item to delete from the databaseDAOException
- Should delete the object with the passed idSerializedObjectDAO.purgeObject(Integer)
public void registerSupportedType(Class<? extends OpenmrsObject> clazz) throws DAOException
SerializedObjectDAO
registerSupportedType
in interface SerializedObjectDAO
clazz
- The class to registerDAOException
SerializedObjectDAO.registerSupportedType(Class)
public void unregisterSupportedType(Class<? extends OpenmrsObject> clazz) throws DAOException
SerializedObjectDAO
unregisterSupportedType
in interface SerializedObjectDAO
clazz
- The class to un-registerDAOException
SerializedObjectDAO.unregisterSupportedType(Class)
public Class<? extends OpenmrsObject> getRegisteredTypeForObject(OpenmrsObject object)
SerializedObjectDAO
getRegisteredTypeForObject
in interface SerializedObjectDAO
object
- The object to check for the registered typeSerializedObjectDAO.getRegisteredTypeForObject(OpenmrsObject)
public <T extends OpenmrsObject> T convertSerializedObject(Class<T> clazz, SerializedObject serializedObject) throws DAOException
SerializedObjectDAO
convertSerializedObject
in interface SerializedObjectDAO
clazz
- the OpenmrsObject class to retrieveserializedObject
- the raw SerializedObject to deserialize into an OpenmrsObjectDAOException
SerializedObjectDAO.convertSerializedObject(Class, SerializedObject)
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
sessionFactory
- public List<Class<? extends OpenmrsObject>> getSupportedTypes()
getSupportedTypes
in interface SerializedObjectDAO
public void setSupportedTypes(List<Class<? extends OpenmrsObject>> supportedTypes)
supportedTypes
- the supportedTypes to setCopyright © 2024 OpenMRS Inc.. All rights reserved.