Project

General

Profile

Download (46.9 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.io.IOException;
14
import java.util.EnumSet;
15
import java.util.List;
16
import java.util.Set;
17
import java.util.UUID;
18

    
19
import org.apache.lucene.index.CorruptIndexException;
20
import org.apache.lucene.queryparser.classic.ParseException;
21

    
22
import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
23
import eu.etaxonomy.cdm.api.service.config.IncludedTaxonConfiguration;
24
import eu.etaxonomy.cdm.api.service.config.MatchingTaxonConfigurator;
25
import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
26
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
27
import eu.etaxonomy.cdm.api.service.dto.FindByIdentifierDTO;
28
import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO;
29
import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
30
import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;
31
import eu.etaxonomy.cdm.api.service.pager.Pager;
32
import eu.etaxonomy.cdm.api.service.search.LuceneMultiSearchException;
33
import eu.etaxonomy.cdm.api.service.search.SearchResult;
34
import eu.etaxonomy.cdm.api.service.util.TaxonRelationshipEdge;
35
import eu.etaxonomy.cdm.model.common.DefinedTerm;
36
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
37
import eu.etaxonomy.cdm.model.common.Language;
38
import eu.etaxonomy.cdm.model.common.RelationshipBase;
39
import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;
40
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
41
import eu.etaxonomy.cdm.model.description.Feature;
42
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
43
import eu.etaxonomy.cdm.model.location.NamedArea;
44
import eu.etaxonomy.cdm.model.media.Media;
45
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
46
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
47
import eu.etaxonomy.cdm.model.name.Rank;
48
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
49
import eu.etaxonomy.cdm.model.reference.Reference;
50
import eu.etaxonomy.cdm.model.taxon.Classification;
51
import eu.etaxonomy.cdm.model.taxon.Synonym;
52
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
53
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
54
import eu.etaxonomy.cdm.model.taxon.Taxon;
55
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
56
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
57
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
58
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
59
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
60
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
61
import eu.etaxonomy.cdm.persistence.query.MatchMode;
62
import eu.etaxonomy.cdm.persistence.query.OrderHint;
63

    
64

    
65
public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
66

    
67
    /**
68
     * Computes all relationships.
69
     * @param limit
70
     * @param start
71
     * @return
72
     * FIXME candidate for harmonization - rename to listRelationships
73
     */
74
    public List<RelationshipBase> getAllRelationships(int limit, int start);
75

    
76
    /**
77
     * Returns a list of taxa that matches the name string and the sec reference
78
     * @param name the name string to search for
79
     * @param sec the taxons sec reference
80
     * @return a list of taxa matching the name and the sec reference
81
     */
82
    public List<TaxonBase> searchTaxaByName(String name, Reference sec);
83

    
84
    /**
85
     * Swaps given synonym and accepted taxon.
86
     * In particular:
87
     * <ul>
88
     * 		<li>A new accepted taxon with the synonyms name is created</li>
89
     * 		<li>The synonym is deleted from the old accepted taxons synonym list</li>
90
     * 		<li>A new synonym with the name of the old accepted taxon is created</li>
91
     * 		<li>The newly created synonym get related to the newly created accepted taxon</li>
92
     * </ul>
93
     *
94
     * @param synonym
95
     * @param acceptedTaxon
96
     * @param synonymRelationshipType the relationship type the newly created synonym will have. Defaults to SYNONYM_OF
97
     * @return
98
     */
99
    public UpdateResult swapSynonymAndAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon);
100

    
101
    /**
102
     * Changes a synonym into an accepted taxon and removes
103
     * the synonym relationship to the given accepted taxon.
104
     * Other synonyms homotypic to the synonym to change are
105
     * moved to the same new accepted taxon as homotypic
106
     * synonyms. The new accepted taxon has the same name and
107
     * the same sec reference as the old synonym.<BR>
108
     * If the given accepted taxon and the synonym are homotypic
109
     * to each other an exception may be thrown as taxonomically it doesn't
110
     * make sense to have two accepted taxa in the same homotypic group
111
     * but also it is than difficult to decide how to handle other names
112
     * in the homotypic group. It is up to the implementing class to
113
     * handle this situation via an exception or in another way.
114
     *
115
     *
116
     * @param synonym
117
     * 				the synonym to change into an accepted taxon
118
     * @param acceptedTaxon
119
     * 				an accepted taxon, the synonym had a relationship to
120
     * @param deleteSynonym
121
     * 			if true the method tries to delete the old synonym from the database
122
     * @param copyCitationInfo
123
     * 			if true the citation and the microcitation of newly created synonyms
124
     * 			is taken from the old synonym relationships.
125
     * @param citation
126
     * 			if given this citation is added to the newly created synonym
127
     * 			relationships as citation. Only used if copyCitationInfo is <code> false</code>
128
     * @param microCitation
129
     * 			if given this microCitation is added to the newly created synonym
130
     * 			relationships as microCitation.Only used if copyCitationInfo is <code> false</code>
131
     * @return
132
     * 			the newly created accepted taxon
133
     * @throws IllegalArgumentException
134
     * 			if the given accepted taxon and the synonym are homotypic
135
     * 		    to each other an exception may be thrown as taxonomically it doesn't
136
     * 			make sense to have two accepted taxa in the same homotypic group
137
     *          but also it is than difficult to decide how to handle other names
138
     *          in the homotypic group. It is up to the implementing class to
139
     *          handle this situation via an exception or in another way.
140
     */
