Added findByReferenceTitle()
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / persistence / dao / common / IIdentifiableDao.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.cdm.persistence.dao.common;
11
12 import java.util.List;
13
14 import org.hibernate.criterion.Criterion;
15
16 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
17 import eu.etaxonomy.cdm.model.common.IdentifiableSource;
18 import eu.etaxonomy.cdm.model.common.LSID;
19 import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
20 import eu.etaxonomy.cdm.model.media.Rights;
21 import eu.etaxonomy.cdm.persistence.dao.BeanInitializer;
22 import eu.etaxonomy.cdm.persistence.query.MatchMode;
23 import eu.etaxonomy.cdm.persistence.query.OrderHint;
24
25 public interface IIdentifiableDao <T extends IdentifiableEntity> extends IAnnotatableDao<T>, ITitledDao<T>, ISearchableDao<T>{
26
27 /**
28 * Return an object by LSID. NOTE: Because of the fact that LSIDs are supposed to
29 * be globally resolvable, this method behaves in a different way to other methods
30 *
31 * 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
32 * revision part, then this will be used in the query, but if not, then it is expected that the request is for the 'current'
33 * version of the object and the revision part will not be used as a matching criteria in the query.
34 *
35 * If the object does not appear in the current view (i.e. it has been deleted), then this method will search the history
36 * tables for a match, again using the revision if it exists, but ignoring it if not.
37 *
38 * @param lsid a LifeScience Identifier identifying the desired object
39 */
40 public T find(LSID lsid);
41
42 /**
43 * Return a count of the sources for this identifiable entity
44 *
45 * @param identifiableEntity The identifiable entity
46 * @return a count of OriginalSource instances
47 */
48 public int countSources(T identifiableEntity);
49
50 /**
51 * Return a List of the sources for this identifiable entity
52 *
53 * @param identifiableEntity The identifiable entity
54 * @param pageSize The maximum number of sources returned (can be null for all sources)
55 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
56 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
57 * @return a List of OriginalSource instances
58 */
59 public List<IdentifiableSource> getSources(T identifiableEntity, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
60
61 /**
62 * Return a count of the rights for this identifiable entity
63 *
64 * @param identifiableEntity The identifiable entity
65 * @return a count of Rights instances
66 */
67 public int countRights(T identifiableEntity);
68
69 /**
70 * Return a List of the rights for this identifiable entity
71 *
72 * @param identifiableEntity The identifiable entity
73 * @param pageSize The maximum number of rights returned (can be null for all rights)
74 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
75 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
76 * @return a List of Rights instances
77 */
78 public List<Rights> getRights(T identifiableEntity, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
79
80 // TODO Migrated from IOriginalSourceDao
81 public List<T> findOriginalSourceByIdInSource(String idInSource, String idNamespace);
82
83 /**
84 * Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
85 * Retrieving this list is considered to be significantly faster than initializing the fully fledged buiseness
86 * objects. To be used in cases where you want to present large amount of data and provide details after
87 * a selection has been made.
88 *
89 * @return a list of <code>UuidAndTitleCache</code> instances
90 */
91 public List<UuidAndTitleCache<T>> getUuidAndTitleCache();
92
93 /**
94 * Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
95 *
96 * @param clazz filter by class - can be null to include all instances of type T
97 * @param queryString the query string to filter by
98 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
99 * @param criteria extra restrictions to apply
100 * @param pageSize The maximum number of rights returned (can be null for all rights)
101 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
102 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
103 * @param orderHints
104 * Supports path like <code>orderHints.propertyNames</code> which
105 * include *-to-one properties like createdBy.username or
106 * authorTeam.persistentTitleCache
107 * @return a List of instances of type T matching the queryString
108 */
109 public List<T> findByTitle(Class<? extends T> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
110
111 /**
112 * Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
113 *
114 * @param clazz filter by class - can be null to include all instances of type T
115 * @param queryString the query string to filter by
116 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
117 * @param criteria extra restrictions to apply
118 * @param pageSize The maximum number of rights returned (can be null for all rights)
119 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
120 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
121 * @param orderHints
122 * Supports path like <code>orderHints.propertyNames</code> which
123 * include *-to-one properties like createdBy.username or
124 * authorTeam.persistentTitleCache
125 * @return a List of instances of type T matching the queryString
126 */
127 public List<T> findByReferenceTitle(Class<? extends T> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
128
129 /**
130 * Return a count of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
131 *
132 * @param clazz filter by class - can be null to include all instances of type T
133 * @param queryString the query string to filter by
134 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
135 * @param criteria extra restrictions to apply
136 * @return a count of instances of type T matching the queryString
137 */
138 public int countByTitle(Class<? extends T> clazz, String queryString, MatchMode matchmode, List<Criterion> criteria);
139 }