eu.etaxonomy.cdm.persistence.dao.hibernate.common
Class VersionableDaoBase<T extends VersionableEntity>

java.lang.Object
  extended by eu.etaxonomy.cdm.persistence.dao.hibernate.common.DaoBase
      extended by eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase<T>
          extended by eu.etaxonomy.cdm.persistence.dao.hibernate.common.VersionableDaoBase<T>
All Implemented Interfaces:
ICdmEntityDao<T>, IVersionableDao<T>
Direct Known Subclasses:
AnnotatableDaoImpl, FeatureNodeDaoImpl, MarkerDaoImpl, PolytomousKeyNodeDaoImpl

public abstract class VersionableDaoBase<T extends VersionableEntity>
extends CdmEntityDaoBase<T>
implements IVersionableDao<T>


Field Summary
 
Fields inherited from class eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase
defaultBeanInitializer, flushAfterNo, type, version
 
Constructor Summary
VersionableDaoBase(Class<T> type)
           
 
Method Summary
protected  void addCriteria(org.hibernate.envers.query.AuditQuery query, List<org.hibernate.envers.query.criteria.AuditCriterion> criteria)
           
protected  void addOrder(org.hibernate.envers.query.AuditQuery query, List<OrderHint> orderHints)
           
protected  void checkNotInPriorView(String message)
           
 int count()
           
 int count(Class<? extends T> clazz)
          Returns the number of objects of type - which must extend T
 int count(T example, Set<String> includeProperties)
          Method that counts the number of objects matching the example provided.
 int countAuditEvents(Class<? extends T> clazz, AuditEvent from, AuditEvent to, List<org.hibernate.envers.query.criteria.AuditCriterion> criteria)
          Returns a count of the total number of audit events affecting objects of class T, optionally restricted to objects of class clazz, the AuditEvents from and to, inclusive, optionally filtered by other criteria
 int countAuditEvents(T t, AuditEventSort sort)
          Returns a count of audit events which affected the state of an entity t.
protected  int countByParam(Class<? extends T> clazz, String param, String queryString, MatchMode matchmode, List<org.hibernate.criterion.Criterion> criterion)
           
 Boolean exists(UUID uuid)
           
protected  List<T> findByParam(Class<? extends T> clazz, String param, String queryString, MatchMode matchmode, List<org.hibernate.criterion.Criterion> criterion, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths)
           
 T findByUuid(UUID uuid)
           
protected  AuditEvent getAuditEventFromContext()
           
 List<AuditEventRecord<T>> getAuditEvents(Class<? extends T> clazz, AuditEvent from, AuditEvent to, List<org.hibernate.envers.query.criteria.AuditCriterion> criteria, Integer pageSize, Integer pageNumber, AuditEventSort sort, List<String> propertyPaths)
          Returns a list of all audit events occurring to objects of type T, optionally restricted to objects of type clazz between the AuditEvents from and to, inclusive, optionally filtered by other criteria
 List<AuditEventRecord<T>> getAuditEvents(T t, Integer pageSize, Integer pageNumber, AuditEventSort sort, List<String> propertyPaths)
          Returns a list of audit events (in order) which affected the state of an entity t.
protected  org.hibernate.envers.AuditReader getAuditReader()
           
 AuditEventRecord<T> getNextAuditEvent(T t)
          A convenience method which returns a record of the next (relative to the audit event in context) audit event to affect the entity t.
 AuditEventRecord<T> getPreviousAuditEvent(T t)
          A convenience method which returns a record of the previous (relative to the audit event in context) audit event to affect the entity t.
 List<T> list(Class<? extends T> type, Integer limit, Integer start)
          Returns a sublist of CdmBase instances of type stored in the database.
 List<T> list(Class<? extends T> clazz, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths)
          Returns a sublist of CdmBase instances stored in the database.
 List<T> list(Integer limit, Integer start)
          Returns a sublist of CdmBase instances stored in the database.
 List<T> list(T example, Set<String> includeProperties, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths)
          Method that lists the objects matching the example provided.
 T load(UUID uuid)
          Finds the cdm entity specified by the uuid parameter and initializes all its *ToOne relations.
 T load(UUID uuid, List<String> propertyPaths)
          Finds the cdm entity specified by the uuid parameter and recursively initializes all bean properties given in the propertyPaths parameter.
 
