eu.etaxonomy.cdm.persistence.dao.hibernate.common
Class IdentifiableDaoBase<T extends IdentifiableEntity>

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>
              extended by eu.etaxonomy.cdm.persistence.dao.hibernate.common.AnnotatableDaoImpl<T>
                  extended by eu.etaxonomy.cdm.persistence.dao.hibernate.common.IdentifiableDaoBase<T>
All Implemented Interfaces:
IAnnotatableDao<T>, ICdmEntityDao<T>, IIdentifiableDao<T>, ISearchableDao<T>, ITitledDao<T>, IVersionableDao<T>
Direct Known Subclasses:
AgentDaoImpl, ClassificationDaoHibernateImpl, CollectionDaoHibernateImpl, DefinedTermDaoImpl, DescriptionDaoImpl, FeatureTreeDaoImpl, MediaDaoHibernateImpl, OccurrenceDaoHibernateImpl, PolytomousKeyDaoImpl, ReferenceDaoHibernateImpl, TaxonDaoHibernateImpl, TaxonNameDaoHibernateImpl, TermVocabularyDaoImpl

public class IdentifiableDaoBase<T extends IdentifiableEntity>
extends AnnotatableDaoImpl<T>
implements IIdentifiableDao<T>


Field Summary
protected  String defaultField
           
protected  Class<? extends T>[] indexedClasses
           
 
Fields inherited from class eu.etaxonomy.cdm.persistence.dao.hibernate.common.CdmEntityDaoBase
defaultBeanInitializer, flushAfterNo, type, version
 
Constructor Summary
IdentifiableDaoBase(Class<T> type)
           
 
Method Summary
 int count(Class<? extends T> clazz, String queryString)
          Returns a count of T instances where entities match a given queryString (as interpreted by the Lucene QueryParser)
 int countByReferenceTitle(Class<? extends T> clazz, String queryString, MatchMode matchmode, List<org.hibernate.criterion.Criterion> criterion)
          Return a count of objects matching the given query string in the title, optionally filtered by class, optionally with a particular MatchMode
 int countByTitle(Class<? extends T> clazz, String queryString, MatchMode matchmode, List<org.hibernate.criterion.Criterion> criterion)
          Return a count of objects matching the given query string in the titleCache, optionally filtered by class, optionally with a particular MatchMode
 Integer countByTitle(String queryString)
           
 Integer countByTitle(String queryString, CdmBase sessionObject)
           
 Integer countByTitle(String queryString, MatchMode matchMode, List<org.hibernate.criterion.Criterion> criteria)
           
 int countRights(T identifiableEntity)
          Return a count of the rights for this identifiable entity
 int countSources(T identifiableEntity)
          Return a count of the sources for this identifiable entity
 Long countTitleCache(Class<? extends T> clazz, String queryString, MatchMode matchMode)
          Return a count of distinct titleCache Strings for a given IdentifiableEntity, optionally filtered by class, optionally with a particular MatchMode
 T find(LSID lsid)
          Return an object by LSID.
 List<T> findByReferenceTitle(Class<? extends T> clazz, String queryString, MatchMode matchmode, List<org.hibernate.criterion.Criterion> criterion, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths)
          Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
 List<T> findByTitle(Class<? extends T> clazz, String queryString, MatchMode matchmode, List<org.hibernate.criterion.Criterion> criterion, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths)
          Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
 List<T> findByTitle(String queryString)
           
 List<T> findByTitle(String queryString, CdmBase sessionObject)
           
 List<T> findByTitle(String queryString, MatchMode matchmode, int page, int pagesize, List<org.hibernate.criterion.Criterion> criteria)
           
 List<T> findByTitleAndClass(String queryString, Class<T> clazz)
           
 List<T> findOriginalSourceByIdInSource(String idInSource, String idNamespace)
           
 List<T> findTitleCache(Class<? extends T> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, MatchMode matchMode)
          TODO
 List<Credit> getCredits(T identifiableEntity, Integer pageSize, Integer pageNumber)
           
 List<Rights> getRights(T identifiableEntity, Integer pageSize, Integer pageNumber, List<String> propertyPaths)
          Return a List of the rights for this identifiable entity
 List<IdentifiableSource> getSources(T identifiableEntity, Integer pageSize, Integer pageNumber, List<String> propertyPaths)
          Return a List of the sources for this identifiable entity
 List<UuidAndTitleCache<T>> getUuidAndTitleCache()
          Return a list of all uuids mapped to titleCache in the convenient UuidAndTitleCache object.
