Project

General

Profile

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

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

    
61

    
62
public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
63

    
64
    /**
65
     * Returns a list of taxa that matches the name string and the sec reference
66
     * @param name the name string to search for
67
     * @param sec the taxons sec reference
68
     * @return a list of taxa matching the name and the sec reference
69
     */
70
    public List<TaxonBase> searchTaxaByName(String name, Reference sec);
71

    
72
    /**
73
     * Swaps given synonym and accepted taxon.
74
     * In particular:
75
     * <ul>
76
     * 		<li>A new accepted taxon with the synonyms name is created</li>
77
     * 		<li>The synonym is deleted from the old accepted taxons synonym list</li>
78
     * 		<li>A new synonym with the name of the old accepted taxon is created</li>
79
     * 		<li>The newly created synonym get related to the newly created accepted taxon</li>
80
     * </ul>
81
     *
82
     * @param synonym
83
     * @param acceptedTaxon
84
     * @return
85
     */
86
    public UpdateResult swapSynonymAndAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon);
87

    
88
    /**
89
     * Changes a synonym into an accepted taxon and removes
90
     * the synonym relationship to the given accepted taxon.
91
     * Other synonyms homotypic to the synonym to change are
92
     * moved to the same new accepted taxon as homotypic
93
     * synonyms. The new accepted taxon has the same name and
94
     * the same sec reference as the old synonym.<BR>
95
     * If the given accepted taxon and the synonym are homotypic
96
     * to each other an exception may be thrown as taxonomically it doesn't
97
     * make sense to have two accepted taxa in the same homotypic group
98
     * but also it is than difficult to decide how to handle other names
99
     * in the homotypic group. It is up to the implementing class to
100
     * handle this situation via an exception or in another way.
101
     *
102
     *
103
     * @param synonym
104
     * 				the synonym to change into an accepted taxon
105
     * @param acceptedTaxon
106
     * 				an accepted taxon, the synonym had a relationship to
107
     * @param deleteSynonym
108
     * 			if true the method tries to delete the old synonym from the database
109
     * @return
110
     * 			the newly created accepted taxon
111
     * @throws IllegalArgumentException
112
     * 			if the given accepted taxon and the synonym are homotypic
113
     * 		    to each other an exception may be thrown as taxonomically it doesn't
114
     * 			make sense to have two accepted taxa in the same homotypic group
115
     *          but also it is than difficult to decide how to handle other names
116
     *          in the homotypic group. It is up to the implementing class to
117
     *          handle this situation via an exception or in another way.
118
     */
119
    public UpdateResult changeSynonymToAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon, boolean deleteSynonym) throws HomotypicalGroupChangeException;
120

    
121
    /**
122
     * @param synonymUuid
123
     * @param acceptedTaxonUuid
124
     * @param newParentNodeUuid
125
     * @param deleteSynonym
126
     * @return
127
     * @throws HomotypicalGroupChangeException
128
     */
129
    public UpdateResult changeSynonymToAcceptedTaxon(UUID synonymUuid, UUID acceptedTaxonUuid, UUID newParentNodeUuid,
130
            boolean deleteSynonym)
131
            throws HomotypicalGroupChangeException;
132

    
133
    /**
134
     * Change a synonym into a related concept
135
     *
136
     * @param synonym
137
     * 				the synonym to change into the concept taxon
138
     * @param toTaxon
139
     * 				the taxon the newly created concept should be related to
140
     * @param taxonRelationshipType
141
     * 				the type of relationship
142
     * @param reference
143
     * @param microReference
144
     * @return
145
     * 				update result with the newly created concept
146
     */
147
    public UpdateResult changeSynonymToRelatedTaxon(Synonym synonym, Taxon toTaxon, TaxonRelationshipType taxonRelationshipType, Reference reference, String microReference);
148

    
149
    /**
150
     *
151
     * Change a related concept into synonym
152
     *
153
     * @param synonym
154
     * 				the concept taxon to change into a synonym
155
     * @param toTaxon
156
     * 				the taxon the newly created synonym should be related to
157
     * @param oldRelationshipType
158
     *              the type of old concept relationship
159
     * @param synonymRelationshipType
160
     * 				the type of new synonym relationship
161
     *
162
     * @return
163
     * 				update result with the newly created synonym
164
     * @throws DataChangeNoRollbackException
165
     */