Methods inherited from class eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase
addCriteria, addExample, addGroups, addOrder, clear, countGroups, delete, findById, getSession, getType, group, list, list, list, list, listByIds, load, lock, merge, refresh, refresh, replace, rows, save, saveAll, saveCdmObj, saveOrUpdate, saveOrUpdateAll, setDefaultBeanInitializer, setPagingParameter, setPagingParameter, update
 
Methods inherited from class eu.etaxonomy.cdm.persistence.dao.hibernate.common.DaoBase
addOrder, flush, getSessionFactory, setSessionFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface eu.etaxonomy.cdm.persistence.dao.common.ICdmEntityDao
clear, delete, findById, flush, getSession, getType, group, list, list, list, listByIds, load, lock, merge, refresh, refresh, replace, rows, save, saveAll, saveOrUpdate, saveOrUpdateAll, update
 

Constructor Detail

VersionableDaoBase

public VersionableDaoBase(Class<T> type)
Method Detail

getAuditReader

protected org.hibernate.envers.AuditReader getAuditReader()

getAuditEventFromContext

protected AuditEvent getAuditEventFromContext()

checkNotInPriorView

protected void checkNotInPriorView(String message)

findByUuid

public T findByUuid(UUID uuid)
Specified by:
findByUuid in interface ICdmEntityDao<T extends VersionableEntity>
Overrides:
findByUuid in class CdmEntityDaoBase<T extends VersionableEntity>
Returns:

findByParam

protected List<T> findByParam(Class<? extends T> clazz,
                              String param,
                              String queryString,
                              MatchMode matchmode,
                              List<org.hibernate.criterion.Criterion> criterion,
                              Integer pageSize,
                              Integer pageNumber,
                              List<OrderHint> orderHints,
                              List<String> propertyPaths)
Overrides:
findByParam in class CdmEntityDaoBase<T extends VersionableEntity>

load

public T load(UUID uuid)
Description copied from interface: ICdmEntityDao
Finds the cdm entity specified by the uuid parameter and initializes all its *ToOne relations.

Specified by:
load in interface ICdmEntityDao<T extends VersionableEntity>
Overrides:
load in class CdmEntityDaoBase<T extends VersionableEntity>
Returns:

load

public T load(UUID uuid,
              List<String> propertyPaths)
Description copied from interface: ICdmEntityDao
Finds the cdm entity specified by the uuid parameter and recursively initializes all bean properties given in the propertyPaths parameter.

For detailed description and examples please refer to: IBeanInitializer.initialize(Object, List)

Specified by:
load in interface ICdmEntityDao<T extends VersionableEntity>
Overrides:
load in class CdmEntityDaoBase<T extends VersionableEntity>
propertyPaths - properties to be initialized
Returns:

exists

public Boolean exists(UUID uuid)
Specified by:
exists in interface ICdmEntityDao<T extends VersionableEntity>
Overrides:
exists in class CdmEntityDaoBase<T extends VersionableEntity>
Returns:

count

public int count()
Specified by:
count in interface ICdmEntityDao<T extends VersionableEntity>
Overrides:
count in class CdmEntityDaoBase<T extends VersionableEntity>

count

public int count(Class<? extends T> clazz)
Description copied from interface: ICdmEntityDao
Returns the number of objects of type - which must extend T

Specified by:
count in interface ICdmEntityDao<T extends VersionableEntity>
Overrides:
count in class CdmEntityDaoBase<T extends VersionableEntity>
Returns:

list

public List<T> list(Integer limit,
                    Integer start)
Description copied from interface: ICdmEntityDao
Returns a sublist of CdmBase instances stored in the database. A maximum of 'limit' objects are returned, starting at object with index 'start'.

Specified by:
list in interface ICdmEntityDao<T extends VersionableEntity>
Overrides:
list in class CdmEntityDaoBase<T extends VersionableEntity>
Parameters:
limit - the maximum number of entities returned (can be null to return all entities)
Returns:

list

public List<T> list(Class<? extends T> type,
                    Integer limit,
                    Integer start)
Description copied from interface: ICdmEntityDao
Returns a sublist of CdmBase instances of type stored in the database. A maximum of 'limit' objects are returned, starting at object with index 'start'.

