public interface SerializedObjectDAO
MyOpenmrsObject m = getObject(MyOpenmrsObject.class, 10);The second form operates on SerializedObject instances directly, and provides the consumer with more control over how to handle these SerializedObjects. A typical reason why this might be useful is to provide graceful failure in the event that a persisted Object has had an API change, and thus would fail to deserialize properly. In this case, the consumer can use something like the following:
MyOpenmrsObject m = null; SerializedObject s = getSerializedObject(10); try { m = convertSerializedObject(MyOpenmrsObject.class, s); } catch (Exception e) { // Handle this exception however you need to for your use case. }
Modifier and Type | Method and Description |
---|---|
<T extends OpenmrsObject> |
convertSerializedObject(java.lang.Class<T> clazz,
SerializedObject serializedObject)
Converts a raw SerializedObject to an OpenmrsObject, using the appropriate Serializer
|
<T extends OpenmrsObject> |
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> |
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> |
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
|
<T extends OpenmrsObject> |
getObject(java.lang.Class<T> type,
java.lang.Integer id)
Retrieves the saved object of the passed type from the database by it's id
|
<T extends OpenmrsObject> |
getObjectByUuid(java.lang.Class<T> type,
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> |
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 |
unregisterSupportedType(java.lang.Class<? extends OpenmrsObject> clazz)
Removes this class as one that should be supported
|
SerializedObject getSerializedObject(java.lang.Integer id) throws DAOException
id
- the id to lookupDAOException
<T extends OpenmrsObject> T getObject(java.lang.Class<T> type, java.lang.Integer id) throws DAOException
type
- The class of the object to retrieveid
- The primary key id of the object to retrieveDAOException
SerializedObject getSerializedObjectByUuid(java.lang.String uuid) throws DAOException
uuid
- The UUID of the object to retrieveDAOException
<T extends OpenmrsObject> T getObjectByUuid(java.lang.Class<T> type, java.lang.String uuid) throws DAOException
type
- The class of the object to retrieveuuid
- The UUID of the object to retrieveDAOException
<T extends OpenmrsObject> T saveObject(T object) throws DAOException
object
- The object to saveDAOException
<T extends OpenmrsObject> T saveObject(T object, OpenmrsSerializer serializer) throws DAOException
OpenmrsSerializer
object
- The object to saveserializer
- The OpenmrsSerializer
to useDAOException
java.util.List<SerializedObject> getAllSerializedObjects(java.lang.Class<?> type, boolean includeRetired) throws DAOException
type
- The class of the object to retrieveincludeRetired
- if true includes retired/voided objects, otherwise does notDAOException
<T extends OpenmrsObject> java.util.List<T> getAllObjects(java.lang.Class<T> type) throws DAOException
type
- The class of the object to retrieveDAOException
<T extends OpenmrsObject> java.util.List<T> getAllObjects(java.lang.Class<T> type, boolean includeRetired) throws DAOException
type
- The class of the object to retrieveincludeRetired
- includeRetired If true, returns voided/retired objects as wellDAOException
java.util.List<SerializedObject> getAllSerializedObjectsByName(java.lang.Class<?> type, java.lang.String name, boolean exactMatchOnly) throws DAOException
type
- The class of the object to retrievename
- the name of the item to retrieveexactMatchOnly
- if true will only return exact matchesDAOException
<T extends OpenmrsMetadata> java.util.List<T> getAllObjectsByName(java.lang.Class<T> type, java.lang.String name, boolean exactMatchOnly) throws DAOException
type
- The class of the object to retrievename
- the name of the item to retrieveexactMatchOnly
- if true will only return exact matchesDAOException
<T extends OpenmrsObject> T convertSerializedObject(java.lang.Class<T> clazz, SerializedObject serializedObject) throws DAOException
clazz
- the OpenmrsObject class to retrieveserializedObject
- the raw SerializedObject to deserialize into an OpenmrsObjectDAOException
void purgeObject(java.lang.Integer id) throws DAOException
id
- The id of the item to delete from the databaseDAOException
java.lang.Class<? extends OpenmrsObject> getRegisteredTypeForObject(OpenmrsObject object)
object
- The object to check for the registered typejava.util.List<java.lang.Class<? extends OpenmrsObject>> getSupportedTypes()
void registerSupportedType(java.lang.Class<? extends OpenmrsObject> clazz) throws DAOException
clazz
- The class to registerDAOException
void unregisterSupportedType(java.lang.Class<? extends OpenmrsObject> clazz) throws DAOException
clazz
- The class to un-registerDAOException
Copyright © 2018 OpenMRS Inc.. All Rights Reserved.