Project

General

Profile

Download (11.5 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.pager.Pager;
19
import eu.etaxonomy.cdm.common.IProgressMonitor;
20
import eu.etaxonomy.cdm.model.common.ISourceable;
21
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
22
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
23
import eu.etaxonomy.cdm.model.common.LSID;
24
import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
25
import eu.etaxonomy.cdm.model.media.Rights;
26
import eu.etaxonomy.cdm.persistence.dao.BeanInitializer;
27
import eu.etaxonomy.cdm.persistence.query.MatchMode;
28
import eu.etaxonomy.cdm.persistence.query.OrderHint;
29
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
30
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
31
import eu.etaxonomy.cdm.strategy.match.IMatchable;
32
import eu.etaxonomy.cdm.strategy.merge.IMergable;
33
import eu.etaxonomy.cdm.strategy.merge.IMergeStrategy;
34

    
35
public interface IIdentifiableEntityService<T extends IdentifiableEntity> extends IAnnotatableService<T> {
36

    
37
	/**
38
	 * (Re-)generate the title caches for all objects of this concrete IdentifiableEntity class.
39
	 * Uses default values.
40
	 * @see #updateTitleCache(Class, Integer, IIdentifiableEntityCacheStrategy, IProgressMonitor)
41
	 */
42
	public void updateTitleCache();
43
	
44
	/**
45
	 * (Re-)generate the title caches for all objects of this concrete IdentifiableEntity class
46
	 *
47
	 * @param clazz class of objects to be updated 
48
	 * @param stepSize number of objects loaded per step. If <code>null</code> use default.
49
	 * @param cacheStrategy cachestrategy used for title cache. If <code>null</code> use default.
50
	 * @param monitor progress monitor. If <code>null</code> use default.
51
	 */
52
	public void updateTitleCache(Class<? extends T> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<T> cacheStrategy, IProgressMonitor monitor);
53
	
54
	/**
55
	 * Finds an object with a given LSID. If the object does not currently exist in the current view, then
56
	 * the most recent prior version of the object will be returned, or null if an object with this identifier
57
	 * has never existed
58
	 * 
59
	 * @param lsid
60
	 * @return an object of type T or null of the object has never existed
61
	 */
62
	public T find(LSID lsid);
63
	
64
	/**
65
	 * Replaces all *ToMany and *ToOne references to an object (x) with another object of the same type (y)
66
	 * 
67
	 * Ignores ManyToAny and OneToAny relationships as these are typically involved with bidirectional 
68
	 * parent-child relations
69
	 * 
70
	 * @param x
71
	 * @param y
72
	 * @return the replacing object (y)
73
	 */
74
	public T replace(T x, T y);
75
	
76
	/**
77
	 * Return a Pager of sources belonging to this object
78
	 * 
79
	 * @param t The identifiable entity
80
	 * @param pageSize The maximum number of sources returned (can be null for all sources)
81
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
82
	 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
83
	 * @return a Pager of OriginalSource entities
84
	 */
85
    public Pager<IdentifiableSource> getSources(T t, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
86
    
87
	/**
88
	 * Return a Pager of rights belonging to this object
89
	 * 
90
	 * @param t The identifiable entity
91
	 * @param pageSize The maximum number of rights returned (can be null for all rights)
92
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
93
	 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
94
	 * @return a Pager of Rights entities
95
	 */
96
    public Pager<Rights> getRights(T t, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
97
    
98
    public ISourceable getSourcedObjectByIdInSource(Class clazz, String idInSource, String idNamespace);
99
    
100
	/**
101
	 * Return a list of all uuids mapped to titleCache in the convenient <code>UuidAndTitleCache</code> object.
102
	 * Retrieving this list is considered to be significantly faster than initializing the fully fledged buiseness
103
	 * objects. To be used in cases where you want to present large amount of data and provide details after 
104
	 * a selection has been made.  
105
	 * 
106
	 * @return a list of <code>UuidAndTitleCache</code> instances
107
	 */
108
	public List<UuidAndTitleCache<T>> getUuidAndTitleCache(); 
109
	
110
	/**
111
	 * Return a Pager of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
112
	 * 
113
	 * @param clazz filter by class - can be null to include all instances of type T
114
	 * @param queryString the query string to filter by
115
	 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
116
	 * @param criteria additional criteria to filter by
117
	 * @param pageSize The maximum number of objects returned (can be null for all objects)
118
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
119
	 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
120
	 * @param orderHints
121
	 *            Supports path like <code>orderHints.propertyNames</code> which
122
	 *            include *-to-one properties like createdBy.username or
123
	 *            authorTeam.persistentTitleCache
124
	 * @return a paged list of instances of type T matching the queryString
125
	 */
126
    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);
127
    
128
    /**
129
	 * Return a Pager of objects matching the given query string, optionally filtered by class, 
130
	 * optionally with a particular MatchMode
131
	 * 
132
	 * @return a paged list of instances of type T matching the queryString
133
	 */
134
    public Pager<T> findByTitle(IIdentifiableEntityServiceConfigurator<T> configurator);
135
    
136
    
137
    /**
138
	 * Return an Integer of how many 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 additional criteria to filter by
144
	 *
145
	 * @return 
146
	 */
147
    public Integer countByTitle(Class<? extends T> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria);
148
   
149
    /**
150
	 * Return an Integer of how many objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
151
	 * 
152
	 * @param configurator an {@link IIdentifiableEntityServiceConfigurator} object
153
	 *
154
	 * @return 
155
	 */
156
    public Integer countByTitle(IIdentifiableEntityServiceConfigurator<T> configurator);
157
   
158
    
159
	/**
160
	 * Return a List of objects matching the given query string, optionally filtered by class, optionally with a particular MatchMode
161
	 * 
162
	 * @param clazz filter by class - can be null to include all instances of type T
163
	 * @param queryString the query string to filter by
164
	 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
165
	 * @param criteria additional criteria to filter by
166
	 * @param pageSize The maximum number of objects returned (can be null for all objects)
167
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
168
	 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
169
	 * @param orderHints
170
	 *            Supports path like <code>orderHints.propertyNames</code> which
171
	 *            include *-to-one properties like createdBy.username or
172
	 *            authorTeam.persistentTitleCache
173
	 * @return a list of instances of type T matching the queryString
174
	 */
175
    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);
176
    
177
	/**
178
	 * Return a List of objects matching the given query string, 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
	 * @param criteria additional criteria to filter by
184
	 * @param pageSize The maximum number of objects returned (can be null for all objects)
185
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
186
	 * @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
187
	 * @param orderHints
188
	 *            Supports path like <code>orderHints.propertyNames</code> which
189
	 *            include *-to-one properties like createdBy.username or
190
	 *            authorTeam.persistentTitleCache
191
	 * @return a list of instances of type T matching the queryString
192
	 */
193
    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);
194
    
195
    /**
196
	 * Returns a Paged List of IdentifiableEntity instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
197
	 * 
198
	 * @param clazz filter the results by class (or pass null to return all IdentifiableEntity instances)
199
	 * @param queryString
200
	 * @param pageSize The maximum number of identifiable entities returned (can be null for all matching identifiable entities)
201
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
202
	 * @param orderHints
203
	 *            Supports path like <code>orderHints.propertyNames</code> which
204
	 *            include *-to-one properties like createdBy.username or
205
	 *            authorTeam.persistentTitleCache
206
	 * @param propertyPaths properties to be initialized
207
	 * @return a Pager IdentifiableEntity instances
208
	 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
209
	 */
210
	public Pager<T> search(Class<? extends T> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
211

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