Specified by:
list in interface ICdmEntityDao<T extends VersionableEntity>
Overrides:
list in class CdmEntityDaoBase<T extends VersionableEntity>
limit - the maximum number of entities returned (can be null to return all entities)
Returns:

list

public List<T> list(Class<? extends T> clazz,
                    Integer limit,
                    Integer start,
                    List<OrderHint> orderHints,
                    List<String> propertyPaths)
Description copied from interface: ICdmEntityDao
Returns a sublist of CdmBase instances stored in the database. A maximum of 'limit' objects are returned, starting at object with index 'start'.

Specified by:
list in interface ICdmEntityDao<T extends VersionableEntity>
Overrides:
list in class CdmEntityDaoBase<T extends VersionableEntity>
limit - the maximum number of entities returned (can be null to return all entities)
orderHints - Supports path like orderHints.propertyNames which include *-to-one properties like createdBy.username or authorTeam.persistentTitleCache
Returns:

addOrder

protected void addOrder(org.hibernate.envers.query.AuditQuery query,
                        List<OrderHint> orderHints)

getAuditEvents

public List<AuditEventRecord<T>> getAuditEvents(T t,
                                                Integer pageSize,
                                                Integer pageNumber,
                                                AuditEventSort sort,
                                                List<String> propertyPaths)
Description copied from interface: IVersionableDao
Returns a list of audit events (in order) which affected the state of an entity t. The events returned either start at the AuditEvent in context and go forward in time (AuditEventSort.FORWARDS) or backwards in time (AuditEventSort.BACKWARDS). If the AuditEventContext is set to null, or to AuditEvent.CURRENT_VIEW, then all relevant AuditEvents are returned.

Specified by:
getAuditEvents in interface IVersionableDao<T extends VersionableEntity>
Parameters:
t - The versionable entity which was affected by the audit events
pageSize - The maximum number of audit event records returned (can be null for all audit event records)
pageNumber - The offset (in pageSize chunks) from the start of the result set (0 - based)
sort - should the list be sorted going forward in time (AuditEventSort.FORWARDS) or backwards (AuditEventSort.BACKWARDS)
propertyPaths - paths initialized on the returned audited objects
Returns:
a list of AuditEventRecords, containing the AuditEvent, the state of the entity at that event, and the type of modification

countAuditEvents

public int countAuditEvents(T t,
                            AuditEventSort sort)
Description copied from interface: IVersionableDao
Returns a count of audit events which affected the state of an entity t. The events either start at the AuditEvent in context and go forward in time (AuditEventSort.FORWARDS) or backwards in time (AuditEventSort.BACKWARDS). If the AuditEventContext is set to null, or to AuditEvent.CURRENT_VIEW, then all relevant AuditEvents are considered.

Specified by:
countAuditEvents in interface IVersionableDao<T extends VersionableEntity>
Parameters:
t - The versionable entity which was affected by the audit events
sort - should the events considered start now and go forward in time (AuditEventSort.FORWARDS) or backwards (AuditEventSort.BACKWARDS)
Returns:
a count of audit events

getNextAuditEvent

public AuditEventRecord<T> getNextAuditEvent(T t)
Description copied from interface: IVersionableDao
A convenience method which returns a record of the next (relative to the audit event in context) audit event to affect the entity t.

Specified by:
getNextAuditEvent in interface IVersionableDao<T extends VersionableEntity>
Parameters:
t - The versionable entity affected by these audit events
Returns:
a record of the next audit event to affect t, or null if the current event is the last to affect t

getPreviousAuditEvent

public AuditEventRecord<T> getPreviousAuditEvent(T t)
Description copied from interface: IVersionableDao
A convenience method which returns a record of the previous (relative to the audit event in context) audit event to affect the entity t.

Specified by:
getPreviousAuditEvent in interface IVersionableDao<T extends VersionableEntity>
Parameters:
t - The versionable entity affected by these audit events
Returns:
a record of the previous audit event to affect t, or null if the current event is the first to affect t

countAuditEvents

public int countAuditEvents(Class<? extends T> clazz,
                            AuditEvent from,
                            AuditEvent to,
                            List<org.hibernate.envers.query.criteria.AuditCriterion> criteria)
Description copied from interface: IVersionableDao
Returns a count of the total number of audit events affecting objects of class T, optionally restricted to objects of class clazz, the AuditEvents from and to, inclusive, optionally filtered by other criteria