166
  public 	UpdateResult changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
167
             TaxonRelationshipType oldRelationshipType,
168
            SynonymType synonymType) throws DataChangeNoRollbackException;
169

    
170
    /**
171
     * Changes the homotypic group of a synonym into the new homotypic group.
172
     * All relations to taxa are updated correctly depending on the homotypic
173
     * group of the accepted taxon. <BR>
174
     * All existing basionym relationships to and from this name are removed.<BR>
175
     * If the parameter <code>targetTaxon</code> is defined, the synonym is
176
     * added to this taxon irrespctive of if it has been related to this
177
     * taxon before.<BR>
178
     * If <code>setBasionymRelationIfApplicable</code> is true a basionym relationship
179
     * between the existing basionym(s) of the new homotypic group and the synonyms name
180
     * is added.<BR>
181
     *
182
     * @param synonym
183
     * @param newHomotypicalGroup
184
     * @param taxon
185
     * @param setBasionymRelationIfApplicable
186
     */
187
    public void changeHomotypicalGroupOfSynonym(Synonym synonym, HomotypicalGroup newHomotypicalGroup,
188
            Taxon targetTaxon, boolean setBasionymRelationIfApplicable);
189

    
190
    /**
191
     * See {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
192
     * @param oldSynonym
193
     * @param newTaxon
194
     * @param moveHomotypicGroup
195
     * @param newSynonymType
196
     * @return
197
     * @throws HomotypicalGroupChangeException
198
     */
199
    public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym, Taxon newTaxon, boolean moveHomotypicGroup,
200
            SynonymType newSynonymType) throws HomotypicalGroupChangeException;
201

    
202

    
203
    /**
204
     * Moves a synonym to another taxon and removes the old synonym relationship.
205
     *
206
     * @param oldSynonym the old synonym to move.
207
     * @param newTaxon the taxon the synonym will be moved to
208
     * @param moveHomotypicGroup if the synonym belongs to a homotypic 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 newSynonymType the synonym type of the new synonyms. Default is
213
     * 		{@link SynonymType#HETEROTYPIC_SYNONYM_OF() heterotypic}.
214
     * @param newSecundum The secundum for the new synonyms).
215
     * @param newSecundumDetail The secundum micro reference for the new synonym(s).
216
     * @param keepSecundumIfUndefined if no <code>newSecundum</code> and/or no <code>newSecundumDetail</code>
217
     * 		is defined they are taken from the old synonym(s) if <code>keepSecundumIfUndefined</code> is
218
     * 		<code>true</code>. If <code>false</code> the secundum and the secundum detail will be taken
219
     * 		only from the <code>newSecundum</code> and <code>newSecundumDetail</code> even if they are
220
     *      undefined (<code>null</code>).
221
     * @return The new synonym relationship. If <code>moveHomotypicGroup</code> is <code>true</code> additionally
222
     * 		created new synonym relationships must be retrieved separately from the new taxon.
223
     * @throws HomotypicalGroupChangeException Exception is thrown if (1) synonym is homotypic to the old accepted taxon or
224
     * 		(2) synonym is in homotypic group with other synonyms and <code>moveHomotypicGroup</code> is false
225
     */
226
    public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym, Taxon newTaxon, boolean moveHomotypicGroup,
227
            SynonymType newSynonymType, Reference newSecundum,
228
            String newSecundumDetail, boolean keepSecundumIfUndefined) throws HomotypicalGroupChangeException;
229

    
230

    
231
    /**
232
     * @param oldSynonym
233
     * @param newTaxonUUID
234
     * @param moveHomotypicGroup
235
     * @param newSynonymType
236
     * @param reference
237
     * @param referenceDetail
238
     * @param keepReference
239
     * @return
240
     * @throws HomotypicalGroupChangeException
241
     *
242
     * @see {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
243
     */
244
    public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym,
245
            UUID newTaxonUUID, boolean moveHomotypicGroup,
