Project

General

Profile

Download (47.1 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.dto.TaxonRelationshipsDTO;
27
import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
28
import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;
29
import eu.etaxonomy.cdm.api.service.pager.Pager;
30
import eu.etaxonomy.cdm.api.service.search.LuceneMultiSearchException;
31
import eu.etaxonomy.cdm.api.service.search.LuceneParseException;
32
import eu.etaxonomy.cdm.api.service.search.SearchResult;
33
import eu.etaxonomy.cdm.api.service.util.TaxonRelationshipEdge;
34
import eu.etaxonomy.cdm.exception.UnpublishedException;
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.MarkerType;
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.name.HomotypicalGroup;
46
import eu.etaxonomy.cdm.model.name.Rank;
47
import eu.etaxonomy.cdm.model.name.TaxonName;
48
import eu.etaxonomy.cdm.model.reference.Reference;
49
import eu.etaxonomy.cdm.model.taxon.Classification;
50
import eu.etaxonomy.cdm.model.taxon.Synonym;
51
import eu.etaxonomy.cdm.model.taxon.SynonymType;
52
import eu.etaxonomy.cdm.model.taxon.Taxon;
53
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
54
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
55
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
56
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
57
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
58
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
59
import eu.etaxonomy.cdm.persistence.query.MatchMode;
60
import eu.etaxonomy.cdm.persistence.query.OrderHint;
61
import eu.etaxonomy.cdm.persistence.query.TaxonTitleType;
62

    
63

    
64
public interface ITaxonService
65
             extends IIdentifiableEntityService<TaxonBase>, IPublishableService<TaxonBase>{
66

    
67
    /**
68
     * {@inheritDoc}
69
     * <BR><BR>
70
     * NOTE: Also taxa with <code>publish=false</code> are returned.
71
     */
72
    @Override
73
    public TaxonBase load(UUID uuid, List<String> propertyPaths);
74

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

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

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

    
132
    /**
133
     * @param synonymUuid
134
     * @param acceptedTaxonUuid
135
     * @param newParentNodeUuid
136
     * @param deleteSynonym
137
     * @return
138
     * @throws HomotypicalGroupChangeException
139
     */
140
    public UpdateResult changeSynonymToAcceptedTaxon(UUID synonymUuid, UUID acceptedTaxonUuid, UUID newParentNodeUuid,
141
            boolean deleteSynonym)
142
            throws HomotypicalGroupChangeException;
143

    
144
    /**
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
     * 				update result with the newly created concept
157
     */
158
    public UpdateResult changeSynonymToRelatedTaxon(Synonym synonym, Taxon toTaxon, TaxonRelationshipType taxonRelationshipType, Reference reference, String microReference);
159

    
160
    /**
161
     *
162
     * Change a related concept into synonym
163
     *
164
     * @param synonym
165
     * 				the concept taxon to change into a synonym
166
     * @param toTaxon
167
     * 				the taxon the newly created synonym should be related to
168
     * @param oldRelationshipType
169
     *              the type of old concept relationship
170
     * @param synonymRelationshipType
171
     * 				the type of new synonym relationship
172
     *
173
     * @return
174
     * 				update result with the newly created synonym
175
     * @throws DataChangeNoRollbackException
176
     */
177
  public 	UpdateResult changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
178
             TaxonRelationshipType oldRelationshipType,
179
            SynonymType synonymType) throws DataChangeNoRollbackException;
180

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

    
201
    /**
202
     * See {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
203
     * @param oldSynonym
204
     * @param newTaxon
205
     * @param moveHomotypicGroup
206
     * @param newSynonymType
207
     * @return
208
     * @throws HomotypicalGroupChangeException
209
     */
210
    public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym, Taxon newTaxon, boolean moveHomotypicGroup,
211
            SynonymType newSynonymType) throws HomotypicalGroupChangeException;