protected
<E extends IIdentifiableEntity>
List<UuidAndTitleCache<E>>
getUuidAndTitleCache(org.hibernate.Query query)
           
 void optimizeIndex()
          Calls optimize on the relevant index (useful periodically to increase response times on the free-text search)
 void purgeIndex()
          Removes all entities of type T from the index
 void rebuildIndex()
          Index all T entities currently in the database (useful in concert with purgeIndex() to (re-)create indexes or in the case of corrupt indexes / mismatch between the database and the free-text indices)
 List<T> search(Class<? extends T> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths)
          Returns a List of T instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
 String suggestQuery(String string)
          Suggest a query that will return hits based upon an existing lucene query string (that is presumably misspelt and returns no hits) Used to implement "did you mean?"-type functionality using the lucene spellchecker.
 
Methods inherited from class eu.etaxonomy.cdm.persistence.dao.hibernate.common.AnnotatableDaoImpl
countAnnotations, countMarkers, countMarkers, getAnnotations, getMarkers, groupMarkers
 
Methods inherited from class eu.etaxonomy.cdm.persistence.dao.hibernate.common.VersionableDaoBase
addCriteria, addOrder, checkNotInPriorView, count, count, count, countAuditEvents, countAuditEvents, countByParam, exists, findByParam, findByUuid, getAuditEventFromContext, getAuditEvents, getAuditEvents, getAuditReader, getNextAuditEvent, getPreviousAuditEvent, list, list, list, list, load, load
 
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.IAnnotatableDao
countAnnotations, countMarkers, countMarkers, getAnnotations, getMarkers, groupMarkers
 
Methods inherited from interface eu.etaxonomy.cdm.persistence.dao.common.IVersionableDao
countAuditEvents, countAuditEvents, getAuditEvents, getAuditEvents, getNextAuditEvent, getPreviousAuditEvent
 
Methods inherited from interface eu.etaxonomy.cdm.persistence.dao.common.ICdmEntityDao
clear, count, count, count, delete, exists, findById, findByUuid, flush, getSession, getType, group, list, list, list, list, list, list, list, listByIds, load, load, load, lock, merge, refresh, refresh, replace, rows, save, saveAll, saveOrUpdate, saveOrUpdateAll, update
 

Field Detail

defaultField

protected String defaultField

indexedClasses

protected Class<? extends T extends IdentifiableEntity>[] indexedClasses
Constructor Detail

IdentifiableDaoBase

public IdentifiableDaoBase(Class<T> type)
Method Detail

findByTitle

public List<T> findByTitle(String queryString)
Specified by:
findByTitle in interface ITitledDao<T extends IdentifiableEntity>
Returns:

findByTitle

public List<T> findByTitle(String queryString,
                           CdmBase sessionObject)
Specified by:
findByTitle in interface ITitledDao<T extends IdentifiableEntity>
Returns:

findByTitleAndClass

public List<T> findByTitleAndClass(String queryString,
                                   Class<T> clazz)
Specified by:
findByTitleAndClass in interface ITitledDao<T extends IdentifiableEntity>

findTitleCache

public List<T> findTitleCache(Class<? extends T> clazz,
                              String queryString,
                              Integer pageSize,
                              Integer pageNumber,
                              List<OrderHint> orderHints,
                              MatchMode matchMode)
