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.apache.lucene.index.CorruptIndexException;
20
import org.hibernate.criterion.Criterion;
21

    
22
import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
23
import eu.etaxonomy.cdm.api.service.pager.Pager;
24
import eu.etaxonomy.cdm.api.service.search.DocumentSearchResult;
25
import eu.etaxonomy.cdm.api.service.search.LuceneParseException;
26
import eu.etaxonomy.cdm.api.service.search.SearchResult;
27
import eu.etaxonomy.cdm.model.common.CdmBase;
28
import eu.etaxonomy.cdm.model.common.Language;
29
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
30
import eu.etaxonomy.cdm.model.common.RelationshipBase;
31
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
32
import eu.etaxonomy.cdm.model.name.HybridRelationship;
33
import eu.etaxonomy.cdm.model.name.HybridRelationshipType;
34
import eu.etaxonomy.cdm.model.name.INonViralName;
35
import eu.etaxonomy.cdm.model.name.NameRelationship;
36
import eu.etaxonomy.cdm.model.name.NameRelationshipType;
37
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
38
import eu.etaxonomy.cdm.model.name.Rank;
39
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
40
import eu.etaxonomy.cdm.model.name.TaxonName;
41
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
42
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
43
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
44
import eu.etaxonomy.cdm.persistence.query.MatchMode;
45
import eu.etaxonomy.cdm.persistence.query.OrderHint;
46
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
47
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
48

    
49
public interface INameService extends IIdentifiableEntityService<TaxonName> {
50

    
51
	/**
52
	 * Deletes a name. Depening on the configurator state links to the name will either be
53
	 * deleted or throw exceptions.<BR>
54
	 * If name is <code>null</code> this method has no effect.
55
	 * @param name
56
	 * @param config
57
	 *
58
	 */
59
	public DeleteResult delete(UUID nameUUID, NameDeletionConfigurator config);
60

    
61
	/**
62
	 * Removes the given type designation from the given taxon name and deletes it from
63
	 * the database if it is not connected to any other name.
64
	 * If <code>typeDesignation</code> is <code>null</code> all type designations are deleted
65
	 * from the given taxon name. If <code>name</code> is <code>null</code> all names are removed from
66
	 * the given type designation. If both are <code>null</code> nothing happens.
67
	 * @param typeDesignation
68
	 * @param name
69
	 * @return
70
	 */
71
	public DeleteResult deleteTypeDesignation(TaxonName name, TypeDesignationBase typeDesignation);
72

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

    
85

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

    
93
	public Map<UUID, ReferencedEntityBase> saveReferencedEntitiesAll(Collection<ReferencedEntityBase> referencedEntityCollection);
94

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
255

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

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

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

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

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

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

    
362

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

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

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

    
393

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

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

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

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

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

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

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

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

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

    
483

    
484
}
(48-48/101)