246
            SynonymType newSynonymType,
247
            Reference newSecundum, String newSecundumDetail, boolean keepSecundumIfUndefined)
248
            throws HomotypicalGroupChangeException;
249

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

    
264

    
265
    /**
266
     * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
267
     * where the supplied taxon is relatedTo.
268
     *
269
     * @param taxon The taxon that is relatedTo
270
     * @param type The type of TaxonRelationship (can be null)
271
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
272
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
273
     * @param orderHints Properties to order by
274
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
275
     * @return a Pager of TaxonRelationship instances
276
     */
277
    public Pager<TaxonRelationship> pageToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
278

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

    
293

    
294
    /**
295
     * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
296
     * where the supplied taxon is relatedFrom.
297
     *
298
     * @param taxon The taxon that is relatedFrom
299
     * @param type The type of TaxonRelationship (can be null)
300
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
301
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
302
     * @param orderHints Properties to order by
303
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
304
     * @return a Pager of TaxonRelationship instances
305
     */
306
    public Pager<TaxonRelationship> pageFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
307

    
308
    /**
309
     * lists all taxa which are related to the <code>taxon</code> given as
310
     * parameter.
311
     *
312
     * @param taxon
313
     * @param includeRelationships
314
     * @param maxDepth
315
     *            <code>1</code> for one level, <code>null</code> for infinite
316
     *            depth, <code>0</code> will completely omit collecting related taxa.
317
     * @param limit
318
     * @param start
319
     * @param propertyPaths
320
     * @return
321
     */
322
    public Set<Taxon> listRelatedTaxa(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, Integer maxDepth,
323
            Integer limit, Integer start, List<String> propertyPaths);
324

    
325

    
326
    /**
327
     * Returns all or a page of all taxon concept relationships in the database.
328
     * The result can be filtered by relationship types.
329
     *
330
     * @param types The taxon relationship type filter, if <code>null</code> no filter is set, if empty the result will also be empty
331
     * @param pageSize the page size
332
     * @param pageStart the number of the start page
333
     * @param orderHints the order hints
334
     * @param propertyPaths the property path to initialize the resulting objects
335
     * @return list of taxon relationships matching the filter criteria
336
     */
337
    public List<TaxonRelationship> listTaxonRelationships(Set<TaxonRelationshipType> types,
338
            Integer pageSize, Integer pageStart, List<OrderHint> orderHints, List<String> propertyPaths);
339

    
340
    /**
341
     * Lists all classifications the given taxon/synonym is used in{@link Synonym}
342
     *
343
     * @param taxonBase
344
     * @param limit
345
     * @param start
346
     * @param propertyPaths
347
     * @return
348
     */
349
    public List<Classification> listClassifications(TaxonBase taxonBase, Integer limit, Integer start, List<String> propertyPaths);
350

    
351
    /**
352
     * Returns the Synonyms (with the given synonym relationship type, if this argument is supplied)
353
     * that do have the supplied taxon as accepted taxon.
354
     *
355
     * @param taxon The accepted taxon
356
     * @param type The type of Synonym (can be null)
357
     * @param pageSize The maximum number of synonyms returned (can be null for returning synonyms)
358
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
359
     * * @param orderHints Properties to order by
360
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
361
     * @return a Pager of {@link Synonym} instances
362
     */