Specified by:
countAuditEvents in interface IVersionableDao<T extends VersionableEntity>
Parameters:
clazz - Restrict the results returned to objects of this class
from - The audit event to start from (or pass null to start from the beginning of the recordset)
to - The audit event to continue until (or pass null to return audit events up to the time of the query)
criteria - Extra criteria to filter by
Returns:
the count of audit events

addCriteria

protected void addCriteria(org.hibernate.envers.query.AuditQuery query,
                           List<org.hibernate.envers.query.criteria.AuditCriterion> criteria)

getAuditEvents

public List<AuditEventRecord<T>> getAuditEvents(Class<? extends T> clazz,
                                                AuditEvent from,
                                                AuditEvent to,
                                                List<org.hibernate.envers.query.criteria.AuditCriterion> criteria,
                                                Integer pageSize,
                                                Integer pageNumber,
                                                AuditEventSort sort,
                                                List<String> propertyPaths)
Description copied from interface: IVersionableDao
Returns a list of all audit events occurring to objects of type T, optionally restricted to objects of type clazz between the AuditEvents from and to, inclusive, optionally filtered by other criteria

Specified by:
getAuditEvents in interface IVersionableDao<T extends VersionableEntity>
Parameters:
clazz - Restrict the results returned to objects of this class
from - The audit event to start from (inclusive, or pass null to start from the beginning of the recordset)
to - The audit event to continue until (exclusive, or pass null to return audit events up to the time of the query)
criteria - Extra criteria to filter by
pageSize - The maximum number of objects returned (can be null for all matching objects)
pageNumber - The offset (in pageSize chunks) from the start of the result set (0 - based, can be null, equivalent of starting at the beginning of the recordset)
sort - Sort the events either forwards or backwards in time
propertyPaths - properties to be initialized
Returns:

countByParam

protected int countByParam(Class<? extends T> clazz,
                           String param,
                           String queryString,
                           MatchMode matchmode,
                           List<org.hibernate.criterion.Criterion> criterion)
Overrides:
countByParam in class CdmEntityDaoBase<T extends VersionableEntity>

count

public int count(T example,
                 Set<String> includeProperties)
Description copied from interface: ICdmEntityDao
Method that counts the number of objects matching the example provided. The includeProperties property is used to specify which properties of the example are used. If includeProperties is null or empty, then all literal properties are used (restrictions are applied as in the Hibernate Query-By-Example API call Example.create(object)). If includeProperties is not empty then only literal properties that are named in the set are used to create restrictions, *PLUS* any *ToOne related entities. Related entities are matched on ID, not by their internal literal values (e.g. the call is criteria.add(Restrictions.eq(property,relatedObject)), not criteria.createCriteria(property).add(Example.create(relatedObject)))

Specified by:
count in interface ICdmEntityDao<T extends VersionableEntity>
Overrides:
count in class CdmEntityDaoBase<T extends VersionableEntity>
Returns:
a count of matching objects

list

public List<T> list(T example,
                    Set<String> includeProperties,
                    Integer limit,
                    Integer start,
                    List<OrderHint> orderHints,
                    List<String> propertyPaths)
Description copied from interface: ICdmEntityDao
Method that lists the objects matching the example provided. The includeProperties property is used to specify which properties of the example are used. If includeProperties is null or empty, then all literal properties are used (restrictions are applied as in the Hibernate Query-By-Example API call Example.create(object)). If includeProperties is not empty then only literal properties that are named in the set are used to create restrictions, *PLUS* any *ToOne related entities. Related entities are matched on ID, not by their internal literal values (e.g. the call is criteria.add(Restrictions.eq(property,relatedObject)), not criteria.createCriteria(property).add(Example.create(relatedObject)))

Specified by:
list in interface ICdmEntityDao<T extends VersionableEntity>
Overrides:
list in class CdmEntityDaoBase<T extends VersionableEntity>
limit - the maximum number of entities returned (can be null to return all entities)
start - The (0-based) offset from the start of the recordset
orderHints - Supports path like orderHints.propertyNames which include *-to-one properties like createdBy.username or
propertyPaths - paths initialized on the returned objects - only applied to the objects returned from the first grouping
Returns:
a list of matching objects


Copyright © 2007-2013 EDIT. All Rights Reserved.