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.DefinedTerm;
|
17
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
18
|
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
|
19
|
import eu.etaxonomy.cdm.model.common.Identifier;
|
20
|
import eu.etaxonomy.cdm.model.common.LSID;
|
21
|
import eu.etaxonomy.cdm.model.media.Rights;
|
22
|
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
|
23
|
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
|
24
|
import eu.etaxonomy.cdm.persistence.query.MatchMode;
|
25
|
import eu.etaxonomy.cdm.persistence.query.OrderHint;
|
26
|
|
27
|
public interface IIdentifiableDao <T extends IdentifiableEntity> extends IAnnotatableDao<T>, ITitledDao<T>, ISearchableDao<T>{
|
28
|
|
29
|
/**
|
30
|
* Return an object by LSID. NOTE: Because of the fact that LSIDs are supposed to
|
31
|
* be globally resolvable, this method behaves in a different way to other methods
|
32
|
*
|
33
|
* 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
|
34
|
* revision part, then this will be used in the query, but if not, then it is expected that the request is for the 'current'
|
35
|
* version of the object and the revision part will not be used as a matching criteria in the query.
|
36
|
*
|
37
|
* If the object does not appear in the current view (i.e. it has been deleted), then this method will search the history
|
38
|
* tables for a match, again using the revision if it exists, but ignoring it if not.
|
39
|
*
|
40
|
* @param lsid a LifeScience Identifier identifying the desired object
|
41
|
*/
|
42
|
public T find(LSID lsid);
|
43
|
|
44
|
/**
|
45
|
* Return a count of the sources for this identifiable entity
|
46
|
*
|
47
|
* @param identifiableEntity The identifiable entity
|
48
|
* @return a count of OriginalSource instances
|
49
|
*/
|
50
|
public int countSources(T identifiableEntity);
|
51
|
|
52
|
/**
|
53
|
* Return a List of the sources for this identifiable entity
|
54
|
*
|
55
|
* @param identifiableEntity The identifiable entity
|
56
|
* @param pageSize The maximum number of sources returned (can be null for all sources)
|
57
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
58
|
* @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
|
59
|
* @return a List of OriginalSource instances
|
60
|
*/
|
61
|
public List<IdentifiableSource> getSources(T identifiableEntity, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
|
62
|
|
63
|
/**
|
64
|
* Return a count of the rights for this identifiable entity
|
65
|
*
|
66
|
* @param identifiableEntity The identifiable entity
|
67
|
* @return a count of Rights instances
|
68
|
*/
|
69
|
public int countRights(T identifiableEntity);
|
70
|
|
71
|
|
72
|
/**
|
73
|
* Return a List of the rights for this identifiable entity
|
74
|
*
|
75
|
* @param identifiableEntity The identifiable entity
|
76
|
* @param pageSize The maximum number of rights returned (can be null for all rights)
|
77
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
78
|
* @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
|
79
|
* @return a List of Rights instances
|
80
|
*/
|
81
|
public List<Rights> getRights(T identifiableEntity, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
|
82
|
|
83
|
// TODO Migrated from IOriginalSourceDao
|
84
|
public List<T> findOriginalSourceByIdInSource(String idInSource, String idNamespace);
|
85
|
|
86
|
/**
|
87
|
* Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
|
88
|
* Retrieving this list is considered to be significantly faster than initializing the fully fledged buiseness
|
89
|
* objects. To be used in cases where you want to present large amount of data and provide details after
|
90
|
* a selection has been made.
|
91
|
*
|
92
|
* @return a list of <code>UuidAndTitleCache</code> instances
|
93
|
*/
|
94
|
public List<UuidAndTitleCache<T>> getUuidAndTitleCache(Integer limit, String pattern);
|
95
|
/**
|
96
|
* Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
|
97
|
* Retrieving this list is considered to be significantly faster than initializing the fully fledged buiseness
|
98
|
* objects. To be used in cases where you want to present large amount of data and provide details after
|
99
|
* a selection has been made.
|
100
|
*
|
101
|
* @return a list of <code>UuidAndTitleCache</code> instances
|
102
|
*/
|
103
|
public List<UuidAndTitleCache<T>> getUuidAndTitleCache();
|
104
|
|
105
|
/**
|
106
|
* Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
|
107
|
*
|
108
|
* @param clazz filter by class - can be null to include all instances of type T
|
109
|
* @param queryString the query string to filter by
|
110
|
* @param matchmode use a particular type of matching (can be null - defaults to exact matching)
|
111
|
* @param criteria extra restrictions to apply
|
112
|
* @param pageSize The maximum number of rights returned (can be null for all rights)
|
113
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
114
|
* @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
|
115
|
* @param orderHints
|
116
|
* Supports path like <code>orderHints.propertyNames</code> which
|
117
|
* include *-to-one properties like createdBy.username or
|
118
|
* authorTeam.persistentTitleCache
|
119
|
* @return a List of instances of type T matching the queryString
|
120
|
*/
|
121
|
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);
|
122
|
|
123
|
|
124
|
|
125
|
/**
|
126
|
* TODO
|
127
|
* @param clazz
|
128
|
* @param queryString
|
129
|
* @param pageSize
|
130
|
* @param pageNumber
|
131
|
* @param orderHints
|
132
|
* @param matchMode
|
133
|
* @return
|
134
|
*/
|
135
|
public List<T> findTitleCache(Class<? extends T> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, MatchMode matchMode);
|
136
|
|
137
|
/**
|
138
|
* Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
|
139
|
*
|
140
|
* @param clazz filter by class - can be null to include all instances of type T
|
141
|
* @param queryString the query string to filter by
|
142
|
* @param matchmode use a particular type of matching (can be null - defaults to exact matching)
|
143
|
* @param criteria extra restrictions to apply
|
144
|
* @param pageSize The maximum number of rights returned (can be null for all rights)
|
145
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
146
|
* @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
|
147
|
* @param orderHints
|
148
|
* Supports path like <code>orderHints.propertyNames</code> which
|
149
|
* include *-to-one properties like createdBy.username or
|
150
|
* authorTeam.persistentTitleCache
|
151
|
* @return a List of instances of type T matching the queryString
|
152
|
*/
|
153
|
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);
|
154
|
|
155
|
/**
|
156
|
* Return a count of objects matching the given query string in the titleCache, optionally filtered by class, optionally with a particular MatchMode
|
157
|
*
|
158
|
* @param clazz filter by class - can be null to include all instances of type T
|
159
|
* @param queryString the query string to filter by
|
160
|
* @param matchmode use a particular type of matching (can be null - defaults to exact matching)
|
161
|
* @param criteria extra restrictions to apply
|
162
|
* @return a count of instances of type T matching the queryString
|
163
|
*/
|
164
|
public int countByTitle(Class<? extends T> clazz, String queryString, MatchMode matchmode, List<Criterion> criteria);
|
165
|
|
166
|
/**
|
167
|
* Return a count of objects matching the given query string in the title, optionally filtered by class, optionally with a particular MatchMode
|
168
|
*
|
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 criteria extra restrictions to apply
|
173
|
* @return a count of instances of type T matching the queryString
|
174
|
*/
|
175
|
public int countByReferenceTitle(Class<? extends T> clazz, String queryString, MatchMode matchmode, List<Criterion> criteria);
|
176
|
|
177
|
/**
|
178
|
* Return a count of distinct titleCache Strings for a given {@link IdentifiableEntity}, optionally filtered by class, optionally with a particular MatchMode
|
179
|
*
|
180
|
* @param clazz filter by class - can be null to include all instances of type T
|
181
|
* @param queryString the query string to filter by
|
182
|
* @param matchmode use a particular type of matching (can be null - defaults to exact matching)
|
183
|
* @return a count of instances of type T matching the queryString
|
184
|
*/
|
185
|
public abstract Long countTitleCache(Class<? extends T> clazz, String queryString, MatchMode matchMode);
|
186
|
|
187
|
|
188
|
/**
|
189
|
* Return a count of entities having an {@link Identifier} that matches the given parameters.
|
190
|
* @param clazz the entities class
|
191
|
* @param identifier the identifier string
|
192
|
* @param identifierType the identifier type
|
193
|
* @param matchmode
|
194
|
* @see #findByIdentifier
|
195
|
* @return
|
196
|
*/
|
197
|
public <S extends T> int countByIdentifier(Class<S> clazz, String identifier, DefinedTerm identifierType, MatchMode matchmode);
|
198
|
|
199
|
/**
|
200
|
* Returns a tuple including the identifier type, the identifier string,
|
201
|
* and if includeEntity is <code>false</code> the CDM entities uuid, and titleCache,
|
202
|
* otherwise the CDM entity itself
|
203
|
* @param clazz the identifiable entity subclass, may be null
|
204
|
* @param identifier the identifier as {@link String}
|
205
|
* @param identifierType the identifier type, maybe null
|
206
|
* @param matchmode
|
207
|
* @param includeCdmEntity
|
208
|
* @param pageSize
|
209
|
* @param pageNumber
|
210
|
* @param propertyPaths
|
211
|
* @see #countByIdentifier(Class, String, DefinedTerm, MatchMode)
|
212
|
* @return
|
213
|
*/
|
214
|
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);
|
215
|
|
216
|
}
|