nl.gx.webmanager.services.entitymanager
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
<T> T
copy(T entity, PersistenceContext persistenceContext)
          Copies an entity which is not yet persisted (i.e.
 void delete(java.lang.Object entity, PersistenceContext persistenceContext)
          Deletes an entity from the persistence backend
 java.lang.Object find(WmId primaryKey, PersistenceContext persistenceContext)
          Looks up an entity by its id
<T> java.util.Set<T>
getAll(java.lang.Class<T> entity, PersistenceContext persistenceContext)
          Returns all entities of the specified type.
<T> T
getInstance(java.lang.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.
 java.lang.Object getInstance(java.lang.String entityClassname)
          Returns a newly created instance of the requested Class or an instance implementing the requested interface if the Class is an interface.
 java.lang.String getWmIdClassName()
          Returns the class name of the WmId implementation for this EntityDomain.
 boolean isManageable(java.lang.Class<?> clazz)
          Determine if the given class is manageable for the given domain.
 WmId parseIdString(java.lang.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(java.lang.Object entity, java.lang.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

java.lang.Object find(WmId primaryKey,
                      PersistenceContext persistenceContext)
Looks up an entity by its id

Parameters:
primaryKey - the id identifying the entity to load
persistenceContext -
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 persist
persistenceContext -
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 copy
persistenceContext -
Returns:
The copied entity

delete

void delete(java.lang.Object entity,
            PersistenceContext persistenceContext)
            throws DomainException
Deletes an entity from the persistence backend

Parameters:
entity - The entity to be deleted
persistenceContext -
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 persist
persistenceContext -
Returns:
The entity
Throws:
DomainException - when something went wrong while saving the entity

getInstance

<T> T getInstance(java.lang.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 the persist() 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> java.util.Set<T> getAll(java.lang.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 type
persistenceContext - persistence context for session handling.
Returns:
all managed instances of the given class.

getInstance

java.lang.Object getInstance(java.lang.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 the persist() 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(java.lang.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

java.lang.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(java.lang.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(java.lang.Object entity,
                    java.lang.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.


Copyright © 2007-2011 GX Software BV. All Rights Reserved.