2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.persistence
.dao
.common
;
12 import java
.util
.List
;
13 import java
.util
.UUID
;
15 import org
.hibernate
.criterion
.Criterion
;
17 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
18 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
19 import eu
.etaxonomy
.cdm
.model
.common
.LSID
;
20 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
21 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
22 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTerm
;
23 import eu
.etaxonomy
.cdm
.persistence
.dao
.initializer
.IBeanInitializer
;
24 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
25 import eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
;
26 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
28 public interface IIdentifiableDao
<T
extends IdentifiableEntity
> extends IAnnotatableDao
<T
>, ITitledDao
<T
>, ISearchableDao
<T
>{
31 * Return an object by LSID. NOTE: Because of the fact that LSIDs are supposed to
32 * be globally resolvable, this method behaves in a different way to other methods
34 * 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
35 * revision part, then this will be used in the query, but if not, then it is expected that the request is for the 'current'
36 * version of the object and the revision part will not be used as a matching criteria in the query.
38 * If the object does not appear in the current view (i.e. it has been deleted), then this method will search the history
39 * tables for a match, again using the revision if it exists, but ignoring it if not.
41 * @param lsid a LifeScience Identifier identifying the desired object
43 public T
find(LSID lsid
);
46 * Return a count of the sources for this identifiable entity
48 * @param identifiableEntity The identifiable entity
49 * @return a count of OriginalSource instances
51 public long countSources(T identifiableEntity
);
54 * Return a List of the sources for this identifiable entity
56 * @param identifiableEntity The identifiable entity
57 * @param pageSize The maximum number of sources returned (can be null for all sources)
58 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
59 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
60 * @return a List of OriginalSource instances
62 public List
<IdentifiableSource
> getSources(T identifiableEntity
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
65 * Return a count of the rights for this identifiable entity
67 * @param identifiableEntity The identifiable entity
68 * @return a count of Rights instances
70 public long countRights(T identifiableEntity
);
74 * Return a List of the rights for this identifiable entity
76 * @param identifiableEntity The identifiable entity
77 * @param pageSize The maximum number of rights returned (can be null for all rights)
78 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
79 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
80 * @return a List of Rights instances
82 public List
<Rights
> getRights(T identifiableEntity
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
84 // TODO Migrated from IOriginalSourceDao
85 public List
<T
> findOriginalSourceByIdInSource(String idInSource
, String idNamespace
);
90 * Returns the titleCache for a given object defined by uuid.
91 * @param uuid the uuid of the requested object.
92 * @param refresh if false the value as stored in the DB is returned,
93 * otherwise it is recomputed by loading the object and calling the formatter.
94 * @return the titleCache of the requested object
96 public String
getTitleCache(UUID uuid
, boolean refresh
);
99 * Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
101 * @param clazz filter by class - can be null to include all instances of type T
102 * @param queryString the query string to filter by
103 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
104 * @param criteria extra restrictions to apply
105 * @param pageSize The maximum number of rights returned (can be null for all rights)
106 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
107 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
109 * Supports path like <code>orderHints.propertyNames</code> which
110 * include *-to-one properties like createdBy.username or
111 * authorTeam.persistentTitleCache
112 * @return a List of instances of type T matching the queryString
114 public <S
extends T
> List
<S
> findByTitle(Class
<S
> clazz
, String queryString
,MatchMode matchmode
, List
<Criterion
> criteria
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
118 * Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
120 * @param clazz filter by class - can be null to include all instances of type T
121 * @param queryString the query string to filter by
122 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
123 * @param restrictions a <code>List</code> of additional {@link Restriction}s to filter by
124 * @param pageSize The maximum number of rights returned (can be null for all rights)
125 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
126 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
128 * Supports path like <code>orderHints.propertyNames</code> which
129 * include *-to-one properties like createdBy.username or
130 * authorTeam.persistentTitleCache
131 * @return a List of instances of type T matching the queryString
133 public <S
extends T
> List
<S
> findByTitleWithRestrictions(Class
<S
> clazz
, String queryString
,MatchMode matchmode
, List
<Restriction
<?
>> restrictions
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
147 public List
<String
> findTitleCache(Class
<?
extends T
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, MatchMode matchMode
);
149 * Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
151 * @param clazz filter by class - can be null to include all instances of type T
152 * @param queryString the query string to filter by
153 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
154 * @param criteria extra restrictions to apply
155 * @param pageSize The maximum number of rights returned (can be null for all rights)
156 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
157 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
159 * Supports path like <code>orderHints.propertyNames</code> which
160 * include *-to-one properties like createdBy.username or
161 * authorTeam.persistentTitleCache
162 * @return a List of instances of type T matching the queryString
164 public <S
extends T
> List
<S
> findByReferenceTitle(Class
<S
> clazz
, String queryString
,MatchMode matchmode
, List
<Criterion
> criteria
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
167 * Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
169 * @param clazz filter by class - can be null to include all instances of type T
170 * @param queryString the query string to filter by
171 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
172 * @param restrictions a <code>List</code> of additional {@link Restriction}s to filter by
173 * @param pageSize The maximum number of rights returned (can be null for all rights)
174 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
175 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
177 * Supports path like <code>orderHints.propertyNames</code> which
178 * include *-to-one properties like createdBy.username or
179 * authorTeam.persistentTitleCache
180 * @return a List of instances of type T matching the queryString
182 public <S
extends T
> List
<S
> findByReferenceTitleWithRestrictions(Class
<S
> clazz
, String queryString
,MatchMode matchmode
, List
<Restriction
<?
>> restrictions
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
185 * Return a count of objects matching the given query string in the titleCache, optionally filtered by class, optionally with a particular MatchMode
187 * @param clazz filter by class - can be null to include all instances of type T
188 * @param queryString the query string to filter by
189 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
190 * @param criteria extra restrictions to apply
191 * @return a count of instances of type T matching the queryString
193 public long countByTitle(Class
<?
extends T
> clazz
, String queryString
, MatchMode matchmode
, List
<Criterion
> criteria
);
196 * Return a count of objects matching the given query string in the titleCache, optionally filtered by class, optionally with a particular MatchMode
198 * @param clazz filter by class - can be null to include all instances of type T
199 * @param queryString the query string to filter by
200 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
201 * @param restrictions a <code>List</code> of additional {@link Restriction}s to filter by
202 * @return a count of instances of type T matching the queryString
204 public long countByTitleWithRestrictions(Class
<?
extends T
> clazz
, String queryString
, MatchMode matchmode
, List
<Restriction
<?
>> restrictions
);
207 * Return a count of objects matching the given query string in the title, optionally filtered by class, optionally with a particular MatchMode
209 * @param clazz filter by class - can be null to include all instances of type T
210 * @param queryString the query string to filter by
211 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
212 * @param criteria extra restrictions to apply
213 * @return a count of instances of type T matching the queryString
215 public long countByReferenceTitle(Class
<?
extends T
> clazz
, String queryString
, MatchMode matchmode
, List
<Criterion
> criteria
);
218 * Return a count of objects matching the given query string in the title, optionally filtered by class, optionally with a particular MatchMode
220 * @param clazz filter by class - can be null to include all instances of type T
221 * @param queryString the query string to filter by
222 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
223 * @param restrictions a <code>List</code> of additional {@link Restriction}s to filter by
224 * @return a count of instances of type T matching the queryString
226 public long countByReferenceTitleWithRestrictions(Class
<?
extends T
> clazz
, String queryString
, MatchMode matchmode
, List
<Restriction
<?
>> restrictions
);
229 * Return a count of distinct titleCache Strings for a given {@link IdentifiableEntity}, optionally filtered by class, optionally with a particular MatchMode
231 * @param clazz filter by class - can be null to include all instances of type T
232 * @param queryString the query string to filter by
233 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
234 * @return a count of instances of type T matching the queryString
236 public abstract Long
countTitleCache(Class
<?
extends T
> clazz
, String queryString
, MatchMode matchMode
);
240 * Return a count of entities having an {@link Identifier} that matches the given parameters.
241 * @param clazz the entities class
242 * @param identifier the identifier string
243 * @param identifierType the identifier type
245 * @see #findByIdentifier
248 public <S
extends T
> long countByIdentifier(Class
<S
> clazz
, String identifier
, DefinedTerm identifierType
, MatchMode matchmode
);
251 * Returns a tuple including the identifier type, the identifier string,
252 * and if includeEntity is <code>false</code> the CDM entities uuid, and titleCache,
253 * otherwise the CDM entity itself
254 * @param clazz the identifiable entity subclass, may be null
255 * @param identifier the identifier as {@link String}
256 * @param identifierType the identifier type, maybe null
258 * @param includeCdmEntity
261 * @param propertyPaths
262 * @see #countByIdentifier(Class, String, DefinedTerm, MatchMode)
265 public <S
extends T
> List
<Object
[]> findByIdentifier(Class
<S
> clazz
, String identifier
, DefinedTerm identifierType
, MatchMode matchmode
, boolean includeCdmEntity
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
271 * @param includeEntity
274 * @param propertyPaths
277 public <S
extends T
> long countByMarker(Class
<S
> clazz
, MarkerType markerType
, Boolean markerValue
);
283 * @param includeEntity
286 * @param propertyPaths
289 public <S
extends T
> List
<Object
[]> findByMarker(Class
<S
> clazz
, MarkerType markerType
, Boolean markerValue
, boolean includeEntity
,
290 Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
293 * Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
294 * Retrieving this list is considered to be significantly faster than initializing the fully fledged buiseness
295 * objects. To be used in cases where you want to present large amount of data and provide details after
296 * a selection has been made.
298 * @return a list of <code>UuidAndTitleCache</code> instances
299 * @see #getUuidAndTitleCache(Class, Integer, String)
301 public List
<UuidAndTitleCache
<T
>> getUuidAndTitleCache(Integer limit
, String pattern
);
304 * Like {@link #getUuidAndTitleCache(Integer, String)} but searching only on a subclass
305 * of the type handled by the DAO.
307 * @param clazz the (sub)class
308 * @param limit max number of results
309 * @param pattern search pattern
311 * @see #getUuidAndTitleCache(Integer, String)
313 public <S
extends T
> List
<UuidAndTitleCache
<S
>> getUuidAndTitleCache(Class
<S
> clazz
, Integer limit
, String pattern
);
317 * Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
318 * Retrieving this list is considered to be significantly faster than initializing the fully fledged buiseness
319 * objects. To be used in cases where you want to present large amount of data and provide details after
320 * a selection has been made.
322 * @return a list of <code>UuidAndTitleCache</code> instances
324 public List
<UuidAndTitleCache
<T
>> getUuidAndTitleCache();
328 * Like {@link #getUuidAndTitleCache(Integer, String)} but searching only for elements with a marker of markertype
329 * matching the given parameter
335 List
<UuidAndTitleCache
<T
>> getUuidAndTitleCacheByMarker(Integer limit
, String pattern
, MarkerType markerType
);