Description copied from interface: IIdentifiableDao
TODO

Specified by:
findTitleCache in interface IIdentifiableDao<T extends IdentifiableEntity>
Returns:

countTitleCache

public Long countTitleCache(Class<? extends T> clazz,
                            String queryString,
                            MatchMode matchMode)
Description copied from interface: IIdentifiableDao
Return a count of distinct titleCache Strings for a given IdentifiableEntity, optionally filtered by class, optionally with a particular MatchMode

Specified by:
countTitleCache in interface IIdentifiableDao<T extends IdentifiableEntity>
Parameters:
clazz - filter by class - can be null to include all instances of type T
queryString - the query string to filter by
Returns:
a count of instances of type T matching the queryString

findByTitle

public List<T> findByTitle(Class<? extends T> clazz,
                           String queryString,
                           MatchMode matchmode,
                           List<org.hibernate.criterion.Criterion> criterion,
                           Integer pageSize,
                           Integer pageNumber,
                           List<OrderHint> orderHints,
                           List<String> propertyPaths)
Description copied from interface: IIdentifiableDao
Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode

Specified by:
findByTitle in interface IIdentifiableDao<T extends IdentifiableEntity>
Parameters:
clazz - filter by class - can be null to include all instances of type T
queryString - the query string to filter by
matchmode - use a particular type of matching (can be null - defaults to exact matching)
criterion - extra restrictions to apply
pageSize - The maximum number of rights returned (can be null for all rights)
pageNumber - The offset (in pageSize chunks) from the start of the result set (0 - based)
orderHints - Supports path like orderHints.propertyNames which include *-to-one properties like createdBy.username or authorTeam.persistentTitleCache
propertyPaths - properties to initialize - see IBeanInitializer.initialize(Object, List)
Returns:
a List of instances of type T matching the queryString

findByReferenceTitle

public List<T> findByReferenceTitle(Class<? extends T> clazz,
                                    String queryString,
                                    MatchMode matchmode,
                                    List<org.hibernate.criterion.Criterion> criterion,
                                    Integer pageSize,
                                    Integer pageNumber,
                                    List<OrderHint> orderHints,
                                    List<String> propertyPaths)
Description copied from interface: IIdentifiableDao
Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode

Specified by:
findByReferenceTitle in interface IIdentifiableDao<T extends IdentifiableEntity>
Parameters:
clazz - filter by class - can be null to include all instances of type T
queryString - the query string to filter by
matchmode - use a particular type of matching (can be null - defaults to exact matching)
criterion - extra restrictions to apply
pageSize - The maximum number of rights returned (can be null for all rights)
pageNumber - The offset (in pageSize chunks) from the start of the result set (0 - based)
orderHints - Supports path like orderHints.propertyNames which include *-to-one properties like createdBy.username or authorTeam.persistentTitleCache
propertyPaths - properties to initialize - see IBeanInitializer.initialize(Object, List)
Returns:
a List of instances of type T matching the queryString

findByTitle

public List<T> findByTitle(String queryString,
                           MatchMode matchmode,
                           int page,
                           int pagesize,
                           List<org.hibernate.criterion.Criterion> criteria)
Specified by:
findByTitle in interface ITitledDao<T extends IdentifiableEntity>
criteria - TODO
Returns:

countRights

public int countRights(T identifiableEntity)
Description copied from interface: IIdentifiableDao
Return a count of the rights for this identifiable entity

Specified by:
countRights in interface IIdentifiableDao<T extends IdentifiableEntity>
Parameters:
identifiableEntity - The identifiable entity
Returns:
a count of Rights instances

countSources

public int countSources(T identifiableEntity)
Description copied from interface: IIdentifiableDao
Return a count of the sources for this identifiable entity

Specified by:
countSources in interface IIdentifiableDao<T extends IdentifiableEntity>
Parameters:
identifiableEntity - The identifiable entity
Returns:
a count of OriginalSource instances

getRights