141
    public Taxon changeSynonymToAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon, boolean deleteSynonym, boolean copyCitationInfo, Reference citation, String microCitation) throws HomotypicalGroupChangeException;
142

    
143
    /**
144
     * TODO still needed and correct?
145
     * Change a synonym into a related concept
146
     *
147
     * @param synonym
148
     * 				the synonym to change into the concept taxon
149
     * @param toTaxon
150
     * 				the taxon the newly created concept should be related to
151
     * @param taxonRelationshipType
152
     * 				the type of relationship
153
     * @param reference
154
     * @param microReference
155
     * @return
156
     * 				the newly created concept
157
     */
158
    public Taxon changeSynonymToRelatedTaxon(Synonym synonym, Taxon toTaxon, TaxonRelationshipType taxonRelationshipType, Reference reference, String microReference);
159

    
160
    /**
161
     * TODO still needed and correct?
162
     * Change a synonym into a related concept
163
     *
164
     * @param synonym
165
     * 				the synonym to change into the concept taxon
166
     * @param toTaxon
167
     * 				the taxon the newly created concept should be related to
168
     * @param taxonRelationshipType
169
     * 				the type of relationship
170
     * @param reference
171
     * @param microReference
172
     * @return
173
     * 				the newly created concept
174
     * @throws DataChangeNoRollbackException
175
     */
176
  public 	Synonym changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
177
             TaxonRelationshipType oldRelationshipType,
178
            SynonymRelationshipType synonymRelationshipType) throws DataChangeNoRollbackException;
179

    
180
    /**
181
     * Changes the homotypic group of a synonym into the new homotypic group.
182
     * All relations to taxa are updated correctly depending on the homotypic
183
     * group of the accepted taxon. <BR>
184
     * All existing basionym relationships to and from this name are removed.<BR>
185
     * If the parameter <code>targetTaxon</code> is defined, the synonym is
186
     * added to this taxon irrespctive of if it has been related to this
187
     * taxon before.<BR>
188
     * If <code>removeFromOtherTaxa</code> is true and <code>targetTaxon</code> is
189
     * defined all relationships to other taxa are deleted.<BR>
190
     * If <code>setBasionymRelationIfApplicable</code> is true a basionym relationship
191
     * between the existing basionym(s) of the new homotypic group and the synonyms name
192
     * is added.<BR>
193
     *
194
     * @param synonym
195
     * @param newHomotypicalGroup
196
     * @param taxon
197
     * @param setBasionymRelationIfApplicable
198
     */
199
    public void changeHomotypicalGroupOfSynonym(Synonym synonym, HomotypicalGroup newHomotypicalGroup, Taxon targetTaxon,
200
                        boolean removeFromOtherTaxa, boolean setBasionymRelationIfApplicable);
201

    
202

    
203
    /**
204
     * Moves a synonym to another taxon and removes the old synonym relationship.
205
     *
206
     * @param oldSynonymRelation the old synonym relationship defining the synonym to move and the old accepted taxon.
207
     * @param newTaxon the taxon the synonym will be moved to
208
     * @param moveHomotypicGroup if the synonym belongs to a homotypical group with other synonyms and
209
     * 		<code>moveHomotypicGroup</code> is <code>true</code> all these synonyms are moved to the new taxon,
210
     * 		if <code>false</code> a {@link HomotypicalGroupChangeException} is thrown.
211
     * 		<code>MoveHomotypicGroup</code> has no effect if the synonym is the only synonym in it's homotypic group.
212
     * @param newSynonymRelationshipType the synonym relationship type of the new synonym relations. Default is
213
     * 		{@link SynonymRelationshipType#HETEROTYPIC_SYNONYM_OF() heterotypic}.
214
     * @param newReference The reference for the new synonym relation(s).
215
     * @param newReferenceDetail The reference detail for the new synonym relation(s).
216
     * @param keepReference if no <code>newReference</code> and/or no <code>newReferenceDetail</code>
217
     * 		is defined they are taken from the old synonym relation(s) if <code>keepReference</code> is
218
     * 		<code>true</code>. If <code>false</code> the reference and the reference detail will be taken
219
     * 		only from the <code>newReference</code> and <code>newReferenceDetail</code>.
220
     * @return The new synonym relationship. If <code>moveHomotypicGroup</code> is <code>true</code> additionally
221
     * 		created new synonym relationships must be retrieved separately from the new taxon.
222
     * @throws HomotypicalGroupChangeException Exception is thrown if (1) synonym is homotypic to the old accepted taxon or
223
     * 		(2) synonym is in homotypic group with other synonyms and <code>moveHomotypicGroup</code> is false
224
     */
225
    public UpdateResult moveSynonymToAnotherTaxon(SynonymRelationship oldSynonymRelation, Taxon newTaxon, boolean moveHomotypicGroup,
226
            SynonymRelationshipType newSynonymRelationshipType, Reference newReference, String newReferenceDetail, boolean keepReference) throws HomotypicalGroupChangeException;
