update javadoc and override
[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.initializer.IBeanInitializer;
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 IBeanInitializer#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 IBeanInitializer#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 IBeanInitializer#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
113 /**
114 * TODO
115 * @param clazz
116 * @param queryString
117 * @param pageSize
118 * @param pageNumber
119 * @param orderHints
120 * @param matchMode
121 * @return
122 */
123 public List<T> findTitleCache(Class<? extends T> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, MatchMode matchMode);
124
125 /**
126 * Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
127 *
128 * @param clazz filter by class - can be null to include all instances of type T
129 * @param queryString the query string to filter by
130 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
131 * @param criteria extra restrictions to apply
132 * @param pageSize The maximum number of rights returned (can be null for all rights)
133 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
134 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
135 * @param orderHints
136 * Supports path like <code>orderHints.propertyNames</code> which
137 * include *-to-one properties like createdBy.username or
138 * authorTeam.persistentTitleCache
139 * @return a List of instances of type T matching the queryString
140 */
141 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);
142
143 /**
144 * Return a count of objects matching the given query string in the titleCache, optionally filtered by class, optionally with a particular MatchMode
145 *
146 * @param clazz filter by class - can be null to include all instances of type T
147 * @param queryString the query string to filter by
148 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
149 * @param criteria extra restrictions to apply
150 * @return a count of instances of type T matching the queryString
151 */
152 public int countByTitle(Class<? extends T> clazz, String queryString, MatchMode matchmode, List<Criterion> criteria);
153
154 /**
155 * Return a count of objects matching the given query string in the title, optionally filtered by class, optionally with a particular MatchMode
156 *
157 * @param clazz filter by class - can be null to include all instances of type T
158 * @param queryString the query string to filter by
159 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
160 * @param criteria extra restrictions to apply
161 * @return a count of instances of type T matching the queryString
162 */
163 public int countByReferenceTitle(Class<? extends T> clazz, String queryString, MatchMode matchmode, List<Criterion> criteria);
164
165 /**
166 * Return a count of distinct titleCache Strings for a given {@link IdentifiableEntity}, optionally filtered by class, optionally with a particular MatchMode
167 *
168 * @param clazz filter by class - can be null to include all instances of type T
169 * @param queryString the query string to filter by
170 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
171 * @return a count of instances of type T matching the queryString
172 */
173 public abstract Long countTitleCache(Class<? extends T> clazz, String queryString, MatchMode matchMode);
174
175 }