Project

General

Profile

Download (14.1 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

    
11
package eu.etaxonomy.cdm.api.service;
12

    
13
import java.util.List;
14

    
15
import org.hibernate.criterion.Criterion;
16

    
17
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
18
import eu.etaxonomy.cdm.api.service.dto.FindByIdentifierDTO;
19
import eu.etaxonomy.cdm.api.service.pager.Pager;
20
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
21
import eu.etaxonomy.cdm.model.common.DefinedTerm;
22
import eu.etaxonomy.cdm.model.common.ISourceable;
23
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
24
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
25
import eu.etaxonomy.cdm.model.common.LSID;
26
import eu.etaxonomy.cdm.model.media.Rights;
27
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
28
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
29
import eu.etaxonomy.cdm.persistence.query.MatchMode;
30
import eu.etaxonomy.cdm.persistence.query.OrderHint;
31
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
32
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
33
import eu.etaxonomy.cdm.strategy.match.IMatchable;
34
import eu.etaxonomy.cdm.strategy.merge.IMergable;
35
import eu.etaxonomy.cdm.strategy.merge.IMergeStrategy;
36

    
37
public interface IIdentifiableEntityService<T extends IdentifiableEntity> extends IAnnotatableService<T> {
38

    
39
    /**
40
     * (Re-)generate the title caches for all objects of this concrete IdentifiableEntity class.
41
     * Uses default values.
42
     * @see #updateTitleCache(Class, Integer, IIdentifiableEntityCacheStrategy, IProgressMonitor)
43
     */
44
    public void updateTitleCache();
45

    
46
    /**
47
     * (Re-)generate the title caches for all objects of this concrete IdentifiableEntity class
48
     *
49
     * @param clazz class of objects to be updated
50
     * @param stepSize number of objects loaded per step. If <code>null</code> use default.
51
     * @param cacheStrategy cachestrategy used for title cache. If <code>null</code> use default.
52
     * @param monitor progress monitor. If <code>null</code> use default.
53
     */
54
    public void updateTitleCache(Class<? extends T> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<T> cacheStrategy, IProgressMonitor monitor);
55

    
56
    /**
57
     * Finds an object with a given LSID. If the object does not currently exist in the current view, then
58
     * the most recent prior version of the object will be returned, or null if an object with this identifier
59
     * has never existed
60
     *
61
     * @param lsid
62
     * @return an object of type T or null of the object has never existed
63
     */
64
    public T find(LSID lsid);
65

    
66
    /**
67
     * Replaces all *ToMany and *ToOne references to an object (x) with another object of the same type (y)
68
     *
69
     * Ignores ManyToAny and OneToAny relationships as these are typically involved with bidirectional
70
     * parent-child relations
71
     *
72
     * @param x
73
     * @param y
74
     * @return the replacing object (y)
75
     */
76
    public T replace(T x, T y);
77

    
78
    /**
79
     * Return a Pager of sources belonging to this object
80
     *
81
     * @param t The identifiable entity
82
     * @param pageSize The maximum number of sources returned (can be null for all sources)
83
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
84
     * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
85
     * @return a Pager of OriginalSource entities
86
     */
87
    public Pager<IdentifiableSource> getSources(T t, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
88

    
89
    /**
90
     * Return a Pager of rights belonging to this object
91
     *
92
     * @param t The identifiable entity
93
     * @param pageSize The maximum number of rights returned (can be null for all rights)
94
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
95
     * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
96
     * @return a Pager of Rights entities
97
     */
98
    public Pager<Rights> getRights(T t, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
99

    
100
    /**
101
     * Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
102
     * @see #getUuidAndTitleCache(Integer, String)
103
     */
104
    public List<UuidAndTitleCache<T>> getUuidAndTitleCache();
105

    
106
    /**
107
     * Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
108
     * Retrieving this list is considered to be significantly faster than initializing the fully fledged business
109
     * objects. To be used in cases where you want to present large amount of data and provide details after
110
     * a selection has been made.
111
     *
112
     * @return a list of <code>UuidAndTitleCache</code> instances
113
     */
114
    public List<UuidAndTitleCache<T>> getUuidAndTitleCache(Integer limit, String pattern);
115

    
116
    /**
117
     * Return a Pager of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
118
     *
119
     * @param clazz filter by class - can be null to include all instances of type T
120
     * @param queryString the query string to filter by
121
     * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
122
     * @param criteria additional criteria to filter by
123
     * @param pageSize The maximum number of objects returned (can be null for all objects)
124
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
125
     * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
126
     * @param orderHints
127
     *            Supports path like <code>orderHints.propertyNames</code> which
128
     *            include *-to-one properties like createdBy.username or
129
     *            authorTeam.persistentTitleCache
130
     * @return a paged list of instances of type T matching the queryString
131
     */
132
    public Pager<T> findByTitle(Class<? extends T> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
133

    
134

    
135
    /**
136
     * Return a Pager of objects matching the given query string, optionally filtered by class,
137
     * optionally with a particular MatchMode
138
     *
139
     * @return a paged list of instances of type T matching the queryString
140
     */
141
    public Pager<T> findByTitle(IIdentifiableEntityServiceConfigurator<T> configurator);
142

    
143

    
144
    /**
145
     * Return an Integer of how many objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
146
     *
147
     * @param clazz filter by class - can be null to include all instances of type T
148
     * @param queryString the query string to filter by
149
     * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
150
     * @param criteria additional criteria to filter by
151
     *
152
     * @return
153
     */
154
    public Integer countByTitle(Class<? extends T> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria);
155

    
156
    /**
157
     * Return an Integer of how many objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
158
     *
159
     * @param configurator an {@link IIdentifiableEntityServiceConfigurator} object
160
     *
161
     * @return
162
     */
163
    public Integer countByTitle(IIdentifiableEntityServiceConfigurator<T> configurator);
164

    
165

    
166
    /**
167
     * Return a List of objects matching the given query string, 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 additional criteria to filter by
173
     * @param pageSize The maximum number of objects returned (can be null for all objects)
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)}
176
     * @param orderHints
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
181
     */
182
    public List<T> listByTitle(Class<? extends T> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
183

    
184
    /**
185
     * Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
186
     *
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 additional criteria to filter by
191
     * @param pageSize The maximum number of objects returned (can be null for all objects)
192
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
193
     * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
194
     * @param orderHints
195
     *            Supports path like <code>orderHints.propertyNames</code> which
196
     *            include *-to-one properties like createdBy.username or
197
     *            authorTeam.persistentTitleCache
198
     * @return a list of instances of type T matching the queryString
199
     */
200
    public List<T> listByReferenceTitle(Class<? extends T> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
201

    
202
    /**
203
     * Returns a Paged List of IdentifiableEntity instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
204
     *
205
     * @param clazz filter the results by class (or pass null to return all IdentifiableEntity instances)
206
     * @param queryString
207
     * @param pageSize The maximum number of identifiable entities returned (can be null for all matching identifiable entities)
208
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
209
     * @param orderHints
210
     *            Supports path like <code>orderHints.propertyNames</code> which
211
     *            include *-to-one properties like createdBy.username or
212
     *            authorTeam.persistentTitleCache
213
     * @param propertyPaths properties to be initialized
214
     * @return a Pager IdentifiableEntity instances
215
     * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
216
     */
217
    public Pager<T> search(Class<? extends T> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
218

    
219

    
220
    /**
221
     * This method tries to deduplicate all objects of a certain class by first trying to find matchabel objects and
222
     * merging them in a second step. For performance reasons implementing classes must not guarantee that ALL
223
     * matching object pairs are found but only a subset. But it must guarantee that only matching objects are merged.
224
     *<BR> Matching is defined by the given matching strategy or if no matching strategy is given the default matching
225
     *strategy is used.
226
     *<BR>clazz must implement {@link IMatchable} and {@link IMergable} otherwise no deduplication is performed.
227
     *<BR>The current implementation in IdentifiableServiceBase tries to match and merge all objects with an identical non
228
     *empty titleCache.
229
     * @param clazz
230
     * @param matchStrategy
231
     * @param mergeStrategy
232
     * @return the number of merges performed during deduplication
233
     */
234
    public int deduplicate(Class<? extends T> clazz, IMatchStrategy matchStrategy, IMergeStrategy mergeStrategy);
235

    
236

    
237
    /**
238
     * Return a Pager of objects with distinct titleCache strings filtered by the given query string, optionally filtered by class, optionally with a particular MatchMode
239
     * @param clazz
240
     * @param queryString
241
     * @param pageSize
242
     * @param pageNumber
243
     * @param orderHints
244
     * @param matchMode
245
     * @return
246
     */
247
    public Pager<T> findTitleCache(Class<? extends T> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, MatchMode matchMode);
248

    
249

    
250
    /**
251
     * Returns an Sourceable object according the
252
     * @param clazz
253
     * @param idInSource
254
     * @param idNamespace
255
     * @return
256
     */
257
    //TODO shouldn't we move this to CommonService or to a new SourceService ?
258
    //TODO should this return a List ?
259
    public ISourceable getSourcedObjectByIdInSource(Class clazz, String idInSource, String idNamespace);
260

    
261
    /**
262
     * Returns a Pager for {@link FindByIdentifierDTO DTOs} that hold the identifier including type, title and uuid
263
     * and the according CDM Object information (uuid, title and the object itself (optional)).
264
     *
265
     * all {@link IdentifiableEntity identifiable entities} which have the according
266
     * identifier attached
267
     * @param clazz the identifiable entity subclass, may be null
268
     * @param identifier the identifier as {@link String}
269
     * @param identifierType the identifier type, maybe null
270
     * @param matchmode
271
     * @param includeCdmEntity if true the CDM entity is also returned (this may slow down performance for large datasets)
272
     * @param pageSize
273
     * @param pageNumber
274
     * @param propertyPaths
275
     * @return
276
     */
277
    public <S extends T> Pager<FindByIdentifierDTO<S>> findByIdentifier(Class<S> clazz, String identifier, DefinedTerm identifierType, MatchMode matchmode, boolean includeCdmEntity, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
278

    
279
}
(42-42/97)