212

    
213

    
214
    /**
215
     * Moves a synonym to another taxon and removes the old synonym relationship.
216
     *
217
     * @param oldSynonym the old synonym to move.
218
     * @param newTaxon the taxon the synonym will be moved to
219
     * @param moveHomotypicGroup if the synonym belongs to a homotypic group with other synonyms and
220
     * 		<code>moveHomotypicGroup</code> is <code>true</code> all these synonyms are moved to the new taxon,
221
     * 		if <code>false</code> a {@link HomotypicalGroupChangeException} is thrown.
222
     * 		<code>moveHomotypicGroup</code> has no effect if the synonym is the only synonym in it's homotypic group.
223
     * @param newSynonymType the synonym type of the new synonyms. Default is
224
     * 		{@link SynonymType#HETEROTYPIC_SYNONYM_OF() heterotypic}.
225
     * @param newSecundum The secundum for the new synonyms).
226
     * @param newSecundumDetail The secundum micro reference for the new synonym(s).
227
     * @param keepSecundumIfUndefined if no <code>newSecundum</code> and/or no <code>newSecundumDetail</code>
228
     * 		is defined they are taken from the old synonym(s) if <code>keepSecundumIfUndefined</code> is
229
     * 		<code>true</code>. If <code>false</code> the secundum and the secundum detail will be taken
230
     * 		only from the <code>newSecundum</code> and <code>newSecundumDetail</code> even if they are
231
     *      undefined (<code>null</code>).
232
     * @return The new synonym relationship. If <code>moveHomotypicGroup</code> is <code>true</code> additionally
233
     * 		created new synonym relationships must be retrieved separately from the new taxon.
234
     * @throws HomotypicalGroupChangeException Exception is thrown if (1) synonym is homotypic to the old accepted taxon or
235
     * 		(2) synonym is in homotypic group with other synonyms and <code>moveHomotypicGroup</code> is false
236
     */
237
    public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym, Taxon newTaxon, boolean moveHomotypicGroup,
238
            SynonymType newSynonymType, Reference newSecundum,
239
            String newSecundumDetail, boolean keepSecundumIfUndefined) throws HomotypicalGroupChangeException;
240

    
241

    
242
    /**
243
     * @param oldSynonym
244
     * @param newTaxonUUID
245
     * @param moveHomotypicGroup
246
     * @param newSynonymType
247
     * @param reference
248
     * @param referenceDetail
249
     * @param keepReference
250
     * @return
251
     * @throws HomotypicalGroupChangeException
252
     *
253
     * @see {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
254
     */
255
    public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym,
256
            UUID newTaxonUUID, boolean moveHomotypicGroup,
257
            SynonymType newSynonymType,
258
            Reference newSecundum, String newSecundumDetail, boolean keepSecundumIfUndefined)
259
            throws HomotypicalGroupChangeException;
260

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

    
277

    
278
    /**
279
     * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
280
     * where the supplied taxon is relatedTo.
281
     *
282
     * @param taxon The taxon that is relatedTo
283
     * @param type The type of TaxonRelationship (can be null)
284
     * @param includeUnpublished should unpublished related taxa also be returned?
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 Pager of TaxonRelationship instances
290
     */
291
    public Pager<TaxonRelationship> pageToTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
292
            boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
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 includeUnpublished should unpublished related taxa also be returned?
301
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
302
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
303
     * @param orderHints Properties to order by
304
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
305
     * @return a List of TaxonRelationship instances
306
     */
307
    public List<TaxonRelationship> listFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
308
            boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
309

    
310

    
311
    /**
312
     * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
313
     * where the supplied taxon is relatedFrom.
314
     *
315
     * @param taxon The taxon that is relatedFrom
316
     * @param type The type of TaxonRelationship (can be null)
317
     * @param includeUnpublished should unpublished related taxa also be returned?
318
     * @param pageSize The maximum number of relationships returned (can be null for all relationships)
319
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
320
     * @param orderHints Properties to order by
321
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
322
     * @return a Pager of TaxonRelationship instances
323
     */
324
    public Pager<TaxonRelationship> pageFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
325
            boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
