Project

General

Profile

Download (21.3 KB) Statistics
| Branch: | Tag: | Revision:
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.api.service;
11

    
12
import java.io.IOException;
13
import java.util.Collection;
14
import java.util.HashMap;
15
import java.util.List;
16
import java.util.Map;
17
import java.util.UUID;
18

    
19
import org.hibernate.criterion.Criterion;
20

    
21
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
22
import eu.etaxonomy.cdm.api.service.pager.Pager;
23
import eu.etaxonomy.cdm.api.service.search.DocumentSearchResult;
24
import eu.etaxonomy.cdm.api.service.search.LuceneParseException;
25
import eu.etaxonomy.cdm.api.service.search.SearchResult;
26
import eu.etaxonomy.cdm.model.common.CdmBase;
27
import eu.etaxonomy.cdm.model.common.Language;
28
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
29
import eu.etaxonomy.cdm.model.common.RelationshipBase;
30
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
31
import eu.etaxonomy.cdm.model.name.HybridRelationship;
32
import eu.etaxonomy.cdm.model.name.HybridRelationshipType;
33
import eu.etaxonomy.cdm.model.name.INonViralName;
34
import eu.etaxonomy.cdm.model.name.NameRelationship;
35
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
36
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
37
import eu.etaxonomy.cdm.model.name.Rank;
38
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
39
import eu.etaxonomy.cdm.model.name.TaxonName;
40
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
41
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
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<TaxonName> {
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
	 *
55
	 */
56
	public DeleteResult delete(UUID nameUUID, NameDeletionConfigurator config);
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 DeleteResult deleteTypeDesignation(TaxonName name, TypeDesignationBase typeDesignation);
69

    
70
	/**
71
	 * Removes the given type designation from the given taxon name and deletes it from
72
	 * the database if it is not connected to any other name.
73
	 * If <code>typeDesignation</code> is <code>null</code> all type designations are deleted
74
	 * from the given taxon name. If <code>name</code> is <code>null</code> all names are removed from
75
	 * the given type designation. If both are <code>null</code> nothing happens.
76
	 * @param typeDesignation
77
	 * @param name
78
	 * @return
79
	 */
80
	public DeleteResult deleteTypeDesignation(UUID nameUuid, UUID typeDesignationUuid);
81

    
82

    
83
	/**
84
	 * Saves the given type designations.
85
	 * @param typeDesignationCollection
86
	 * @return
87
	 */
88
	public Map<UUID, TypeDesignationBase> saveTypeDesignationAll(Collection<TypeDesignationBase> typeDesignationCollection);
89

    
90
	public Map<UUID, ReferencedEntityBase> saveReferencedEntitiesAll(Collection<ReferencedEntityBase> referencedEntityCollection);
91

    
92
	/**
93
	 * Saves the given homotypical groups.
94
	 * @param homotypicalGroups
95
	 * @return
96
	 */
97
	public Map<UUID, HomotypicalGroup> saveAllHomotypicalGroups(Collection<HomotypicalGroup> homotypicalGroups);
98

    
99
	/**
100
	 * Returns all nomenclatural status.
101
	 * @param limit
102
	 * @param start
103
	 * @return
104
	 */
105
	public List<NomenclaturalStatus> getAllNomenclaturalStatus(int limit, int start);
106

    
107
	/**
108
	 * Returns all type designations.
109
	 * @param limit
110
	 * @param start
111
	 * @return
112
	 */
113
	public List<TypeDesignationBase> getAllTypeDesignations(int limit, int start);
114

    
115
    public TypeDesignationBase loadTypeDesignation(int id, List<String> propertyPaths);
116

    
117
    public TypeDesignationBase loadTypeDesignation(UUID uuid, List<String> propertyPaths);
118

    
119
	/**
120
	 * Returns all NonViralNames with a name cache that matches the given string
121
	 * @param name
122
	 * @return
123
	 */
124
	public List<TaxonName> getNamesByNameCache(String nameCache);
125

    
126
	/**
127
	 * Returns all NonViralNames with a title cache that matches the given string
128
	 * using the given match mode and initialization strategy
129
	 *
130
	 * @param name
131
	 * @param matchMode
132
	 * @param propertyPaths
133
	 * @return
134
	 */
135
	public List<TaxonName> findNamesByTitleCache(String titleCache, MatchMode matchMode, List<String> propertyPaths);
136

    
137
	/**
138
	 * Returns all NonViralNames with a name cache that matches the given string
139
	 * using the given match mode and initialization strategy
140
	 *
141
	 * @param name
142
	 * @param matchMode
143
	 * @param propertyPaths
144
	 * @return
145
	 */
146
	public List<TaxonName> findNamesByNameCache(String nameCache, MatchMode matchMode, List<String> propertyPaths);
147

    
148
	/**
149
	 * @param name
150
	 * @param sessionObject An object that is attached to the session before executing the query
151
	 * @return
152
	 */
153
	public List getNamesByName(String name, CdmBase sessionObject);
154

    
155
	/**
156
	 * Fuzzy matching for the taxon name elements. The input name is first atomised using the {@link NonViralNameParserImpl}
157
	 * into its separate parts (genusOrUninomial,infraGenericEpithet,specificEpithet,infraGenericEpithet,authorshipCache).
158
	 * Each field is then matched separately with the same accuracy parameter.
159
	 *
160
	 * @param name taxon name to fuzzy match
161
	 * @param accuracy value > 0.0 and < 1.0 which determines the accuracy of the result.
162
	 * @param languages list of languages to consider when matching (currently not used)
163
	 * @param highlightFragments
164
	 * @param propertyPaths
165
	 * @param maxNoOfResults
166
	 * @return
167
	 * @throws CorruptIndexException
168
	 * @throws IOException
169
	 * @throws ParseException
170
	 */
171
	public List<SearchResult<TaxonName>> findByNameFuzzySearch(
172
            String name,
173
            float accuracy,
174
            List<Language> languages,
175
            boolean highlightFragments,
176
            List<String> propertyPaths,
177
            int maxNoOfResults) throws IOException, LuceneParseException;
178

    
179
	/**
180
	 * Fuzzy matching for the taxon name elements using only the lucene index.
181
	 *
182
	 * The input name is first atomised using the {@link NonViralNameParserImpl}
183
	 * into its separate parts (genusOrUninomial,infraGenericEpithet,specificEpithet,infraGenericEpithet,authorshipCache).
184
	 * Each field is then matched separately with the same accuracy parameter.
185
	 *
186
	 * @param name taxon name to fuzzy match
187
	 * @param accuracy value > 0.0 and < 1.0 which determines the accuracy of the result.
188
	 * @param languages list of languages to consider when matching (currently not used)
189
	 * @param highlightFragments
190
	 * @param maxNoOfResults
191
	 * @return
192
	 * @throws CorruptIndexException
193
	 * @throws IOException
194
	 * @throws ParseException
195
	 */
196
    public List<DocumentSearchResult> findByNameFuzzySearch(
197
            String name,
198
            float accuracy,
199
            List<Language> languages,
200
            boolean highlightFragments,
201
            int maxNoOfResults) throws IOException, LuceneParseException;
202

    
203
	/**
204
	 * Fuzzy matching against the name cache using only the lucene index.
205
	 *
206
	 *
207
	 * @param name taxon name to fuzzy match
208
	 * @param accuracy value > 0.0 and < 1.0 which determines the accuracy of the result.
209
	 * @param languages list of languages to consider when matching (currently not used)
210
	 * @param highlightFragments
211
	 * @param maxNoOfResults
212
	 * @return
213
	 * @throws CorruptIndexException
214
	 * @throws IOException
215
	 * @throws ParseException
216
	 */
217
    public List<DocumentSearchResult> findByFuzzyNameCacheSearch(
218
            String name,
219
            float accuracy,
220
            List<Language> languages,
221
            boolean highlightFragments,
222
            int maxNoOfResults) throws IOException, LuceneParseException;
223

    
224
	/**
225
	 * Exact matching for the taxon name elements using only the lucene index.
226
	 *
227
	 * The input name is first atomised using the {@link NonViralNameParserImpl}
228
	 * into its separate parts (genusOrUninomial,infraGenericEpithet,specificEpithet,infraGenericEpithet,authorshipCache).
229
	 * Each field is then matched separately with the same accuracy parameter.
230
	 *
231
	 * @param name taxon name to fuzzy match
232
	 * @param wildcard boolean flag to indicate whether a wildcard '*' should be added at the end of the query
233
	 * @param languages list of languages to consider when matching (currently not used)
234
	 * @param highlightFragments
235
	 * @param maxNoOfResults
236
	 * @return
237
	 * @throws CorruptIndexException
238
	 * @throws IOException
239
	 * @throws ParseException
240
	 */
241

    
242
    public List<DocumentSearchResult> findByNameExactSearch(
243
            String name,
244
            boolean wildcard,
245
            List<Language> languages,
246
            boolean highlightFragments,
247
            int maxNoOfResults) throws IOException, LuceneParseException;
248

    
249
	// TODO: Remove getNamesByName() methods. Use findNamesByTitle() instead.
250

    
251
    public List<HomotypicalGroup> getAllHomotypicalGroups(int limit, int start);
252

    
253
	@Deprecated
254
    public List<RelationshipBase> getAllRelationships(int limit, int start);
255

    
256

    
257
	/**
258
	 * Return a List of name relationships in which this name is related to
259
	 * another name, optionally filtered by relationship type
260
	 *
261
	 * @param name
262
	 *            the name on either the <i>"from side"</i> or on the
263
	 *            <i>"to side"</i> of the relationship, depending on the
264
	 *            <code>direction</code> of the relationship.
265
	 * @param direction
266
	 *            the direction of the NameRelationship, may be null to return all relationships
267
	 * @param type
268
	 *            the relationship type (or null to return all relationships)
269
	 * @param pageSize
270
	 *            The maximum number of relationships returned (can be null for
271
	 *            all relationships)
272
	 * @param pageNumber
273
	 *            The offset (in pageSize chunks) from the start of the result
274
	 *            set (0 - based)
275
	 * @param orderHints
276
	 *            may be null
277
	 * @param propertyPaths
278
	 *            properties to initialize - see
279
	 *            {@link IBeanInitializer#initialize(Object, List)}
280
	 * @return a Pager of NameRelationship instances
281
	 */
282
	public List<NameRelationship> listNameRelationships(TaxonName name,  NameRelationship.Direction direction, NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
283

    
284
	/**
285
	 * Return a List of name relationships in which this name is related to another name, optionally filtered
286
	 * by relationship type
287
	 *
288
	 * @param name the name on the <i>"from side"</i> of the relationship
289
	 * @param direction the direction of the NameRelationship
290
	 * @param type the relationship type (or null to return all relationships)
291
	 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
292
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
293
	 * @param orderHints may be null
294
	 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
295
	 * @return a Pager of NameRelationship instances
296
	 */
297
	public Pager<NameRelationship> pageNameRelationships(TaxonName name,  NameRelationship.Direction direction, NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
298

    
299
	/**
300
	 * Return a List of relationships in which this name is related to another name, optionally filtered
301
	 * by relationship type
302
	 *
303
	 * @param name the name on the <i>"from side"</i> of the relationship
304
	 * @param type the relationship type (or null to return all relationships)
305
	 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
306
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
307
	 * @param orderHints may be null
308
	 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
309
	 * @return a Pager of NameRelationship instances
310
	 * @deprecated use {@link #listNameRelationships(TaxonName, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
311
	 */
312
	@Deprecated
313
	public List<NameRelationship> listFromNameRelationships(TaxonName name,  NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
314

    
315
	/**
316
	 * Return a List of relationships in which this name is related to another name, optionally filtered
317
	 * by relationship type
318
	 *
319
	 * @param name the name on the <i>"from side"</i> of the relationship
320
	 * @param type the relationship type (or null to return all relationships)
321
	 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
322
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
323
	 * @param orderHints may be null
324
	 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
325
	 * @return a Pager of NameRelationship instances
326
	 * @deprecated use {@link #pageNameRelationships(TaxonName, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
327
	 */
328
	@Deprecated
329
	public Pager<NameRelationship> pageFromNameRelationships(TaxonName name,  NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
330

    
331
	/**
332
	 * Return a List of relationships in which another name is related to this name, optionally filtered
333
	 * by relationship type
334
	 *
335
	 * @param name the name on the <i>"to side"</i> of the relationship
336
	 * @param type the relationship type (or null to return all relationships)
337
	 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
338
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
339
	 * @param orderHints may be null
340
	 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
341
	 * @return a Pager of NameRelationship instances
342
	 * @deprecated use {@link #listNameRelationships(TaxonName, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
343
	 */
344
	@Deprecated
345
	public List<NameRelationship> listToNameRelationships(TaxonName name,  NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
346

    
347
	/**
348
	 * Return a List of relationships in which another name is related to this name, optionally filtered
349
	 * by relationship type
350
	 *
351
	 * @param name the name on the <i>"to side"</i> of the relationship
352
	 * @param type the relationship type (or null to return all relationships)
353
	 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
354
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
355
	 * @param orderHints may be null
356
	 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
357
	 * @return a Pager of NameRelationship instances
358
	 * @deprecated use {@link #pageNameRelationships(TaxonName, eu.etaxonomy.cdm.model.common.RelationshipBase.Direction, NameRelationshipType, Integer, Integer, List, List)} instead
359
	 */
360
	@Deprecated
361
	public Pager<NameRelationship> pageToNameRelationships(TaxonName name,  NameRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
362

    
363

    
364
	/**
365
	 * Return a List of hybrids related to this name, optionally filtered
366
	 * by hybrid relationship type
367
	 *
368
	 * @param name the name
369
	 * @param type the hybrid relationship type (or null to return all hybrids)
370
	 * @param pageSize The maximum number of hybrid relationships returned (can be null for all relationships)
371
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
372
	 * @param orderHints may be null
373
	 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
374
	 * @return a Pager of HybridRelationship instances
375
	 */
376
	public Pager<HybridRelationship> getHybridNames(INonViralName name, HybridRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
377

    
378
	/**
379
	 * Return a List of types related to this name, optionally filtered
380
	 * by type designation status
381
	 *
382
	 * @param name the name
383
	 * @param status the type designation status (or null to return all types)
384
	 * @param pageSize The maximum number of types returned (can be null for all types)
385
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
386
	 * @return a Pager of TypeDesignationBase instances
387
	 */
388
	public Pager<TypeDesignationBase> getTypeDesignations(TaxonName name,
389
			SpecimenTypeDesignationStatus status, Integer pageSize, Integer pageNumber);
390

    
391
	public Pager<TypeDesignationBase> getTypeDesignations(TaxonName name,
392
			SpecimenTypeDesignationStatus status, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
393

    
394

    
395
	/**
396
	 * Returns a List of TaxonName instances that match the properties passed
397
	 *
398
	 * @param uninomial
399
	 * @param infraGenericEpithet
400
	 * @param specificEpithet
401
	 * @param infraspecificEpithet
402
	 * @param rank
403
	 * @param pageSize The maximum number of names returned (can be null for all names)
404
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
405
	 * @param orderHints may be null
406
	 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
407
	 * @return a Pager of TaxonName instances
408
	 */
409
	public Pager<TaxonName> searchNames(String uninomial, String infraGenericEpithet, String specificEpithet, String infraspecificEpithet, Rank rank, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
410

    
411
	/**
412
	 * Returns a Paged List of TaxonName instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
413
	 *
414
	 * @param clazz filter the results by class (or pass null to return all TaxonName instances)
415
	 * @param queryString
416
	 * @param pageSize The maximum number of names returned (can be null for all matching names)
417
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
418
	 * @param orderHints
419
	 *            Supports path like <code>orderHints.propertyNames</code> which
420
	 *            include *-to-one properties like createdBy.username or
421
	 *            authorTeam.persistentTitleCache
422
	 * @param propertyPaths properties to be initialized
423
	 * @return a Pager TaxonName instances
424
	 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
425
	 */
426
	@Override
427
    public Pager<TaxonName> search(Class<? extends TaxonName> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
428

    
429
	/**
430
	 * Returns a map that holds uuid, titleCache pairs of all names in the current database
431
	 *
432
	 * @return
433
	 * 			a <code>Map</code> containing uuid and titleCache of names
434
	 */
435
	public List<UuidAndTitleCache> getUuidAndTitleCacheOfNames(Integer limit, String pattern);
436

    
437
	/**
438
	 * Return a Pager of names matching the given query string, optionally filtered by class, optionally with a particular MatchMode
439
	 *
440
	 * @param clazz filter by class - can be null to include all instances of type T
441
	 * @param queryString the query string to filter by
442
	 * @param matchmode use a particular type of matching (can be null - defaults to exact matching)
443
	 * @param criteria additional criteria to filter by
444
	 * @param pageSize The maximum number of objects returned (can be null for all objects)
445
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
446
	 * @param propertyPaths properties to initialize - see {@link IBeanInitializer#initialize(Object, List)}
447
	 * @param orderHints
448
	 *            Supports path like <code>orderHints.propertyNames</code> which
449
	 *            include *-to-one properties like createdBy.username or
450
	 *            authorTeam.persistentTitleCache
451
	 * @return a paged list of instances of type T matching the queryString
452
	 */
453
    public Pager<TaxonName> findByName(Class<? extends TaxonName> clazz, String queryString,MatchMode matchmode, List<Criterion> criteria, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
454

    
455
    /**
456
     * Returns a homotypical group with the given UUID or null if not homotypical group exists with that UUID
457
     *
458
     * @param uuid the uuid of the homotypical group
459
     * @return a homotypical group
460
     */
461
    public HomotypicalGroup findHomotypicalGroup(UUID uuid);
462

    
463
    /**
464
     * @param uuid
465
     * @return
466
     */
467
    public List<TaggedText> getTaggedName(UUID uuid);
468

    
469
    /**
470
     * @param nameUuid
471
     * @return
472
     */
473
    public UpdateResult setAsGroupsBasionym(UUID nameUuid);
474

    
475
	public List<HashMap<String, String>> getNameRecords();
476

    
477
    /**
478
     * @param name
479
     * @param config
480
     * @return
481
     */
482
    DeleteResult delete(TaxonName name, NameDeletionConfigurator config);
483

    
484

    
485
}
(48-48/105)