public List<Rights> getRights(T identifiableEntity,
                              Integer pageSize,
                              Integer pageNumber,
                              List<String> propertyPaths)
Description copied from interface: IIdentifiableDao
Return a List of the rights for this identifiable entity

Specified by:
getRights in interface IIdentifiableDao<T extends IdentifiableEntity>
Parameters:
identifiableEntity - The identifiable entity
pageSize - The maximum number of rights returned (can be null for all rights)
pageNumber - The offset (in pageSize chunks) from the start of the result set (0 - based)
propertyPaths - properties to initialize - see IBeanInitializer.initialize(Object, List)
Returns:
a List of Rights instances

getCredits

public List<Credit> getCredits(T identifiableEntity,
                               Integer pageSize,
                               Integer pageNumber)

getSources

public List<IdentifiableSource> getSources(T identifiableEntity,
                                           Integer pageSize,
                                           Integer pageNumber,
                                           List<String> propertyPaths)
Description copied from interface: IIdentifiableDao
Return a List of the sources for this identifiable entity

Specified by:
getSources in interface IIdentifiableDao<T extends IdentifiableEntity>
Parameters:
identifiableEntity - The identifiable entity
pageSize - The maximum number of sources returned (can be null for all sources)
pageNumber - The offset (in pageSize chunks) from the start of the result set (0 - based)
propertyPaths - properties to initialize - see IBeanInitializer.initialize(Object, List)
Returns:
a List of OriginalSource instances

findOriginalSourceByIdInSource

public List<T> findOriginalSourceByIdInSource(String idInSource,
                                              String idNamespace)
Specified by:
findOriginalSourceByIdInSource in interface IIdentifiableDao<T extends IdentifiableEntity>

find

public T find(LSID lsid)
Description copied from interface: IIdentifiableDao
Return an object by LSID. NOTE: Because of the fact that LSIDs are supposed to be globally resolvable, this method behaves in a different way to other methods In short, it attempts to find an object of type T in the current view using the LSID passed. If the LSID passed has a revision part, then this will be used in the query, but if not, then it is expected that the request is for the 'current' version of the object and the revision part will not be used as a matching criteria in the query. If the object does not appear in the current view (i.e. it has been deleted), then this method will search the history tables for a match, again using the revision if it exists, but ignoring it if not.

Specified by:
find in interface IIdentifiableDao<T extends IdentifiableEntity>
Parameters:
lsid - a LifeScience Identifier identifying the desired object

getUuidAndTitleCache

public List<UuidAndTitleCache<T>> getUuidAndTitleCache()
Description copied from interface: IIdentifiableDao
Return a list of all uuids mapped to titleCache in the convenient UuidAndTitleCache object. Retrieving this list is considered to be significantly faster than initializing the fully fledged buiseness objects. To be used in cases where you want to present large amount of data and provide details after a selection has been made.

Specified by:
getUuidAndTitleCache in interface IIdentifiableDao<T extends IdentifiableEntity>
Returns:
a list of UuidAndTitleCache instances

getUuidAndTitleCache

protected <E extends IIdentifiableEntity> List<UuidAndTitleCache<E>> getUuidAndTitleCache(org.hibernate.Query query)

countByTitle

public int countByTitle(Class<? extends T> clazz,
                        String queryString,
                        MatchMode matchmode,
                        List<org.hibernate.criterion.Criterion> criterion)
Description copied from interface: IIdentifiableDao
Return a count of objects matching the given query string in the titleCache, optionally filtered by class, optionally with a particular MatchMode

Specified by:
countByTitle in interface IIdentifiableDao<T extends IdentifiableEntity>
Parameters:
clazz - filter by class - can be null to include all instances of type T
queryString - the query string to filter by
matchmode - use a particular type of matching (can be null - defaults to exact matching)
criterion - extra restrictions to apply
Returns:
a count of instances of type T matching the queryString

countByReferenceTitle