363
    public Pager<Synonym> getSynonyms(Taxon taxon, SynonymType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
364

    
365
    /**
366
     * This method returns in the first entry the list of synonyms of the
367
     * homotypic group of the accepted taxon. All other entries represent the lists of heterotypic
368
     * synonym groups. For detailed information about these 2 groups see
369
     * {@link #getHomotypicSynonymsByHomotypicGroup(Taxon, List)} and
370
     * {@link #getHeterotypicSynonymyGroups(Taxon, List)}
371
     *
372
     * @see			#getSynonyms()
373
     * @see			SynonymType#HETEROTYPIC_SYNONYM_OF()
374
     * @see			eu.etaxonomy.cdm.model.name.HomotypicalGroup
375

    
376
     * @param taxon the accepted taxon
377
     * @param propertyPaths the property path
378
     * @return the list of groups of synonyms
379
     */
380
    public List<List<Synonym>> getSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
381

    
382

    
383
    /**
384
     * Returns the list of all synonyms that share the same homotypical group with the given taxon.
385
     * Only those homotypic synonyms are returned that do have a synonym relationship with the accepted taxon.
386
     * @param taxon
387
     * @param propertyPaths
388
     * @return
389
     */
390
    public List<Synonym> getHomotypicSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
391

    
392
    /**
393
     * Returns the ordered list of all {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup homotypical groups}
394
     * that contain {@link Synonym synonyms} that are heterotypic to the given taxon.
395
     * {@link eu.etaxonomy.cdm.model.name.TaxonName Taxon names} of heterotypic synonyms
396
     * belong to a homotypical group which cannot be the homotypical group to which the
397
     * taxon name of the given taxon belongs. This method does not return the homotypic group the given
398
     * taxon belongs to.<BR>
399
     * This method does neglect the type of synonym relationship that is defined between the given taxon
400
     * and the synonym. So the synonym relationship may be homotypic however a synonym is returned
401
     * in one of the result lists as long as the synonym does not belong to the same homotypic group as
402
     * the given taxon.<BR>
403
     * The list returned is ordered according to the date of publication of the
404
     * first published name within each homotypical group.
405
     *
406
     * @see			#getHeterotypicSynonymyGroups()
407
     * @see			#getSynonyms()
408
     * @see			SynonymType#HETEROTYPIC_SYNONYM_OF()
409
     * @see			eu.etaxonomy.cdm.model.name.HomotypicalGroup
410

    
411
     * @param taxon
412
     * @param propertyPaths
413
     * @return
414
     */
415
    public List<List<Synonym>> getHeterotypicSynonymyGroups(Taxon taxon, List<String> propertyPaths);
416

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

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

    
452
    /**
453
     * Returns a list of TaxonBase instances where the
454
     * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
455
     * <i>null</i> will search for those taxa with a value of null in that field
456
     *
457
     * @param clazz optionally filter by class
458
     * @param uninomial
459
     * @param infragenericEpithet
460
     * @param specificEpithet
461
     * @param infraspecificEpithet
462
     * @param rank
463
     * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
464
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
465
     * @return a List of TaxonBase instances
466
     */
467
    public List<TaxonBase> listTaxaByName(Class<? extends TaxonBase> clazz, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, String authorship, Rank rank, Integer pageSize, Integer pageNumber);
468

    
469
    /**
470
     * Returns a list of IdentifiableEntity instances (in particular, TaxonName and TaxonBase instances)
471
     * that match the properties specified in the configurator.
472
     * @param configurator
473
     * @return
474
     */
475
    public Pager<IdentifiableEntity> findTaxaAndNames(IFindTaxaAndNamesConfigurator configurator);
476

    
477
    /**
478
     * performes a union searches for TaxonBase instances on all available
479
     * free text indexes. At the time of writing this documentation it combines
480
     * {@link #findByDescriptionElementFullText(Class, String, Classification, List, List, boolean, Integer, Integer, List, List)}
481
     * and {@link #findByFullText(Class, String, Classification, List, boolean, Integer, Integer, List, List)
482
     *
483
     * @param queryString
484
     *            the query string
485
     * @param classification
486
     *            Additional filter criterion: If a taxonomic classification
487
     *            three is specified here the result set will only contain taxa
488
     *            of the given classification
489
     * @param languages
490
     *            Additional filter criterion: Search only in these languages.
491
     *            Not all text fields in the cdm model are multilingual, thus
492
     *            this setting will only apply to the multilingiual fields.
493
     *            Other fields are searched nevertheless if this parameter is
494
     *            set or not.
495
     * @param highlightFragments
496
     *            TODO
497
     * @param pageSize
498
     *            The maximum number of objects returned (can be null for all
499
     *            objects)
500
     * @param pageNumber
501
     *            The offset (in pageSize chunks) from the start of the result
502
     *            set (0 - based)
503
     * @param orderHints
504
     *            Supports path like <code>orderHints.propertyNames</code> which
505
     *            include *-to-one properties like createdBy.username or
506
     *            authorTeam.persistentTitleCache
507
     * @param propertyPaths
508
     *            properties to initialize - see
509
     *            {@link IBeanInitializer#initialize(Object, List)}
510
     * @return a paged list of instances of type T matching the queryString and
511
     *         the additional filter criteria
512
     * @return
513
     * @throws LuceneCorruptIndexException
514
     * @throws IOException
515
     * @throws LuceneParseException
516
     * @throws LuceneMultiSearchException
517
     * @deprecated this search should fully be covered by the new method
518
     *      {@link #findTaxaAndNamesByFullText(EnumSet, String, Classification, Set, List, boolean, Integer, Integer, List, List)}
519
     *      , maybe we should rename this latter method to give it a more meaningful name
520
     */
521
    @Deprecated
522
    public Pager<SearchResult<TaxonBase>> findByEverythingFullText(String queryString,
523
            Classification classification, List<Language> languages, boolean highlightFragments,
524
            Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException, LuceneMultiSearchException;
525

    
526
    /**
527
     * Searches for TaxonBase instances using the TaxonBase free text index.
528
     *
529
     * <h4>This is an experimental feature, it may be moved, modified, or even
530
     * removed in future releases!!!</h4>
531
     *
532
     * @param clazz
533
     *            Additional filter criterion: The specific TaxonBase subclass
534
     *            to search for
535
     * @param queryString
536
     *            the query string
537
     * @param classification
538
     *            Additional filter criterion: If a taxonomic classification
539
     *            three is specified here the result set will only contain taxa
540
     *            of the given classification
541
     * @param languages
542
     *            Additional filter criterion: Search only in these languages.
543
     *            Not all text fields in the cdm model are multilingual, thus
544
     *            this setting will only apply to the multilingiual fields.
545
     *            Other fields are searched nevertheless if this parameter is
546
     *            set or not.
547
     * @param highlightFragments
548
     *            TODO
549
     * @param pageSize
550
     *            The maximum number of objects returned (can be null for all
551
     *            objects)
552
     * @param pageNumber
553
     *            The offset (in pageSize chunks) from the start of the result
554
     *            set (0 - based)
555
     * @param orderHints
556
     *            Supports path like <code>orderHints.propertyNames</code> which
557
     *            include *-to-one properties like createdBy.username or
558
     *            authorTeam.persistentTitleCache
559
     * @param propertyPaths
560
     *            properties to initialize - see
561
     *            {@link IBeanInitializer#initialize(Object, List)}
562
     * @return a paged list of instances of type T matching the queryString and
563
     *         the additional filter criteria
564
     * @throws LuceneCorruptIndexException
565
     * @throws IOException
566
     * @throws LuceneParseException
567
     */
568
    public Pager<SearchResult<TaxonBase>> findByFullText(Class<? extends TaxonBase> clazz, String queryString, Classification classification,
569
            List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
570
            List<String> propertyPaths) throws IOException, LuceneParseException;
571

    
572

    
573
    /**
574
     * @param areaFilter
575
     * @param statusFilter
576
     * @param classification
577
     *            Additional filter criterion: If a taxonomic classification
578
     *            three is specified here the result set will only contain taxa
579
     *            of the given classification
580
     * @param highlightFragments
581
     * @param pageSize
582
     *            The maximum number of objects returned (can be null for all
583
     *            objects)
584
     * @param pageNumber
585
     *            The offset (in pageSize chunks) from the start of the result
586
     *            set (0 - based)
587
     * @param orderHints
588
     *            Supports path like <code>orderHints.propertyNames</code> which
589
     *            include *-to-one properties like createdBy.username or
590
     *            authorTeam.persistentTitleCache
591
     * @param propertyPath
592
     *            Common properties to initialize the instances of the
593
     *            CDM types ({@link Taxon} and {@link Synonym}
594
     *            this method can return - see {@link IBeanInitializer#initialize(Object, List)}
595
     * @return a paged list of instances of {@link Taxon} instances
596
     * @throws IOException
597
     * @throws LuceneParseException
598
     */
599
    public Pager<SearchResult<TaxonBase>> findByDistribution(List<NamedArea> areaFilter, List<PresenceAbsenceTerm> statusFilter,
600
            Classification classification,
601
            Integer pageSize, Integer pageNumber,
602
            List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException;
603

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

    
655
    /**
656
     * Searches for TaxonBase instances by using the DescriptionElement free text index.
657
     *
658
     * <h4>This is an experimental feature, it may be moved, modified, or even
659
     * removed in future releases!!!</h4>
660
     *
661
     * @param clazz
662
     *            Additional filter criterion:
663
     * @param queryString
664
     *            the query string to filter by
665
     * @param classification
666
     *            Additional filter criterion: If a taxonomic classification
667
     *            three is specified here the result set will only contain taxa
668
     *            of the given classification
669
     * @param features
670
     *            TODO
671
     * @param languages
672
     *            Additional filter criterion: Search only in these languages.
673
     *            Not all text fields in the cdm model are multilingual, thus
674
     *            this setting will only apply to the multilingiual fields.
675
     *            Other fields are searched nevertheless if this parameter is
676
     *            set or not.
677
     * @param highlightFragments
678
     *            TODO
679
     * @param pageSize
680
     *            The maximum number of objects returned (can be null for all
681
     *            objects)
682
     * @param pageNumber
683
     *            The offset (in pageSize chunks) from the start of the result
684
     *            set (0 - based)
685
     * @param orderHints
686
     *            Supports path like <code>orderHints.propertyNames</code> which
687
     *            include *-to-one properties like createdBy.username or
688
     *            authorTeam.persistentTitleCache
689
     * @param propertyPaths
690
     *            properties to initialize - see
691
     *            {@link IBeanInitializer#initialize(Object, List)}
692
     * @return a paged list of instances of type T matching the queryString and
693
     *         the additional filter criteria
694
     * @throws IOException
695
     * @throws LuceneCorruptIndexException
696
     * @throws LuceneParseException
697
     */
698
    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 IOException, LuceneParseException;
699

    
700

    
701
    /**
702
     *
703
     * @param taxon
704
     * @param size
705
     * @param height
706
     * @param widthOrDuration
707
     * @param mimeTypes
708
     * @return
709
     *
710
     * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
711
     */
712
    @Deprecated
713
    public List<MediaRepresentation> getAllMedia(Taxon taxon, int size, int height, int widthOrDuration, String[] mimeTypes);
714

    
715

    
716
    /**
717
     * Lists all Media found in an any TaxonDescription associated with this
718
     * taxon.
719
     *
720
     * @param taxon
721
     * @param includeRelationships
722
     *            the given list of TaxonRelationshipEdges will be taken into
723
     *            account when retrieving media associated with the given taxon.
724
     *            Can be NULL.
725
     * @param limitToGalleries
726
     *            whether to take only TaxonDescription into account which are
727
     *            marked as gallery
728
     * @return
729
     * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
730
     */
731
    @Deprecated
732
    public List<Media> listTaxonDescriptionMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, boolean limitToGalleries, List<String> propertyPath);
733

    
734
    /**
735
     * Lists all Media found in an any TaxonDescription, NameDescription,
736
     * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
737
     *
738
     * @param taxon
739
     * @param includeRelationships
740
     *            the given list of TaxonRelationshipEdges will be taken into
741
     *            account when retrieving media associated with the given taxon.
742
     *            Can be NULL.
743
     * @param limitToGalleries
744
     *            whether to take only descriptions into account which are
745
     *            marked as gallery, can be NULL
746
     * @param includeTaxonDescriptions
747
     *            whether to take TaxonDescriptions into account, can be NULL
748
     * @param includeOccurrences
749
     *          whether to take TaxonDescriptions into account, can be NULL
750
     * @param includeTaxonNameDescriptions
751
     *       whether to take TaxonNameDescriptions into account, can be NULL
752
     * @param propertyPath
753
     * @return
754
     */
755
    public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
756
            Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences,
757
            Boolean includeTaxonNameDescriptions, List<String> propertyPath);
758

    
759
    public List<TaxonBase> findTaxaByID(Set<Integer> listOfIDs);
760

    
761
    /**
762
     * Returns the TaxonBase with the given UUID
763
     * using the given match mode and initialization strategy
764
     *
765
     * @param uuid
766
     * @param propertyPaths
767
     * @return
768
     */
769
    public TaxonBase findTaxonByUuid(UUID uuid, List<String> propertyPaths);
770

    
771
    /**
772
     * Counts the number of synonyms
773
     * @param onlyAttachedToTaxon if <code>true</code> only those synonyms being attached to
774
     * an accepted taxon are counted
775
     * @return the number of synonyms
776
     */
777
    public int countSynonyms(boolean onlyAttachedToTaxon);
778

    
779
    public List<TaxonName> findIdenticalTaxonNames(List<String> propertyPath);
780

    
781
    public List<TaxonName> findIdenticalTaxonNameIds(List<String> propertyPath);
782
//
783
//    public String getPhylumName(TaxonName name);
784

    
785
    /**
786
     * Returns all {@link Taxon taxa} which are {@link TaxonRelationshipType#CONGRUENT_TO() congruent} or
787
     * {@link TaxonRelationshipType#INCLUDES() included} in the taxon represented by the given taxon uuid.
788
     * The result also returns the path to these taxa represented by the uuids of
789
     * the {@link TaxonRelationshipType taxon relationships types} and doubtful information.
790
     * If classificationUuids is set only taxa of classifications are returned which are included
791
     * in the given {@link Classification classifications}. ALso the path to these taxa may not include
792
     * taxa from other classifications.
793
     * @param taxonUuid uuid of the original taxon
794
     * @param classificationUuids List of uuids of classifications used as a filter
795
     * @param includeDoubtful set to <code>true</code> if also doubtfully included taxa should be included in the result
796
     * @return a DTO which includes a list of taxa with the pathes from the original taxon to the given taxon as well
797
     * as doubtful and date information. The original taxon is included in the result.
798
     */
799
    public IncludedTaxaDTO listIncludedTaxa(UUID taxonUuid, IncludedTaxonConfiguration configuration);
800

    
801

    
802
   /**
803
     * Removes a synonym.<BR><BR>
804
     *
805
     * In detail it removes
806
     *  <li>the synonym concept</li>
807
     *  <BR><BR>
808
     *  If <code>removeNameIfPossible</code> is true
809
     *  it also removes the synonym name if it is not used in any other context
810
     *  (part of a concept, in DescriptionElementSource, part of a name relationship, used inline, ...)<BR><BR>
811
     *  If <code>newHomotypicGroupIfNeeded</code> is <code>true</code> and the synonym name
812
     *  is not deleted and the name is homotypic to the taxon
813
     *  the name is moved to a new homotypic group.<BR><BR>
814
     *
815
     *  If synonym is <code>null</code> the method has no effect.
816
     *
817
     * @param taxon
818
     * @param synonym
819
     * @param removeNameIfPossible
820
     * @return deleteResult
821
     *
822
     */
823
    public DeleteResult deleteSynonym(Synonym synonym, SynonymDeletionConfigurator config);
824

    
825
    /**
826
     * Removes a synonym.
827
     *
828
     * The method essentially loads the synonym and calls the
829
     * {@link #deleteSynonym(Synonym, SynonymDeletionConfigurator) deleteSynonym} method
830
     *
831
     * @param synonymUuid
832
     * @param config
833
     * @return
834
     */
835
    public DeleteResult deleteSynonym(UUID synonymUuid, SynonymDeletionConfigurator config);
836

    
837
    /**
838
     * @param tnb
839
     * @return
840
     */
841
    public Taxon findBestMatchingTaxon(String taxonName);
842

    
843
    public Taxon findBestMatchingTaxon(MatchingTaxonConfigurator config);
844

    
845
    public Synonym findBestMatchingSynonym(String taxonName);
846

    
847
     public List<UuidAndTitleCache<IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
848

    
849
    /**
850
     * Creates the specified inferred synonyms for the taxon in the classification, but do not insert it to the database
851
     * @param taxon
852
     * @param tree
853
     * @return list of inferred synonyms
854
     */
855
    public List<Synonym> createInferredSynonyms(Taxon taxon, Classification tree, SynonymType type, boolean doWithMisappliedNames);
856

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

    
866
    public Taxon findAcceptedTaxonFor(UUID synonymUuid, UUID classificationUuid, List<String> propertyPaths);
867

    
868
    public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
869

    
870

    
871
    /**
872
     * @param clazz the optional {@link TaxonBase} subclass
873
     * @param identifier the identifier string
874
     * @param identifierType the identifier type
875
     * @param subtreeFilter filter on a classification subtree (TaxonNode)
876
     * @param matchmode the match mode for the identifier string
877
     * @param includeEntity should the taxon as an object be included in the result
878
     * @param pageSize page size
879
     * @param pageNumber page number
880
     * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
881
     * @return the resulting {@link IdentifiedEntityDTO} pager
882
     * @see IIdentifiableEntityService#findByIdentifier(Class, String, DefinedTerm, MatchMode, boolean, Integer, Integer, List)
883
     */
884
    public <S extends TaxonBase> Pager<IdentifiedEntityDTO<S>> findByIdentifier(
885
			Class<S> clazz, String identifier, DefinedTerm identifierType, TaxonNode subtreeFilter,
886
			MatchMode matchmode, boolean includeEntity, Integer pageSize,
887
			Integer pageNumber,	List<String> propertyPaths);
888

    
889
    /**
890
     * Returns a pager for {@link MarkedEntityDTO DTOs} that hold the marker including type, title and uuid
891
     * and the according {@link TaxonBase} information (uuid, title and the taxon object itself (optional)).
892
     *
893
     * @param clazz The optional {@link TaxonBase} subclass
894
     * @param markerType the obligatory marker type, if not given, the results will always be empty
895
     * @param markerValue the optional
896
     * @param subtreeFilter filter on a classification subtree (TaxonNode)
897
     * @param includeEntity should the taxon as an object be included in the result
898
     * @param titleType which label to give the returned entity, taxon.titleCache, name.titleCache or name.nameCache
899
     * @param pageSize page size
900
     * @param pageNumber page number
901
     * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
902
     * @return the resulting {@link MarkedEntityDTO} pager
903
     * @see IIdentifiableEntityService#findByMarker(Class, MarkerType, Boolean, boolean, Integer, Integer, List)
904
     */
905
    public <S extends TaxonBase> Pager<MarkedEntityDTO<S>> findByMarker(
906
            Class<S> clazz, MarkerType markerType, Boolean markerValue,
907
            TaxonNode subtreeFilter, boolean includeEntity, TaxonTitleType titleType,
908
            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
909

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

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

    
925

    
926
	public UpdateResult moveFactualDateToAnotherTaxon(UUID fromTaxonUuid,
927
			UUID toTaxonUuid);
928

    
929

    
930
    /**
931
     * @param synonymUuid
932
     * @param toTaxonUuid
933
     * @param taxonRelationshipType
934
     * @param citation
935
     * @param microcitation
936
     * @return
937
     */
938
    public UpdateResult changeSynonymToRelatedTaxon(UUID synonymUuid, UUID toTaxonUuid, TaxonRelationshipType taxonRelationshipType,
939
            Reference citation, String microcitation);
940

    
941
    /**
942
     * @param fromTaxonUuid
943
     * @param toTaxonUuid
944
     * @param oldRelationshipType
945
     * @param synonymType
946
     * @return
947
     * @throws DataChangeNoRollbackException
948
     */
949
    public UpdateResult changeRelatedTaxonToSynonym(UUID fromTaxonUuid, UUID toTaxonUuid,
950
            TaxonRelationshipType oldRelationshipType, SynonymType synonymType) throws DataChangeNoRollbackException;
951

    
952
    /**
953
     * @param acceptedTaxonUuid
954
     * @param newName
955
     * @param type
956
     * @return
957
     */
958
    UpdateResult createSynonym(UUID acceptedTaxonUuid, Synonym synonym);
959

    
960

    
961

    
962

    
963

    
964
}
(64-64/105)