227

    
228
    /**
229
     * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
230
     * where the supplied taxon is relatedTo.
231
     *
232
     * @param taxon The taxon that is relatedTo
233
     * @param type The type of TaxonRelationship (can be null)
234
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
235
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
236
     * @param orderHints Properties to order by
237
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
238
     * @return a List of TaxonRelationship instances
239
     */
240
    public List<TaxonRelationship> listToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
241

    
242

    
243

    
244
    /**
245
     * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
246
     * where the supplied taxon is relatedTo.
247
     *
248
     * @param taxon The taxon that is relatedTo
249
     * @param type The type of TaxonRelationship (can be null)
250
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
251
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
252
     * @param orderHints Properties to order by
253
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
254
     * @return a Pager of TaxonRelationship instances
255
     */
256
    public Pager<TaxonRelationship> pageToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
257

    
258
    /**
259
     * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
260
     * where the supplied taxon is relatedFrom.
261
     *
262
     * @param taxon The taxon that is relatedFrom
263
     * @param type The type of TaxonRelationship (can be null)
264
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
265
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
266
     * @param orderHints Properties to order by
267
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
268
     * @return a List of TaxonRelationship instances
269
     */
270
    public List<TaxonRelationship> listFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
271

    
272

    
273
    /**
274
     * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
275
     * where the supplied taxon is relatedFrom.
276
     *
277
     * @param taxon The taxon that is relatedFrom
278
     * @param type The type of TaxonRelationship (can be null)
279
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
280
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
281
     * @param orderHints Properties to order by
282
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
283
     * @return a Pager of TaxonRelationship instances
284
     */
285
    public Pager<TaxonRelationship> pageFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
286

    
287
    /**
288
     * lists all taxa which are related to the <code>taxon</code> given as
289
     * parameter.
290
     *
291
     * @param taxon
292
     * @param includeRelationships
293
     * @param maxDepth
294
     *            <code>1</code> for one level, <code>null</code> for infinite
295
     *            depth, <code>0</code> will completely omit collecting related taxa.
296
     * @param limit
297
     * @param start
298
     * @param propertyPaths
299
     * @return
300
     */
301
    public Set<Taxon> listRelatedTaxa(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, Integer maxDepth,
302
            Integer limit, Integer start, List<String> propertyPaths);
303

    
304
    /**
305
     * lists all accepted taxa for the given {@link Synonym}
306
     *
307
     * @param taxonBase
308
     * @param limit
309
     * @param start
310
     * @param propertyPaths
311
     * @return
312
     */
313
    public List<Classification> listClassifications(TaxonBase taxonBase, Integer limit, Integer start, List<String> propertyPaths);
314

    
315
    /**
316
     * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
317
     * where the supplied synonym is relatedFrom.
318
     *
319
     * @param taxon The synonym that is relatedFrom
320
     * @param type The type of SynonymRelationship (can be null)
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 Properties to order by
324
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
325
     * @return a Pager of SynonymRelationship instances
326
     */