326

    
327
    /**
328
     * lists all taxa which are related to the <code>taxon</code> given as
329
     * parameter.
330
     *
331
     * @param taxon
332
     * @param includeRelationships
333
     * @param maxDepth
334
     *            <code>1</code> for one level, <code>null</code> for infinite
335
     *            depth, <code>0</code> will completely omit collecting related taxa.
336
     * @param limit
337
     * @param start
338
     * @param propertyPaths
339
     * @return
340
     */
341
    public Set<Taxon> listRelatedTaxa(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, Integer maxDepth,
342
            boolean includeUnpublished, Integer limit, Integer start, List<String> propertyPaths);
343

    
344

    
345
    /**
346
     * Returns all or a page of all taxon concept relationships in the database.
347
     * The result can be filtered by relationship types.
348
     *
349
     * @param types The taxon relationship type filter, if <code>null</code> no filter is set, if empty the result will also be empty
350
     * @param pageSize the page size
351
     * @param pageStart the number of the start page
352
     * @param orderHints the order hints
353
     * @param propertyPaths the property path to initialize the resulting objects
354
     * @return list of taxon relationships matching the filter criteria
355
     */
356
    public List<TaxonRelationship> listTaxonRelationships(Set<TaxonRelationshipType> types,
357
            Integer pageSize, Integer pageStart, List<OrderHint> orderHints, List<String> propertyPaths);
358

    
359
    /**
360
     * Lists all classifications the given taxon/synonym is used in{@link Synonym}
361
     *
362
     * @param taxonBase
363
     * @param limit
364
     * @param start
365
     * @param propertyPaths
366
     * @return
367
     */
368
    public List<Classification> listClassifications(TaxonBase taxonBase, Integer limit, Integer start, List<String> propertyPaths);
369

    
370
    /**
371
     * Returns the Synonyms (with the given synonym relationship type, if this argument is supplied)
372
     * that do have the supplied taxon as accepted taxon.
373
     *
374
     * @param taxon The accepted taxon
375
     * @param type The type of Synonym (can be null)
376
     * @param pageSize The maximum number of synonyms returned (can be null for returning synonyms)
377
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
378
     * * @param orderHints Properties to order by
379
     * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
380
     * @return a Pager of {@link Synonym} instances
381
     */
