Interface EntityDomain
-
public interface EntityDomain
Entity domain interface. An EntityDomain a persistent storage backend such a SQL table or node in a JCR. Each persistent object in WM is stored in a particular Entity domain.- Author:
- n.milutinovic, bramk, bartk
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> T
copy(T entity, PersistenceContext persistenceContext)
Copies an entity which is not yet persisted (i.e.void
delete(Object entity, PersistenceContext persistenceContext)
Deletes an entity from the persistence backendObject
find(WmId primaryKey, PersistenceContext persistenceContext)
Looks up an entity by its id<T> Set<T>
getAll(Class<T> entity, PersistenceContext persistenceContext)
Returns all entities of the specified type.<T> T
getInstance(Class<T> entityClass)
Returns a newly created instance of the requested Class or an instance implementing the requested interface if the Class is an interface.Object
getInstance(String entityClassname)
Returns a newly created instance of the requested Class or an instance implementing the requested interface if the Class is an interface.String
getWmIdClassName()
Returns the class name of the WmId implementation for this EntityDomain.boolean
isManageable(Class<?> clazz)
Determine if the given class is manageable for the given domain.WmId
parseIdString(String wmId)
Parse string representation of the WM ID into WM ID for that particular domain.<T> T
persist(T entity, PersistenceContext persistenceContext)
Persists an entity which is not yet persisted (i.e.void
removeProperty(Object entity, String property, PersistenceContext persistenceContext)
Remove named property from the persistent image of the given entity.<T> T
save(T entity, PersistenceContext persistenceContext)
Saves an entity that was persisted before (i.e.
-
-
-
Method Detail
-
find
Object find(WmId primaryKey, PersistenceContext persistenceContext)
Looks up an entity by its id- Parameters:
primaryKey
- the id identifying the entity to loadpersistenceContext
-- Returns:
- the requested entity or null if it wasn't found
-
persist
<T> T persist(T entity, PersistenceContext persistenceContext)
Persists an entity which is not yet persisted (i.e. which doesn't have its' WmId filled in yet)- Type Parameters:
T
- The type of the entity to persist- Parameters:
entity
- The entity to persistpersistenceContext
-- Returns:
- The persisted entity with its WmId filled in.
-
copy
<T> T copy(T entity, PersistenceContext persistenceContext)
Copies an entity which is not yet persisted (i.e. which doesn't have its' WmId filled in yet)- Type Parameters:
T
- The type of the entity to copy- Parameters:
entity
- The entity to copypersistenceContext
-- Returns:
- The copied entity
-
delete
void delete(Object entity, PersistenceContext persistenceContext) throws DomainException
Deletes an entity from the persistence backend- Parameters:
entity
- The entity to be deletedpersistenceContext
-- Throws:
DomainException
- when something went wrong while deleting the entity
-
save
<T> T save(T entity, PersistenceContext persistenceContext) throws DomainException
Saves an entity that was persisted before (i.e. which does have its' WmId filled in)- Type Parameters:
T
- The type of the entity to persist- Parameters:
entity
- The entity to persistpersistenceContext
-- Returns:
- The entity
- Throws:
DomainException
- when something went wrong while saving the entity
-
getInstance
<T> T getInstance(Class<T> entityClass)
Returns a newly created instance of the requested Class or an instance implementing the requested interface if the Class is an interface. In order to persist such an entity, invoke thepersist()
method.- Type Parameters:
T
- The type of Class to instantiate- Parameters:
entityClass
- The Class to get an instance of (is generally the interface of the required Class)- Returns:
- a newly created instance of the requested Class
-
getAll
<T> Set<T> getAll(Class<T> entity, PersistenceContext persistenceContext)
Returns all entities of the specified type.- Type Parameters:
T
- The requested type- Parameters:
entity
- the Class of the requested typepersistenceContext
- persistence context for session handling.- Returns:
- all managed instances of the given class.
-
getInstance
Object getInstance(String entityClassname)
Returns a newly created instance of the requested Class or an instance implementing the requested interface if the Class is an interface. In order to persist such an entity, invoke thepersist()
method.- Parameters:
entityClassname
- The Class to get an instance of (is generally the interface of the required Class)- Returns:
- a newly created instance of the requested Class
-
parseIdString
WmId parseIdString(String wmId)
Parse string representation of the WM ID into WM ID for that particular domain.- Parameters:
wmId
- String representation of the WM ID.- Returns:
- parsed WM ID or
null
if the domain is not matched.
-
getWmIdClassName
String getWmIdClassName()
Returns the class name of the WmId implementation for this EntityDomain.- Returns:
- the class name of the WmId implementation for this EntityDomain
-
isManageable
boolean isManageable(Class<?> clazz)
Determine if the given class is manageable for the given domain. This most likely involves checking for proper annotations on the class.- Parameters:
clazz
- class to check for this entity domain.- Returns:
- whether or not the class is manageable by this entity domain.
-
removeProperty
void removeProperty(Object entity, String property, PersistenceContext persistenceContext)
Remove named property from the persistent image of the given entity.- Parameters:
entity
- entity for property removal.property
- name of the property to remove.persistenceContext
- persistence context for this operation.
-
-