327
    public Pager<SynonymRelationship> getSynonyms(Synonym synonym, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
328

    
329
    /**
330
     * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
331
     * where the supplied taxon is relatedTo.
332
     *
333
     * @param taxon The taxon that is relatedTo
334
     * @param type The type of SynonymRelationship (can be null)
335
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
336
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
337
     * * @param orderHints Properties to order by
338
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
339
     * @return a Pager of SynonymRelationship instances
340
     */
341
    public Pager<SynonymRelationship> getSynonyms(Taxon taxon, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
342

    
343
    /**
344
     * This method returns in the first entry the list of synonyms of the
345
     * homotypic group of the accepted taxon. All other entries represent the lists of heterotypic
346
     * synonym groups. For detailed information about these 2 groups see
347
     * {@link #getHomotypicSynonymsByHomotypicGroup(Taxon, List)} and
348
     * {@link #getHeterotypicSynonymyGroups(Taxon, List)}
349
     *
350
     * @see			#getSynonyms()
351
     * @see			SynonymRelationshipType#HETEROTYPIC_SYNONYM_OF()
352
     * @see			eu.etaxonomy.cdm.model.name.HomotypicalGroup
353

    
354
     * @param taxon the accepted taxon
355
     * @param propertyPaths the property path
356
     * @return the list of groups of synonyms
357
     */
358
    public List<List<Synonym>> getSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
359

    
360

    
361
    /**
362
     * Returns the list of all synonyms that share the same homotypical group with the given taxon.
363
     * Only those homotypic synonyms are returned that do have a synonym relationship with the accepted taxon.
364
     * @param taxon
365
     * @param propertyPaths
366
     * @return
367
     */
368
    public List<Synonym> getHomotypicSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
369

    
370
    /**
371
     * Returns the ordered list of all {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup homotypical groups}
372
     * that contain {@link Synonym synonyms} that are heterotypic to the given taxon.
373
     * {@link eu.etaxonomy.cdm.model.name.TaxonNameBase Taxon names} of heterotypic synonyms
374
     * belong to a homotypical group which cannot be the homotypical group to which the
375
     * taxon name of the given taxon belongs. This method does not return the homotypic group the given
376
     * taxon belongs to.<BR>
377
     * This method does neglect the type of synonym relationship that is defined between the given taxon
378
     * and the synonym. So the synonym relationship may be homotypic however a synonym is returned
379
     * in one of the result lists as long as the synonym does not belong to the same homotypic group as
380
     * the given taxon.<BR>
381
     * The list returned is ordered according to the date of publication of the
382
     * first published name within each homotypical group.
383
     *
384
     * @see			#getHeterotypicSynonymyGroups()
385
     * @see			#getSynonyms()
386
     * @see			SynonymRelationshipType#HETEROTYPIC_SYNONYM_OF()
387
     * @see			eu.etaxonomy.cdm.model.name.HomotypicalGroup
388

    
389
     * @param taxon
390
     * @param propertyPaths
391
     * @return
392
     */
393
    public List<List<Synonym>> getHeterotypicSynonymyGroups(Taxon taxon, List<String> propertyPaths);
394

    
395
    /**
396
     * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
397
     *
398
     * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
399
     * @param queryString
400
     * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
401
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
402
     * @param orderHints
403
     *            Supports path like <code>orderHints.propertyNames</code> which
404
     *            include *-to-one properties like createdBy.username or
405
     *            authorTeam.persistentTitleCache
406
     * @param propertyPaths properties to be initialized
407
     * @return a Pager Taxon instances
408
     * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
409
     */
410
    @Override
411
    public Pager<TaxonBase> search(Class<? extends TaxonBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
412

    
413
    /**
414
     * Returns a list of TaxonBase instances where the
415
     * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
416
     * <i>null</i> will search for those taxa with a value of null in that field
417
     *
418
     * @param clazz optionally filter by class (can be null to return all taxa)
419
     * @param uninomial
420
     * @param infragenericEpithet
421
     * @param specificEpithet
422
     * @param infraspecificEpithet
423
     * @param rank
424
     * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
425
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
426
     * @return a list of TaxonBase instances
427
     */
428
    public Pager<TaxonBase> findTaxaByName(Class<? extends TaxonBase> clazz, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, String authorship, Rank rank, Integer pageSize, Integer pageNumber);
429

    
430
    /**
431
     * Returns a list of TaxonBase instances where the
432
     * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
433
     * <i>null</i> will search for those taxa with a value of null in that field
434
     *
435
     * @param clazz optionally filter by class
436
     * @param uninomial
437
     * @param infragenericEpithet
438
     * @param specificEpithet
439
     * @param infraspecificEpithet
440
     * @param rank
441
     * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
442
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
443
     * @return a List of TaxonBase instances
444
     */
445
    public List<TaxonBase> listTaxaByName(Class<? extends TaxonBase> clazz, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, String authorship, Rank rank, Integer pageSize, Integer pageNumber);
446

    
447
    /**
448
     * Returns a list of IdentifiableEntity instances (in particular, TaxonNameBase and TaxonBase instances)
449
     * that match the properties specified in the configurator.
450
     * @param configurator
451
     * @return
452
     */
453
    public Pager<IdentifiableEntity> findTaxaAndNames(IFindTaxaAndNamesConfigurator configurator);
454

    
455
    /**
456
     * performes a union searches for TaxonBase instances on all available
457
     * free text indexes. At the time of writing this documentation it combines
458
     * {@link #findByDescriptionElementFullText(Class, String, Classification, List, List, boolean, Integer, Integer, List, List)}
459
     * and {@link #findByFullText(Class, String, Classification, List, boolean, Integer, Integer, List, List)
460
     *
461
     * @param queryString
462
     *            the query string
463
     * @param classification
464
     *            Additional filter criterion: If a taxonomic classification
465
     *            three is specified here the result set will only contain taxa
466
     *            of the given classification
467
     * @param languages
468
     *            Additional filter criterion: Search only in these languages.
469
     *            Not all text fields in the cdm model are multilingual, thus
470
     *            this setting will only apply to the multilingiual fields.
471
     *            Other fields are searched nevertheless if this parameter is
472
     *            set or not.
473
     * @param highlightFragments
474
     *            TODO
475
     * @param pageSize
476
     *            The maximum number of objects returned (can be null for all
477
     *            objects)
478
     * @param pageNumber
479
     *            The offset (in pageSize chunks) from the start of the result
480
     *            set (0 - based)
481
     * @param orderHints
482
     *            Supports path like <code>orderHints.propertyNames</code> which
483
     *            include *-to-one properties like createdBy.username or
484
     *            authorTeam.persistentTitleCache
485
     * @param propertyPaths
486
     *            properties to initialize - see
487
     *            {@link IBeanInitializer#initialize(Object, List)}
488
     * @return a paged list of instances of type T matching the queryString and
489
     *         the additional filter criteria
490
     * @return
491
     * @throws CorruptIndexException
492
     * @throws IOException
493
     * @throws ParseException
494
     * @throws LuceneMultiSearchException
495
     * @deprecated this search should fully be covered by the new method
496
     *      {@link #findTaxaAndNamesByFullText(EnumSet, String, Classification, Set, List, boolean, Integer, Integer, List, List)}
497
     *      , maybe we should rename this latter method to give it a more meaningful name
498
     */
499
    @Deprecated
500
    public Pager<SearchResult<TaxonBase>> findByEverythingFullText(String queryString,
501
            Classification classification, List<Language> languages, boolean highlightFragments,
502
            Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws CorruptIndexException, IOException, ParseException, LuceneMultiSearchException;
503

    
504
    /**
505
     * Searches for TaxonBase instances using the TaxonBase free text index.
506
     *
507
     * <h4>This is an experimental feature, it may be moved, modified, or even
508
     * removed in future releases!!!</h4>
509
     *
510
     * @param clazz
511
     *            Additional filter criterion: The specific TaxonBase subclass
512
     *            to search for
513
     * @param queryString
514
     *            the query string
515
     * @param classification
516
     *            Additional filter criterion: If a taxonomic classification
517
     *            three is specified here the result set will only contain taxa
518
     *            of the given classification
519
     * @param languages
520
     *            Additional filter criterion: Search only in these languages.
521
     *            Not all text fields in the cdm model are multilingual, thus
522
     *            this setting will only apply to the multilingiual fields.
523
     *            Other fields are searched nevertheless if this parameter is
524
     *            set or not.
525
     * @param highlightFragments
526
     *            TODO
527
     * @param pageSize
528
     *            The maximum number of objects returned (can be null for all
529
     *            objects)
530
     * @param pageNumber
531
     *            The offset (in pageSize chunks) from the start of the result
532
     *            set (0 - based)
533
     * @param orderHints
534
     *            Supports path like <code>orderHints.propertyNames</code> which
535
     *            include *-to-one properties like createdBy.username or
536
     *            authorTeam.persistentTitleCache
537
     * @param propertyPaths
538
     *            properties to initialize - see
539
     *            {@link IBeanInitializer#initialize(Object, List)}
540
     * @return a paged list of instances of type T matching the queryString and
541
     *         the additional filter criteria
542
     * @throws CorruptIndexException
543
     * @throws IOException
544
     * @throws ParseException
545
     */
546
    public Pager<SearchResult<TaxonBase>> findByFullText(Class<? extends TaxonBase> clazz, String queryString, Classification classification,
547
            List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
548
            List<String> propertyPaths) throws CorruptIndexException, IOException, ParseException;
549

    
550

    
551
    /**
552
     * @param areaFilter
553
     * @param statusFilter
554
     * @param classification
555
     *            Additional filter criterion: If a taxonomic classification
556
     *            three is specified here the result set will only contain taxa
557
     *            of the given classification
558
     * @param highlightFragments
559
     * @param pageSize
560
     *            The maximum number of objects returned (can be null for all
561
     *            objects)
562
     * @param pageNumber
563
     *            The offset (in pageSize chunks) from the start of the result
564
     *            set (0 - based)
565
     * @param orderHints
566
     *            Supports path like <code>orderHints.propertyNames</code> which
567
     *            include *-to-one properties like createdBy.username or
568
     *            authorTeam.persistentTitleCache
569
     * @param propertyPath
570
     *            Common properties to initialize the instances of the
571
     *            CDM types ({@link Taxon} and {@link Synonym}
572
     *            this method can return - see {@link IBeanInitializer#initialize(Object, List)}
573
     * @return a paged list of instances of {@link Taxon} instances
574
     * @throws IOException
575
     * @throws ParseException
576
     */
577
    public Pager<SearchResult<TaxonBase>> findByDistribution(List<NamedArea> areaFilter, List<PresenceAbsenceTerm> statusFilter,
578
            Classification classification,
579
            Integer pageSize, Integer pageNumber,
580
            List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, ParseException;
581

    
582
    /**
583
     * Searches for TaxonBase instances using the TaxonBase free text index.
584
     *
585
     *
586
     *
587
     * <h4>This is an experimental feature, it may be moved, modified, or even
588
     * removed in future releases!!!</h4>
589
     * @param searchModes
590
     *            Additional filter criterion: defaults to [doTaxa] if set null
591
     * @param queryString
592
     *            the query string
593
     * @param classification
594
     *            Additional filter criterion: If a taxonomic classification
595
     *            three is specified here the result set will only contain taxa
596
     *            of the given classification
597
     * @param namedAreas
598
     * @param languages
599
     *            Additional filter criterion: Search only in these languages.
600
     *            Not all text fields in the cdm model are multilingual, thus
601
     *            this setting will only apply to the multilingiual fields.
602
     *            Other fields are searched nevertheless if this parameter is
603
     *            set or not.
604
     * @param highlightFragments
605
     *            TODO
606
     * @param pageSize
607
     *            The maximum number of objects returned (can be null for all
608
     *            objects)
609
     * @param pageNumber
610
     *            The offset (in pageSize chunks) from the start of the result
611
     *            set (0 - based)
612
     * @param orderHints
613
     *            Supports path like <code>orderHints.propertyNames</code> which
614
     *            include *-to-one properties like createdBy.username or
615
     *            authorTeam.persistentTitleCache
616
     * @param propertyPath
617
     *            Common properties to initialize the instances of the
618
     *            CDM types ({@link Taxon} and {@link Synonym}
619
     *            this method can return - see {@link IBeanInitializer#initialize(Object, List)}
620
     * @return a paged list of instances of {@link Taxon}, {@link Synonym}, matching the queryString and
621
     *         the additional filter criteria
622
     * @throws CorruptIndexException
623
     * @throws IOException
624
     * @throws ParseException
625
     * @throws LuceneMultiSearchException
626
     */
627
    public Pager<SearchResult<TaxonBase>> findTaxaAndNamesByFullText(
628
            EnumSet<TaxaAndNamesSearchMode> searchModes,
629
            String queryString, Classification classification, Set<NamedArea> namedAreas, Set<PresenceAbsenceTerm> distributionStatus,
630
            List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
631
            List<String> propertyPaths) throws CorruptIndexException, IOException, ParseException, LuceneMultiSearchException;
632

    
633
    /**
634
     * Searches for TaxonBase instances by using the DescriptionElement free text index.
635
     *
636
     * <h4>This is an experimental feature, it may be moved, modified, or even
637
     * removed in future releases!!!</h4>
638
     *
639
     * @param clazz
640
     *            Additional filter criterion:
641
     * @param queryString
642
     *            the query string to filter by
643
     * @param classification
644
     *            Additional filter criterion: If a taxonomic classification
645
     *            three is specified here the result set will only contain taxa
646
     *            of the given classification
647
     * @param features
648
     *            TODO
649
     * @param languages
650
     *            Additional filter criterion: Search only in these languages.
651
     *            Not all text fields in the cdm model are multilingual, thus
652
     *            this setting will only apply to the multilingiual fields.
653
     *            Other fields are searched nevertheless if this parameter is
654
     *            set or not.
655
     * @param highlightFragments
656
     *            TODO
657
     * @param pageSize
658
     *            The maximum number of objects returned (can be null for all
659
     *            objects)
660
     * @param pageNumber
661
     *            The offset (in pageSize chunks) from the start of the result
662
     *            set (0 - based)
663
     * @param orderHints
664
     *            Supports path like <code>orderHints.propertyNames</code> which
665
     *            include *-to-one properties like createdBy.username or
666
     *            authorTeam.persistentTitleCache
667
     * @param propertyPaths
668
     *            properties to initialize - see
669
     *            {@link IBeanInitializer#initialize(Object, List)}
670
     * @return a paged list of instances of type T matching the queryString and
671
     *         the additional filter criteria
672
     * @throws IOException
673
     * @throws CorruptIndexException
674
     * @throws ParseException
675
     */
676
    public Pager<SearchResult<TaxonBase>> findByDescriptionElementFullText(Class<? extends DescriptionElementBase> clazz, String queryString, Classification classification, List<Feature> features, List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws CorruptIndexException, IOException, ParseException;
677

    
678

    
679
    /**
680
     *
681
     * @param taxon
682
     * @param size
683
     * @param height
684
     * @param widthOrDuration
685
     * @param mimeTypes
686
     * @return
687
     *
688
     * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
689
     */
690
    @Deprecated
691
    public List<MediaRepresentation> getAllMedia(Taxon taxon, int size, int height, int widthOrDuration, String[] mimeTypes);
692

    
693

    
694
    /**
695
     * Lists all Media found in an any TaxonDescription associated with this
696
     * taxon.
697
     *
698
     * @param taxon
699
     * @param includeRelationships
700
     *            the given list of TaxonRelationshipEdges will be taken into
701
     *            account when retrieving media associated with the given taxon.
702
     *            Can be NULL.
703
     * @param limitToGalleries
704
     *            whether to take only TaxonDescription into account which are
705
     *            marked as gallery
706
     * @return
707
     * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
708
     */
709
    @Deprecated
710
    public List<Media> listTaxonDescriptionMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, boolean limitToGalleries, List<String> propertyPath);
711

    
712
    /**
713
     * Lists all Media found in an any TaxonDescription, NameDescription,
714
     * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
715
     *
716
     * @param taxon
717
     * @param includeRelationships
718
     *            the given list of TaxonRelationshipEdges will be taken into
719
     *            account when retrieving media associated with the given taxon.
720
     *            Can be NULL.
721
     * @param limitToGalleries
722
     *            whether to take only descriptions into account which are
723
     *            marked as gallery, can be NULL
724
     * @param includeTaxonDescriptions
725
     *            whether to take TaxonDescriptions into account, can be NULL
726
     * @param includeOccurrences
727
     *          whether to take TaxonDescriptions into account, can be NULL
728
     * @param includeTaxonNameDescriptions
729
     *       whether to take TaxonNameDescriptions into account, can be NULL
730
     * @param propertyPath
731
     * @return
732
     */
733
    public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
734
            Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences,
735
            Boolean includeTaxonNameDescriptions, List<String> propertyPath);
736

    
737
    public List<TaxonBase> findTaxaByID(Set<Integer> listOfIDs);
738

    
739
    /**
740
     * Returns the TaxonBase with the given UUID
741
     * using the given match mode and initialization strategy
742
     *
743
     * @param uuid
744
     * @param propertyPaths
745
     * @return
746
     */
747
    public TaxonBase findTaxonByUuid(UUID uuid, List<String> propertyPaths);
748

    
749
    public int countAllRelationships();
750

    
751
    public List<TaxonNameBase> findIdenticalTaxonNames(List<String> propertyPath);
752

    
753
    public List<TaxonNameBase> findIdenticalTaxonNameIds(List<String> propertyPath);
754

    
755
    public String getPhylumName(TaxonNameBase name);
756

    
757
    public long deleteSynonymRelationships(Synonym syn);
758

    
759
    /**
760
     * Returns all {@link Taxon taxa} which are {@link TaxonRelationshipType#CONGRUENT_TO() congruent} or
761
     * {@link TaxonRelationshipType#INCLUDES() included} in the taxon represented by the given taxon uuid.
762
     * The result also returns the path to these taxa represented by the uuids of
763
     * the {@link TaxonRelationshipType taxon relationships types} and doubtful information.
764
     * If classificationUuids is set only taxa of classifications are returned which are included
765
     * in the given {@link Classification classifications}. ALso the path to these taxa may not include
766
     * taxa from other classifications.
767
     * @param taxonUuid uuid of the original taxon
768
     * @param classificationUuids List of uuids of classifications used as a filter
769
     * @param includeDoubtful set to <code>true</code> if also doubtfully included taxa should be included in the result
770
     * @return a DTO which includes a list of taxa with the pathes from the original taxon to the given taxon as well
771
     * as doubtful and date information. The original taxon is included in the result.
772
     */
773
    public IncludedTaxaDTO listIncludedTaxa(UUID taxonUuid, IncludedTaxonConfiguration configuration);
774

    
775

    
776
   /**
777
     * Removes a synonym.<BR><BR>
778
     *
779
     * In detail it removes
780
     *  <li>all synonym relationship to the given taxon or to all taxa if taxon is <code>null</code></li>
781
     *  <li>the synonym concept if it is not referenced by any synonym relationship anymore</li>
782
     *  <BR><BR>
783
     *  If <code>removeNameIfPossible</code> is true
784
     *  it also removes the synonym name if it is not used in any other context
785
     *  (part of a concept, in DescriptionElementSource, part of a name relationship, used inline, ...)<BR><BR>
786
     *  If <code>newHomotypicGroupIfNeeded</code> is <code>true</code> and the synonym name is not deleted and
787
     *  the name is homotypic to the taxon the name is moved to a new homotypical group.<BR><BR>
788
     *
789
     *  If synonym is <code>null</code> the method has no effect.
790
     *
791
     * @param taxon
792
     * @param synonym
793
     * @param removeNameIfPossible
794
     * @return deleteResult
795
     *
796
     */
797
    public DeleteResult deleteSynonym(Synonym synonym, SynonymDeletionConfigurator config);
798

    
799
    /**
800
     * Removes a synonym.
801
     *
802
     * The method essentially loads the synonym and calls the
803
     * {@link #deleteSynonym(Synonym, SynonymDeletionConfigurator) deleteSynonym} method
804
     *
805
     * @param synonymUuid
806
     * @param config
807
     * @return
808
     */
809
    public DeleteResult deleteSynonym(UUID synonymUuid, SynonymDeletionConfigurator config);
810

    
811
    /**
812
     * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
813
     * depending on direction, where the supplied taxon is relatedTo or the supplied synonym is relatedFrom.
814
     *
815
     * @param taxonBase The taxon or synonym that is relatedTo or relatedFrom
816
     * @param type The type of SynonymRelationship (can be null)
817
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
818
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
819
     * @param orderHints Properties to order by
820
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
821
     * @param direction The direction of the relationship
822
     * @return a List of SynonymRelationship instances
823
     */
824
    public List<SynonymRelationship> listSynonymRelationships(
825
            TaxonBase taxonBase, SynonymRelationshipType type, Integer pageSize, Integer pageNumber,
826
            List<OrderHint> orderHints, List<String> propertyPaths, Direction direction);
827

    
828
    /**
829
     * @param tnb
830
     * @return
831
     */
832
    public Taxon findBestMatchingTaxon(String taxonName);
833

    
834
    public Taxon findBestMatchingTaxon(MatchingTaxonConfigurator config);
835

    
836
    public Synonym findBestMatchingSynonym(String taxonName);
837

    
838
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheTaxon(Integer limit, String pattern);
839

    
840
    public List<UuidAndTitleCache<TaxonBase>> getUuidAndTitleCacheSynonym(Integer limit, String pattern);
841

    
842
    public List<UuidAndTitleCache<IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
843

    
844
    /**
845
     * Creates the specified inferred synonyms for the taxon in the classification, but do not insert it to the database
846
     * @param taxon
847
     * @param tree
848
     * @return list of inferred synonyms
849
     */
850
    public List<Synonym> createInferredSynonyms(Taxon taxon, Classification tree, SynonymRelationshipType type, boolean doWithMisappliedNames);
851

    
852
    /**
853
     * Creates all inferred synonyms for the taxon in the classification, but do not insert it to the database
854
     * @param taxon
855
     * @param tree
856
     * @param iDatabase
857
     * @return list of inferred synonyms
858
     */
859
    public List<Synonym>  createAllInferredSynonyms(Taxon taxon, Classification tree, boolean doWithMisappliedNames);
860

    
861

    
862

    
863

    
864
    /**
865
     * Removes a synonym.<BR><BR>
866
     *
867
     * In detail it removes
868
     *  <li>all synonym relationship to the given taxon or to all taxa if taxon is <code>null</code></li>
869
     *  <li>the synonym concept if it is not referenced by any synonym relationship anymore</li>
870
     *  <BR><BR>
871
     *  If <code>config.removeNameIfPossible</code> is true
872
     *  it also removes the synonym name if it is not used in any other context
873
     *  (part of a concept, in DescriptionElementSource, part of a name relationship, used inline, ...)<BR><BR>
874
     *  If <code>config.newHomotypicGroupIfNeeded</code> is <code>true</code> and the synonym name is not deleted and
875
     *  the name is homotypic to the taxon the name is moved to a new homotypical group.<BR><BR>
876
     *
877
     *  If synonym is <code>null</code> the method has no effect.
878
     *
879
     * @param taxon
880
     * @param synonym
881
     * @param config
882
     * @return deleteResult
883
     */
884
    public DeleteResult deleteSynonym(Synonym synonym, Taxon taxon, SynonymDeletionConfigurator config);
885

    
886

    
887

    
888
    public Pager<Taxon> pageAcceptedTaxaFor(UUID synonymUuid, UUID classificationUuid, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
889
            List<String> propertyPaths);
890

    
891
    public List<Taxon> listAcceptedTaxaFor(UUID synonymUuid, UUID classificationUuid, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
892
            List<String> propertyPaths);
893

    
894
    public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
895

    
896

    
897
    public <S extends TaxonBase> Pager<FindByIdentifierDTO<S>> findByIdentifier(
898
			Class<S> clazz, String identifier, DefinedTerm identifierType, TaxonNode subtreeFilter,
899
			MatchMode matchmode, boolean includeEntity, Integer pageSize,
900
			Integer pageNumber,	List<String> propertyPaths);
901

    
902

    
903
    /**
904
     * @param synonymUuid
905
     * @param taxonUuid
906
     * @param config
907
     * @return
908
     */
909
    public DeleteResult deleteSynonym(UUID synonymUuid, UUID taxonUuid, SynonymDeletionConfigurator config);
910

    
911
    /**
912
     * @param synonymUUid
913
     * @param acceptedTaxonUuid
914
     * @return
915
     */
916
    public UpdateResult swapSynonymAndAcceptedTaxon(UUID synonymUUid, UUID acceptedTaxonUuid);
917

    
918
    /**
919
     * @param taxonUuid
920
     * @param config
921
     * @param classificationUuid
922
     * @return
923
     */
924
    public DeleteResult deleteTaxon(UUID taxonUuid, TaxonDeletionConfigurator config, UUID classificationUuid);
925

    
926
	public UpdateResult moveSynonymToAnotherTaxon(SynonymRelationship oldSynonymRelation,
927
			UUID newTaxonUUID, boolean moveHomotypicGroup,
928
			SynonymRelationshipType newSynonymRelationshipType,
929
			Reference reference, String referenceDetail, boolean keepReference)
930
			throws HomotypicalGroupChangeException;
931

    
932
	public UpdateResult moveFactualDateToAnotherTaxon(UUID fromTaxonUuid,
933
			UUID toTaxonUuid);
934

    
935

    
936
    /**
937
     * @param synonymUuid
938
     * @param toTaxonUuid
939
     * @param taxonRelationshipType
940
     * @param citation
941
     * @param microcitation
942
     * @return
943
     */
944
    public UpdateResult changeSynonymToRelatedTaxon(UUID synonymUuid, UUID toTaxonUuid, TaxonRelationshipType taxonRelationshipType,
945
            Reference citation, String microcitation);
946

    
947
    /**
948
     * @param fromTaxonUuid
949
     * @param toTaxonUuid
950
     * @param oldRelationshipType
951
     * @param synonymRelationshipType
952
     * @return
953
     * @throws DataChangeNoRollbackException
954
     */
955
    public UpdateResult changeRelatedTaxonToSynonym(UUID fromTaxonUuid, UUID toTaxonUuid,
956
            TaxonRelationshipType oldRelationshipType, SynonymRelationshipType synonymRelationshipType) throws DataChangeNoRollbackException;
957

    
958
    /**
959
     * @param synonymUuid
960
     * @param acceptedTaxonUuid
961
     * @param newParentNodeUuid
962
     * @param deleteSynonym
963
     * @param copyCitationInfo
964
     * @param citation
965
     * @param microCitation
966
     * @return
967
     * @throws HomotypicalGroupChangeException
968
     */
969
    public UpdateResult changeSynonymToAcceptedTaxon(UUID synonymUuid, UUID acceptedTaxonUuid, UUID newParentNodeUuid,
970
            boolean deleteSynonym, boolean copyCitationInfo, Reference citation, String microCitation)
971
            throws HomotypicalGroupChangeException;
972

    
973

    
974

    
975

    
976

    
977

    
978

    
979
}
(60-60/98)