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.Collection;
|
14
|
import java.util.List;
|
15
|
import java.util.Map;
|
16
|
import java.util.UUID;
|
17
|
|
18
|
import org.hibernate.criterion.Criterion;
|
19
|
|
20
|
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
|
21
|
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
|
22
|
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
23
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
24
|
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
|
25
|
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
|
26
|
import eu.etaxonomy.cdm.model.common.RelationshipBase;
|
27
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
28
|
import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;
|
29
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
30
|
import eu.etaxonomy.cdm.model.name.HybridRelationship;
|
31
|
import eu.etaxonomy.cdm.model.name.HybridRelationshipType;
|
32
|
import eu.etaxonomy.cdm.model.name.NameRelationship;
|
33
|
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
|
34
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
|
35
|
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
|
36
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
37
|
import eu.etaxonomy.cdm.model.name.Rank;
|
38
|
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
|
39
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
40
|
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
41
|
import eu.etaxonomy.cdm.persistence.dao.BeanInitializer;
|
42
|
import eu.etaxonomy.cdm.persistence.query.MatchMode;
|
43
|
import eu.etaxonomy.cdm.persistence.query.OrderHint;
|
44
|
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
|
45
|
|
46
|
public interface INameService extends IIdentifiableEntityService<TaxonNameBase> {
|
47
|
|
48
|
/**
|
49
|
* Deletes a name. Depening on the configurator state links to the name will either be
|
50
|
* deleted or throw exceptions.<BR>
|
51
|
* If name is <code>null</code> this method has no effect.
|
52
|
* @param name
|
53
|
* @param config
|
54
|
* @throws ReferencedObjectUndeletableException
|
55
|
*/
|
56
|
public UUID delete(TaxonNameBase name, NameDeletionConfigurator config) throws ReferencedObjectUndeletableException;
|
57
|
|
58
|
/**
|
59
|
* Removes the given type designation from the given taxon name and deletes it from
|
60
|
* the database if it is not connected to any other name.
|
61
|
* If <code>typeDesignation</code> is <code>null</code> all type designations are deleted
|
62
|
* from the given taxon name. If <code>name</code> is <code>null</code> all names are removed from
|
63
|
* the given type designation. If both are <code>null</code> nothing happens.
|
64
|
* @param typeDesignation
|
65
|
* @param name
|
66
|
* @return
|
67
|
*/
|
68
|
public void deleteTypeDesignation(TaxonNameBase name, TypeDesignationBase typeDesignation);
|
69
|
|
70
|
|
71
|
/**
|
72
|
* Saves the given type designations.
|
73
|
* @param typeDesignationCollection
|
74
|
* @return
|
75
|
*/
|
76
|
public Map<UUID, TypeDesignationBase> saveTypeDesignationAll(Collection<TypeDesignationBase> typeDesignationCollection);
|
77
|
|
78
|
public Map<UUID, ReferencedEntityBase> saveReferencedEntitiesAll(Collection<ReferencedEntityBase> referencedEntityCollection);
|
79
|
|
80
|
/**
|
81
|
* Saves the given homotypical groups.
|
82
|
* @param homotypicalGroups
|
83
|
* @return
|
84
|
*/
|
85
|
public Map<UUID, HomotypicalGroup> saveAllHomotypicalGroups(Collection<HomotypicalGroup> homotypicalGroups);
|
86
|
|
87
|
/**
|
88
|
* Returns all nomenclatural status.
|
89
|
* @param limit
|
90
|
* @param start
|
91
|
* @return
|
92
|
*/
|
93
|
public List<NomenclaturalStatus> getAllNomenclaturalStatus(int limit, int start);
|
94
|
|
95
|
/**
|
96
|
* Returns all type designations.
|
97
|
* @param limit
|
98
|
* @param start
|
99
|
* @return
|
100
|
*/
|
101
|
public List<TypeDesignationBase> getAllTypeDesignations(int limit, int start);
|
102
|
|
103
|
/**
|
104
|
* @param name
|
105
|
* @return
|
106
|
*/
|
107
|
public List<TaxonNameBase> getNamesByName(String name);
|
108
|
|
109
|
/**
|
110
|
* Returns all NonViralNames with a name cache that matches the given string
|
111
|
* @param name
|
112
|
* @return
|
113
|
*/
|
114
|
public List<NonViralName> getNamesByNameCache(String nameCache);
|
115
|
|
116
|
/**
|
117
|
* Returns all NonViralNames with a title cache that matches the given string
|
118
|
* using the given match mode and initialization strategy
|
119
|
*
|
120
|
* @param name
|
121
|
* @param matchMode
|
122
|
* @param propertyPaths
|
123
|
* @return
|
124
|
*/
|
125
|
public List<NonViralName> findNamesByTitleCache(String titleCache, MatchMode matchMode, List<String> propertyPaths);
|
126
|
|
127
|
/**
|
128
|
* Returns all NonViralNames with a name cache that matches the given string
|
129
|
* using the given match mode and initialization strategy
|
130
|
*
|
131
|
* @param name
|
132
|
* @param matchMode
|
133
|
* @param propertyPaths
|
134
|
* @return
|
135
|
*/
|
136
|
public List<NonViralName> findNamesByNameCache(String nameCache, MatchMode matchMode, List<String> propertyPaths);
|
137
|
|
138
|
/**
|
139
|
* Returns the NonViralName with the given UUID
|
140
|
* using the given match mode and initialization strategy
|
141
|
*
|
142
|
* @param uuid
|
143
|
* @param propertyPaths
|
144
|
* @return
|
145
|
*/
|
146
|
public NonViralName findNameByUuid(UUID uuid, List<String> propertyPaths);
|
147
|
/**
|
148
|
* @param name
|
149
|
* @param sessionObject An object that is attached to the session before executing the query
|
150
|
* @return
|
151
|
*/
|
152
|
public List getNamesByName(String name, CdmBase sessionObject);
|
153
|
|
154
|
// TODO: Remove getNamesByName() methods. Use findNamesByTitle() instead.
|
155
|
|
156
|
// FIXME candidate for harmonization?
|
157
|
public List findNamesByTitle(String title);
|
158
|
|
159
|
public List findNamesByTitle(String title, CdmBase sessionObject);
|
160
|
|
161
|
public List<HomotypicalGroup> getAllHomotypicalGroups(int limit, int start);
|
162
|
|
163
|
@Deprecated
|
164
|
public List<RelationshipBase> getAllRelationships(int limit, int start);
|
165
|
|
166
|
/**
|
167
|
* Returns all Ranks
|
168
|
* @return
|
169
|
* @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead
|
170
|
*/
|
171
|
public OrderedTermVocabulary<Rank> getRankVocabulary();
|
172
|
|
173
|
/**
|
174
|
* Returns all NomenclaturalStatusTypes
|
175
|
* @return
|
176
|
* @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead
|
177
|
*/
|
178
|
public TermVocabulary<NomenclaturalStatusType> getStatusTypeVocabulary();
|
179
|
|
180
|
/**
|
181
|
* Returns TypeDesignationStatus vocabulary
|
182
|
* @return
|
183
|
* @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead
|
184
|
*/
|
185
|
public TermVocabulary<SpecimenTypeDesignationStatus> getSpecimenTypeDesignationStatusVocabulary();
|
186
|
|
187
|
/**
|
188
|
* Returns TypeDesignationStatus ordered vocabulary
|
189
|
* @return
|
190
|
* @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead
|
191
|
*/
|
192
|
public OrderedTermVocabulary<SpecimenTypeDesignationStatus> getSpecimenTypeDesignationVocabulary();
|
193
|
|
194
|
/**
|
195
|
* Returns all NameRelationshipTypes
|
196
|
* @return
|
197
|
* @deprecated use VocabularyService#getVocabulary(VocabularyEnum) instead
|
198
|
*/
|
199
|
public TermVocabulary<NameRelationshipType> getNameRelationshipTypeVocabulary();
|
200
|
|
201
|
/**
|
202
|
* Return a List of name relationships in which this name is related to
|
203
|
* another name, optionally filtered by relationship type
|
204
|
*
|
205
|
* @param name
|
206
|
* the name on either the <i>"from side"</i> or on the
|
207
|
* <i>"to side"</i> of the relationship, depending on the
|
208
|
* <code>direction</code> of the relationship.
|
209
|
* @param direction
|
210
|
* the direction of the NameRelationship, may be null to return all relationships
|
211
|
* @param type
|
212
|
* the relationship type (or null to return all relationships)
|
213
|
* @param pageSize
|
214
|
* The maximum number of relationships returned (can be null for
|
215
|
* all relationships)
|
216
|
* @param pageNumber
|
217
|
* The offset (in pageSize chunks) from the start of the result
|
218
|
* set (0 - based)
|
219
|
* @param orderHints
|
220
|
* may be null
|
221
|
* @param propertyPaths
|
222
|
* properties to initialize - see
|
223
|
* {@link BeanInitializer#initialize(Object, List)}
|
224
|
* @return a Pager of NameRelationship instances
|
225
|
*/
|
226
|
public List<NameRelationship> listNameRelationships(TaxonNameBase name, NameRelationship.Direction direction, NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
227
|
|
228
|
/**
|
229
|
* Return a List of name relationships in which this name is related to another name, optionally filtered
|
230
|
* by relationship type
|
231
|
*
|
232
|
* @param name the name on the <i>"from side"</i> of the relationship
|
233
|
* @param direction the direction of the NameRelationship
|
234
|
* @param type the relationship type (or null to return all relationships)
|
235
|
* @param pageSize The maximum number of relationships returned (can be null for all relationships)
|
236
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
237
|
* @param orderHints may be null
|
238
|
* @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
|
239
|
* @return a Pager of NameRelationship instances
|
240
|
*/
|
241
|
public Pager<NameRelationship> pageNameRelationships(TaxonNameBase name, NameRelationship.Direction direction, NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
242
|
|
243
|
/**
|
244
|
* Return a List of relationships in which this name is related to another name, optionally filtered
|
245
|
* by relationship type
|
246
|
*
|
247
|
* @param name the name on the <i>"from side"</i> of the relationship
|
248
|
* @param type the relationship type (or null to return all relationships)
|
249
|
* @param pageSize The maximum number of relationships returned (can be null for all relationships)
|
250
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
251
|
* @param orderHints may be null
|
252
|
* @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
|
253
|
* @return a Pager of NameRelationship instances
|
254
|
* @deprecated use {@link #listNameRelationships(TaxonNameBase, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
|
255
|
*/
|
256
|
@Deprecated
|
257
|
public List<NameRelationship> listFromNameRelationships(TaxonNameBase name, NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
258
|
|
259
|
/**
|
260
|
* Return a List of relationships in which this name is related to another name, optionally filtered
|
261
|
* by relationship type
|
262
|
*
|
263
|
* @param name the name on the <i>"from side"</i> of the relationship
|
264
|
* @param type the relationship type (or null to return all relationships)
|
265
|
* @param pageSize The maximum number of relationships returned (can be null for all relationships)
|
266
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
267
|
* @param orderHints may be null
|
268
|
* @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
|
269
|
* @return a Pager of NameRelationship instances
|
270
|
* @deprecated use {@link #pageNameRelationships(TaxonNameBase, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
|
271
|
*/
|
272
|
@Deprecated
|
273
|
public Pager<NameRelationship> pageFromNameRelationships(TaxonNameBase name, NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
274
|
|
275
|
/**
|
276
|
* Return a List of relationships in which another name is related to this name, optionally filtered
|
277
|
* by relationship type
|
278
|
*
|
279
|
* @param name the name on the <i>"to side"</i> of the relationship
|
280
|
* @param type the relationship type (or null to return all relationships)
|
281
|
* @param pageSize The maximum number of relationships returned (can be null for all relationships)
|
282
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
283
|
* @param orderHints may be null
|
284
|
* @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
|
285
|
* @return a Pager of NameRelationship instances
|
286
|
* @deprecated use {@link #listNameRelationships(TaxonNameBase, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
|
287
|
*/
|
288
|
@Deprecated
|
289
|
public List<NameRelationship> listToNameRelationships(TaxonNameBase name, NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
290
|
|
291
|
/**
|
292
|
* Return a List of relationships in which another name is related to this name, optionally filtered
|
293
|
* by relationship type
|
294
|
*
|
295
|
* @param name the name on the <i>"to side"</i> of the relationship
|
296
|
* @param type the relationship type (or null to return all relationships)
|
297
|
* @param pageSize The maximum number of relationships returned (can be null for all relationships)
|
298
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
299
|
* @param orderHints may be null
|
300
|
* @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
|
301
|
* @return a Pager of NameRelationship instances
|
302
|
* @deprecated use {@link #pageNameRelationships(TaxonNameBase, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
|
303
|
*/
|
304
|
@Deprecated
|
305
|
public Pager<NameRelationship> pageToNameRelationships(TaxonNameBase name, NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
306
|
|
307
|
|
308
|
/**
|
309
|
* Return a List of hybrids related to this name, optionally filtered
|
310
|
* by hybrid relationship type
|
311
|
*
|
312
|
* @param name the name
|
313
|
* @param type the hybrid relationship type (or null to return all hybrids)
|
314
|
* @param pageSize The maximum number of hybrid relationships returned (can be null for all relationships)
|
315
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
316
|
* @param orderHints may be null
|
317
|
* @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
|
318
|
* @return a Pager of HybridRelationship instances
|
319
|
*/
|
320
|
public Pager<HybridRelationship> getHybridNames(NonViralName name, HybridRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
321
|
|
322
|
/**
|
323
|
* Return a List of types related to this name, optionally filtered
|
324
|
* by type designation status
|
325
|
*
|
326
|
* @param name the name
|
327
|
* @param status the type designation status (or null to return all types)
|
328
|
* @param pageSize The maximum number of types returned (can be null for all types)
|
329
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
330
|
* @return a Pager of TypeDesignationBase instances
|
331
|
*/
|
332
|
public Pager<TypeDesignationBase> getTypeDesignations(TaxonNameBase name,
|
333
|
SpecimenTypeDesignationStatus status, Integer pageSize, Integer pageNumber);
|
334
|
|
335
|
public Pager<TypeDesignationBase> getTypeDesignations(TaxonNameBase name,
|
336
|
SpecimenTypeDesignationStatus status, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
|
337
|
|
338
|
|
339
|
/**
|
340
|
* Returns a List of TaxonNameBase instances that match the properties passed
|
341
|
*
|
342
|
* @param uninomial
|
343
|
* @param infraGenericEpithet
|
344
|
* @param specificEpithet
|
345
|
* @param infraspecificEpithet
|
346
|
* @param rank
|
347
|
* @param pageSize The maximum number of names returned (can be null for all names)
|
348
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
349
|
* @param orderHints may be null
|
350
|
* @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
|
351
|
* @return a Pager of TaxonNameBase instances
|
352
|
*/
|
353
|
public Pager<TaxonNameBase> searchNames(String uninomial, String infraGenericEpithet, String specificEpithet, String infraspecificEpithet, Rank rank, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
354
|
|
355
|
/**
|
356
|
* Returns a Paged List of TaxonNameBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
|
357
|
*
|
358
|
* @param clazz filter the results by class (or pass null to return all TaxonNameBase instances)
|
359
|
* @param queryString
|
360
|
* @param pageSize The maximum number of names returned (can be null for all matching names)
|
361
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
362
|
* @param orderHints
|
363
|
* Supports path like <code>orderHints.propertyNames</code> which
|
364
|
* include *-to-one properties like createdBy.username or
|
365
|
* authorTeam.persistentTitleCache
|
366
|
* @param propertyPaths properties to be initialized
|
367
|
* @return a Pager TaxonNameBase instances
|
368
|
* @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
|
369
|
*/
|
370
|
public Pager<TaxonNameBase> search(Class<? extends TaxonNameBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
371
|
|
372
|
/**
|
373
|
* Returns a map that holds uuid, titleCache pairs of all names in the current database
|
374
|
*
|
375
|
* @return
|
376
|
* a <code>Map</code> containing uuid and titleCache of names
|
377
|
*/
|
378
|
public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames();
|
379
|
|
380
|
/**
|
381
|
* Return a Pager of names matching the given query string, optionally filtered by class, optionally with a particular MatchMode
|
382
|
*
|
383
|
* @param clazz filter by class - can be null to include all instances of type T
|
384
|
* @param queryString the query string to filter by
|
385
|
* @param matchmode use a particular type of matching (can be null - defaults to exact matching)
|
386
|
* @param criteria additional criteria to filter by
|
387
|
* @param pageSize The maximum number of objects returned (can be null for all objects)
|
388
|
* @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
|
389
|
* @param propertyPaths properties to initialize - see {@link BeanInitializer#initialize(Object, List)}
|
390
|
* @param orderHints
|
391
|
* Supports path like <code>orderHints.propertyNames</code> which
|
392
|
* include *-to-one properties like createdBy.username or
|
393
|
* authorTeam.persistentTitleCache
|
394
|
* @return a paged list of instances of type T matching the queryString
|
395
|
*/
|
396
|
public Pager<TaxonNameBase> findByName(Class<? extends TaxonNameBase> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
|
397
|
|
398
|
/**
|
399
|
* Returns a homotypical group with the given UUID or null if not homotypical group exists with that UUID
|
400
|
*
|
401
|
* @param uuid the uuid of the homotypical group
|
402
|
* @return a homotypical group
|
403
|
*/
|
404
|
public HomotypicalGroup findHomotypicalGroup(UUID uuid);
|
405
|
|
406
|
/**
|
407
|
* @param uuid
|
408
|
* @return
|
409
|
*/
|
410
|
public List<TaggedText> getTaggedName(UUID uuid);
|
411
|
}
|