382
    public Pager<Synonym> getSynonyms(Taxon taxon, SynonymType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
383

    
384
    /**
385
     * This method returns in the first entry the list of synonyms of the
386
     * homotypic group of the accepted taxon. All other entries represent the lists of heterotypic
387
     * synonym groups. For detailed information about these 2 groups see
388
     * {@link #getHomotypicSynonymsByHomotypicGroup(Taxon, List)} and
389
     * {@link #getHeterotypicSynonymyGroups(Taxon, List)}
390
     *
391
     * @see			#getSynonyms()
392
     * @see			SynonymType#HETEROTYPIC_SYNONYM_OF()
393
     * @see			eu.etaxonomy.cdm.model.name.HomotypicalGroup
394

    
395
     * @param taxon the accepted taxon
396
     * @param propertyPaths the property path
397
     * @return the list of groups of synonyms
398
     */
399
    public List<List<Synonym>> getSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
400

    
401

    
402
    /**
403
     * Returns the list of all synonyms that share the same homotypical group with the given taxon.
404
     * Only those homotypic synonyms are returned that do have a synonym relationship with the accepted taxon.
405
     * @param taxon
406
     * @param propertyPaths
407
     * @return
408
     */
409
    public List<Synonym> getHomotypicSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
410

    
411
    /**
412
     * Returns the ordered list of all {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup homotypical groups}
413
     * that contain {@link Synonym synonyms} that are heterotypic to the given taxon.
414
     * {@link eu.etaxonomy.cdm.model.name.TaxonName Taxon names} of heterotypic synonyms
415
     * belong to a homotypical group which cannot be the homotypical group to which the
416
     * taxon name of the given taxon belongs. This method does not return the homotypic group the given
417
     * taxon belongs to.<BR>
418
     * This method does neglect the type of synonym relationship that is defined between the given taxon
419
     * and the synonym. So the synonym relationship may be homotypic however a synonym is returned
420
     * in one of the result lists as long as the synonym does not belong to the same homotypic group as
421
     * the given taxon.<BR>
422
     * The list returned is ordered according to the date of publication of the
423
     * first published name within each homotypical group.
424
     *
425
     * @see			#getHeterotypicSynonymyGroups()
426
     * @see			#getSynonyms()
427
     * @see			SynonymType#HETEROTYPIC_SYNONYM_OF()
428
     * @see			eu.etaxonomy.cdm.model.name.HomotypicalGroup
429

    
430
     * @param taxon
431
     * @param propertyPaths
432
     * @return
433
     */
434
    public List<List<Synonym>> getHeterotypicSynonymyGroups(Taxon taxon, List<String> propertyPaths);
435

    
436
    /**
437
     * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
438
     *
439
     * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
440
     * @param queryString
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
     * @param orderHints
444
     *            Supports path like <code>orderHints.propertyNames</code> which
445
     *            include *-to-one properties like createdBy.username or
446
     *            authorTeam.persistentTitleCache
447
     * @param propertyPaths properties to be initialized
448
     * @return a Pager Taxon instances
449
     * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
450
     */
451
    @Override
452
    public Pager<TaxonBase> search(Class<? extends TaxonBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
453

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

    
471
    /**
472
     * Returns a list of TaxonBase instances where the
473
     * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
474
     * <i>null</i> will search for those taxa with a value of null in that field
475
     *
476
     * @param clazz optionally filter by class
477
     * @param uninomial
478
     * @param infragenericEpithet
479
     * @param specificEpithet
480
     * @param infraspecificEpithet
481
     * @param rank
482
     * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
483
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
484
     * @return a List of TaxonBase instances
485
     */
486
    public List<TaxonBase> listTaxaByName(Class<? extends TaxonBase> clazz, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, String authorship, Rank rank, Integer pageSize, Integer pageNumber);
487

    
488
    /**
489
     * Returns a list of IdentifiableEntity instances (in particular, TaxonName and TaxonBase instances)
490
     * that match the properties specified in the configurator.
491
     * @param configurator
492
     * @return
493
     */
494
    public Pager<IdentifiableEntity> findTaxaAndNames(IFindTaxaAndNamesConfigurator configurator);
495

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

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

    
594

    
595
    /**
596
     * @param areaFilter
597
     * @param statusFilter
598
     * @param classification
599
     *            Additional filter criterion: If a taxonomic classification
600
     *            three is specified here the result set will only contain taxa
601
     *            of the given classification
602
     * @param highlightFragments
603
     * @param pageSize
604
     *            The maximum number of objects returned (can be null for all
605
     *            objects)
606
     * @param pageNumber
607
     *            The offset (in pageSize chunks) from the start of the result
608
     *            set (0 - based)
609
     * @param orderHints
610
     *            Supports path like <code>orderHints.propertyNames</code> which
611
     *            include *-to-one properties like createdBy.username or
612
     *            authorTeam.persistentTitleCache
613
     * @param propertyPath
614
     *            Common properties to initialize the instances of the
615
     *            CDM types ({@link Taxon} and {@link Synonym}
616
     *            this method can return - see {@link IBeanInitializer#initialize(Object, List)}
617
     * @return a paged list of instances of {@link Taxon} instances
618
     * @throws IOException
619
     * @throws LuceneParseException
620
     */
621
    //TODO needed? currently only used in test
622
    public Pager<SearchResult<TaxonBase>> findByDistribution(List<NamedArea> areaFilter, List<PresenceAbsenceTerm> statusFilter,
623
            Classification classification, TaxonNode subtree,
624
            Integer pageSize, Integer pageNumber,
625
            List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException;
626

    
627
    /**
628
     * Searches for TaxonBase instances using the TaxonBase free text index.
629
     *
630
     *
631
     *
632
     * <h4>This is an experimental feature, it may be moved, modified, or even
633
     * removed in future releases!!!</h4>
634
     * @param searchModes
635
     *            Additional filter criterion: defaults to [doTaxa] if set null
636
     * @param queryString
637
     *            the query string
638
     * @param classification
639
     *            Additional filter criterion: If a taxonomic classification
640
     *            three is specified here the result set will only contain taxa
641
     *            of the given classification
642
     * @param subtree
643
     * @param namedAreas
644
     * @param distributionStatus
645
     * @param languages
646
     *            Additional filter criterion: Search only in these languages.
647
     *            Not all text fields in the cdm model are multilingual, thus
648
     *            this setting will only apply to the multilingiual fields.
649
     *            Other fields are searched nevertheless if this parameter is
650
     *            set or not.
651
     * @param highlightFragments
652
     *            TODO
653
     * @param pageSize
654
     *            The maximum number of objects returned (can be null for all
655
     *            objects)
656
     * @param pageNumber
657
     *            The offset (in pageSize chunks) from the start of the result
658
     *            set (0 - based)
659
     * @param orderHints
660
     *            Supports path like <code>orderHints.propertyNames</code> which
661
     *            include *-to-one properties like createdBy.username or
662
     *            authorTeam.persistentTitleCache
663
     * @param propertyPath
664
     *            Common properties to initialize the instances of the
665
     *            CDM types ({@link Taxon} and {@link Synonym}
666
     *            this method can return - see {@link IBeanInitializer#initialize(Object, List)}
667
     * @return a paged list of instances of {@link Taxon}, {@link Synonym}, matching the queryString and
668
     *         the additional filter criteria
669
     * @throws LuceneCorruptIndexException
670
     * @throws IOException
671
     * @throws LuceneParseException
672
     * @throws LuceneMultiSearchException
673
     */
674
    public Pager<SearchResult<TaxonBase>> findTaxaAndNamesByFullText(
675
            EnumSet<TaxaAndNamesSearchMode> searchModes,
676
            String queryString, Classification classification, TaxonNode subtree,
677
            Set<NamedArea> namedAreas, Set<PresenceAbsenceTerm> distributionStatus,
678
            List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
679
            List<String> propertyPaths) throws IOException, LuceneParseException, LuceneMultiSearchException;
680

    
681
    /**
682
     * Searches for TaxonBase instances by using the DescriptionElement free text index.
683
     *
684
     * <h4>This is an experimental feature, it may be moved, modified, or even
685
     * removed in future releases!!!</h4>
686
     *
687
     * @param clazz
688
     *            Additional filter criterion:
689
     * @param queryString
690
     *            the query string to filter by
691
     * @param classification
692
     *            Additional filter criterion: If a taxonomic classification
693
     *            tree is specified here the result set will only contain taxa
694
     *            of the given classification
695
     * @param subtree
696
     *            Additional filter criterion: If a taxonomic classification
697
     *            subtree is specified here the result set will only contain taxa
698
     *            of the given subtree
699
     * @param features
700
     *            TODO
701
     * @param languages
702
     *            Additional filter criterion: Search only in these languages.
703
     *            Not all text fields in the CDM model are multi-lingual, thus
704
     *            this setting will only apply to the multi-lingual fields.
705
     *            Other fields are searched nevertheless if this parameter is
706
     *            set or not.
707
     * @param highlightFragments
708
     *            TODO
709
     * @param pageSize
710
     *            The maximum number of objects returned (can be null for all
711
     *            objects)
712
     * @param pageNumber
713
     *            The offset (in pageSize chunks) from the start of the result
714
     *            set (0 - based)
715
     * @param orderHints
716
     *            Supports path like <code>orderHints.propertyNames</code> which
717
     *            include *-to-one properties like createdBy.username or
718
     *            authorTeam.persistentTitleCache
719
     * @param propertyPaths
720
     *            properties to initialize - see
721
     *            {@link IBeanInitializer#initialize(Object, List)}
722
     * @return a paged list of instances of type T matching the queryString and
723
     *         the additional filter criteria
724
     * @throws IOException
725
     * @throws LuceneCorruptIndexException
726
     * @throws LuceneParseException
727
     */
728
    public Pager<SearchResult<TaxonBase>> findByDescriptionElementFullText(Class<? extends DescriptionElementBase> clazz,
729
            String queryString, Classification classification, TaxonNode subtree, List<Feature> features, List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException;
730

    
731
    /**
732
     * Lists all Media found in an any TaxonDescription associated with this
733
     * taxon.
734
     *
735
     * @param taxon
736
     * @param includeRelationships
737
     *            the given list of TaxonRelationshipEdges will be taken into
738
     *            account when retrieving media associated with the given taxon.
739
     *            Can be NULL.
740
     * @param limitToGalleries
741
     *            whether to take only TaxonDescription into account which are
742
     *            marked as gallery
743
     * @return
744
     * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
745
     */
746
    @Deprecated
747
    public List<Media> listTaxonDescriptionMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, boolean limitToGalleries, List<String> propertyPath);
748

    
749
    /**
750
     * Lists all Media found in an any TaxonDescription, NameDescription,
751
     * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
752
     *
753
     * @param taxon
754
     * @param includeRelationships
755
     *            the given list of TaxonRelationshipEdges will be taken into
756
     *            account when retrieving media associated with the given taxon.
757
     *            Can be NULL.
758
     * @param limitToGalleries
759
     *            whether to take only descriptions into account which are
760
     *            marked as gallery, can be NULL
761
     * @param includeTaxonDescriptions
762
     *            whether to take TaxonDescriptions into account, can be NULL
763
     * @param includeOccurrences
764
     *          whether to take TaxonDescriptions into account, can be NULL
765
     * @param includeTaxonNameDescriptions
766
     *       whether to take TaxonNameDescriptions into account, can be NULL
767
     * @param propertyPath
768
     * @return
769
     */
770
    public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
771
            Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences,
772
            Boolean includeTaxonNameDescriptions, List<String> propertyPath);
773

    
774
    public List<TaxonBase> findTaxaByID(Set<Integer> listOfIDs);
775

    
776
    /**
777
     * Returns the TaxonBase with the given UUID
778
     * using the given match mode and initialization strategy
779
     *
780
     * @param uuid
781
     * @param propertyPaths
782
     * @return
783
     */
784
    public TaxonBase findTaxonByUuid(UUID uuid, List<String> propertyPaths);
785

    
786
    /**
787
     * Counts the number of synonyms
788
     * @param onlyAttachedToTaxon if <code>true</code> only those synonyms being attached to
789
     * an accepted taxon are counted
790
     * @return the number of synonyms
791
     */
792
    public long countSynonyms(boolean onlyAttachedToTaxon);
793

    
794
    public List<TaxonName> findIdenticalTaxonNames(List<String> propertyPath);
795

    
796
    public List<TaxonName> findIdenticalTaxonNameIds(List<String> propertyPath);
797
//
798
//    public String getPhylumName(TaxonName name);
799

    
800
    /**
801
     * Returns all {@link Taxon taxa} which are {@link TaxonRelationshipType#CONGRUENT_TO() congruent} or
802
     * {@link TaxonRelationshipType#INCLUDES() included} in the taxon represented by the given taxon uuid.
803
     * The result also returns the path to these taxa represented by the uuids of
804
     * the {@link TaxonRelationshipType taxon relationships types} and doubtful information.
805
     * If classificationUuids is set only taxa of classifications are returned which are included
806
     * in the given {@link Classification classifications}. ALso the path to these taxa may not include
807
     * taxa from other classifications.
808
     * @param taxonUuid uuid of the original taxon
809
     * @param classificationUuids List of uuids of classifications used as a filter
810
     * @param includeDoubtful set to <code>true</code> if also doubtfully included taxa should be included in the result
811
     * @return a DTO which includes a list of taxa with the pathes from the original taxon to the given taxon as well
812
     * as doubtful and date information. The original taxon is included in the result.
813
     */
814
    public IncludedTaxaDTO listIncludedTaxa(UUID taxonUuid, IncludedTaxonConfiguration configuration);
815

    
816

    
817
   /**
818
     * Removes a synonym.<BR><BR>
819
     *
820
     * In detail it removes
821
     *  <li>the synonym concept</li>
822
     *  <BR><BR>
823
     *  If <code>removeNameIfPossible</code> is true
824
     *  it also removes the synonym name if it is not used in any other context
825
     *  (part of a concept, in DescriptionElementSource, part of a name relationship, used inline, ...)<BR><BR>
826
     *  If <code>newHomotypicGroupIfNeeded</code> is <code>true</code> and the synonym name
827
     *  is not deleted and the name is homotypic to the taxon
828
     *  the name is moved to a new homotypic group.<BR><BR>
829
     *
830
     *  If synonym is <code>null</code> the method has no effect.
831
     *
832
     * @param taxon
833
     * @param synonym
834
     * @param removeNameIfPossible
835
     * @return deleteResult
836
     *
837
     */
838
    public DeleteResult deleteSynonym(Synonym synonym, SynonymDeletionConfigurator config);
839

    
840
    /**
841
     * Removes a synonym.
842
     *
843
     * The method essentially loads the synonym and calls the
844
     * {@link #deleteSynonym(Synonym, SynonymDeletionConfigurator) deleteSynonym} method
845
     *
846
     * @param synonymUuid
847
     * @param config
848
     * @return
849
     */
850
    public DeleteResult deleteSynonym(UUID synonymUuid, SynonymDeletionConfigurator config);
851

    
852
    /**
853
     * @param tnb
854
     * @return
855
     */
856
    public Taxon findBestMatchingTaxon(String taxonName);
857

    
858
    public Taxon findBestMatchingTaxon(MatchingTaxonConfigurator config);
859

    
860
    public Synonym findBestMatchingSynonym(String taxonName, boolean includeUnpublished);
861

    
862
     public List<UuidAndTitleCache<? extends IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
863

    
864
    /**
865
     * Creates the specified inferred synonyms for the taxon in the classification, but do not insert it to the database
866
     * @param taxon
867
     * @param tree
868
     * @return list of inferred synonyms
869
     */
870
    public List<Synonym> createInferredSynonyms(Taxon taxon, Classification tree, SynonymType type, boolean doWithMisappliedNames);
871

    
872
    /**
873
     * Creates all inferred synonyms for the taxon in the classification, but do not insert it to the database
874
     * @param taxon
875
     * @param tree
876
     * @param iDatabase
877
     * @return list of inferred synonyms
878
     */
879
    public List<Synonym>  createAllInferredSynonyms(Taxon taxon, Classification tree, boolean doWithMisappliedNames);
880

    
881
    public Taxon findAcceptedTaxonFor(UUID synonymUuid, UUID classificationUuid, boolean includeUnpublished,
882
            List<String> propertyPaths) throws UnpublishedException;
883

    
884
    public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
885

    
886

    
887
    /**
888
     * @param clazz the optional {@link TaxonBase} subclass
889
     * @param identifier the identifier string
890
     * @param identifierType the identifier type
891
     * @param subtreeFilter filter on a classification subtree (TaxonNode)
892
     * @param matchmode the match mode for the identifier string
893
     * @param includeEntity should the taxon as an object be included in the result
894
     * @param pageSize page size
895
     * @param pageNumber page number
896
     * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
897
     * @return the resulting {@link IdentifiedEntityDTO} pager
898
     * @see IIdentifiableEntityService#findByIdentifier(Class, String, DefinedTerm, MatchMode, boolean, Integer, Integer, List)
899
     */
900
    public <S extends TaxonBase> Pager<IdentifiedEntityDTO<S>> findByIdentifier(
901
			Class<S> clazz, String identifier, DefinedTerm identifierType, TaxonNode subtreeFilter,
902
			MatchMode matchmode, boolean includeEntity, Integer pageSize,
903
			Integer pageNumber,	List<String> propertyPaths);
904

    
905
    /**
906
     * Returns a pager for {@link MarkedEntityDTO DTOs} that hold the marker including type, title and uuid
907
     * and the according {@link TaxonBase} information (uuid, title and the taxon object itself (optional)).
908
     *
909
     * @param clazz The optional {@link TaxonBase} subclass
910
     * @param markerType the obligatory marker type, if not given, the results will always be empty
911
     * @param markerValue the optional
912
     * @param subtreeFilter filter on a classification subtree (TaxonNode)
913
     * @param includeEntity should the taxon as an object be included in the result
914
     * @param titleType which label to give the returned entity, taxon.titleCache, name.titleCache or name.nameCache
915
     * @param pageSize page size
916
     * @param pageNumber page number
917
     * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
918
     * @return the resulting {@link MarkedEntityDTO} pager
919
     * @see IIdentifiableEntityService#findByMarker(Class, MarkerType, Boolean, boolean, Integer, Integer, List)
920
     */
921
    public <S extends TaxonBase> Pager<MarkedEntityDTO<S>> findByMarker(
922
            Class<S> clazz, MarkerType markerType, Boolean markerValue,
923
            TaxonNode subtreeFilter, boolean includeEntity, TaxonTitleType titleType,
924
            Integer pageSize, Integer pageNumber, List<String> propertyPaths);
925

    
926
    /**
927
     * @param synonymUUid
928
     * @param acceptedTaxonUuid
929
     * @return
930
     */
931
    public UpdateResult swapSynonymAndAcceptedTaxon(UUID synonymUUid, UUID acceptedTaxonUuid);
932

    
933
    /**
934
     * @param taxonUuid
935
     * @param config
936
     * @param classificationUuid
937
     * @return
938
     */
939
    public DeleteResult deleteTaxon(UUID taxonUuid, TaxonDeletionConfigurator config, UUID classificationUuid);
940

    
941

    
942
	public UpdateResult moveFactualDateToAnotherTaxon(UUID fromTaxonUuid,
943
			UUID toTaxonUuid);
944

    
945

    
946
    /**
947
     * @param synonymUuid
948
     * @param toTaxonUuid
949
     * @param taxonRelationshipType
950
     * @param citation
951
     * @param microcitation
952
     * @return
953
     */
954
    public UpdateResult changeSynonymToRelatedTaxon(UUID synonymUuid, UUID toTaxonUuid, TaxonRelationshipType taxonRelationshipType,
955
            Reference citation, String microcitation);
956

    
957
    /**
958
     * @param fromTaxonUuid
959
     * @param toTaxonUuid
960
     * @param oldRelationshipType
961
     * @param synonymType
962
     * @return
963
     * @throws DataChangeNoRollbackException
964
     */
965
    public UpdateResult changeRelatedTaxonToSynonym(UUID fromTaxonUuid, UUID toTaxonUuid,
966
            TaxonRelationshipType oldRelationshipType, SynonymType synonymType) throws DataChangeNoRollbackException;
967

    
968
    /**
969
     * Returns a list of taxon relationships for a given taxon as DTO.
970
     * @param taxonUuid
971
     * @param directTypes
972
     * @param inversTypes
973
     * @param direction
974
     * @param groupMisapplications
975
     * @param includeUnpublished
976
     * @param pageSize
977
     * @param pageNumber
978
     * @return
979
     */
980
    public TaxonRelationshipsDTO listTaxonRelationships(UUID taxonUuid,
981
            Set<TaxonRelationshipType> directTypes,
982
            Set<TaxonRelationshipType> inversTypes, Direction direction, boolean groupMisapplications,
983
            boolean includeUnpublished, Integer pageSize, Integer pageNumber);
984

    
985

    
986

    
987

    
988
}
(65-65/103)