public int countByReferenceTitle(Class<? extends T> clazz,
                                 String queryString,
                                 MatchMode matchmode,
                                 List<org.hibernate.criterion.Criterion> criterion)
Description copied from interface: IIdentifiableDao
Return a count of objects matching the given query string in the title, optionally filtered by class, optionally with a particular MatchMode

Specified by:
countByReferenceTitle in interface IIdentifiableDao<T extends IdentifiableEntity>
Parameters:
clazz - filter by class - can be null to include all instances of type T
queryString - the query string to filter by
matchmode - use a particular type of matching (can be null - defaults to exact matching)
criterion - extra restrictions to apply
Returns:
a count of instances of type T matching the queryString

count

public int count(Class<? extends T> clazz,
                 String queryString)
Description copied from interface: ISearchableDao
Returns a count of T instances where entities match a given queryString (as interpreted by the Lucene QueryParser)

Specified by:
count in interface ISearchableDao<T extends IdentifiableEntity>
Parameters:
clazz - filter the results by class (or pass null to count all entities of type T)
Returns:
a count of the matching entities
See Also:
Apache Lucene - Query Parser Syntax

optimizeIndex

public void optimizeIndex()
Description copied from interface: ISearchableDao
Calls optimize on the relevant index (useful periodically to increase response times on the free-text search)

Specified by:
optimizeIndex in interface ISearchableDao<T extends IdentifiableEntity>

purgeIndex

public void purgeIndex()
Description copied from interface: ISearchableDao
Removes all entities of type T from the index

Specified by:
purgeIndex in interface ISearchableDao<T extends IdentifiableEntity>

rebuildIndex

public void rebuildIndex()
Description copied from interface: ISearchableDao
Index all T entities currently in the database (useful in concert with purgeIndex() to (re-)create indexes or in the case of corrupt indexes / mismatch between the database and the free-text indices)

Specified by:
rebuildIndex in interface ISearchableDao<T extends IdentifiableEntity>

search

public List<T> search(Class<? extends T> clazz,
                      String queryString,
                      Integer pageSize,
                      Integer pageNumber,
                      List<OrderHint> orderHints,
                      List<String> propertyPaths)
Description copied from interface: ISearchableDao
Returns a List of T instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)

Specified by:
search in interface ISearchableDao<T extends IdentifiableEntity>
Parameters:
clazz - filter the results by class (or pass null to return all entities of type T)
pageSize - The maximum number of entities returned (can be null for all matching entities)
pageNumber - The offset (in pageSize chunks) from the start of the result set (0 - based)
orderHints - Supports path like orderHints.propertyNames which include *-to-one properties like createdBy.username or authorTeam.persistentTitleCache
propertyPaths - properties to be initialized
Returns:
a List T instances
See Also:
Apache Lucene - Query Parser Syntax

suggestQuery

public String suggestQuery(String string)
Description copied from interface: ISearchableDao
Suggest a query that will return hits based upon an existing lucene query string (that is presumably misspelt and returns no hits) Used to implement "did you mean?"-type functionality using the lucene spellchecker.

Specified by:
suggestQuery in interface ISearchableDao<T extends IdentifiableEntity>
Parameters:
string - Query string to check
Returns:
a suggested query string that will return hits or null if no such alternative spelling can be found.

countByTitle

public Integer countByTitle(String queryString)
Specified by:
countByTitle in interface ITitledDao<T extends IdentifiableEntity>
Returns:

countByTitle

public Integer countByTitle(String queryString,
                            CdmBase sessionObject)
Specified by:
countByTitle in interface ITitledDao<T extends IdentifiableEntity>
Returns:

countByTitle

public Integer countByTitle(String queryString,
                            MatchMode matchMode,
                            List<org.hibernate.criterion.Criterion> criteria)
Specified by:
countByTitle in interface ITitledDao<T extends IdentifiableEntity>
criteria - TODO
Returns:


Copyright © 2007-2013 EDIT. All Rights Reserved.