Project

General

Profile

Download (47.4 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.Map;
16
import java.util.Set;
17
import java.util.UUID;
18

    
19
import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
20
import eu.etaxonomy.cdm.api.service.config.IncludedTaxonConfiguration;
21
import eu.etaxonomy.cdm.api.service.config.MatchingTaxonConfigurator;
22
import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator;
23
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
24
import eu.etaxonomy.cdm.api.service.dto.IdentifiedEntityDTO;
25
import eu.etaxonomy.cdm.api.service.dto.IncludedTaxaDTO;
26
import eu.etaxonomy.cdm.api.service.dto.MarkedEntityDTO;
27
import eu.etaxonomy.cdm.api.service.dto.TaxonRelationshipsDTO;
28
import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
29
import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;
30
import eu.etaxonomy.cdm.api.service.pager.Pager;
31
import eu.etaxonomy.cdm.api.service.search.LuceneMultiSearchException;
32
import eu.etaxonomy.cdm.api.service.search.LuceneParseException;
33
import eu.etaxonomy.cdm.api.service.search.SearchResult;
34
import eu.etaxonomy.cdm.api.util.TaxonRelationshipEdge;
35
import eu.etaxonomy.cdm.exception.UnpublishedException;
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.metadata.SecReferenceHandlingEnum;
46
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingSwapEnum;
47
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
48
import eu.etaxonomy.cdm.model.name.Rank;
49
import eu.etaxonomy.cdm.model.name.TaxonName;
50
import eu.etaxonomy.cdm.model.reference.Reference;
51
import eu.etaxonomy.cdm.model.taxon.Classification;
52
import eu.etaxonomy.cdm.model.taxon.Synonym;
53
import eu.etaxonomy.cdm.model.taxon.SynonymType;
54
import eu.etaxonomy.cdm.model.taxon.Taxon;
55
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
56
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
57
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
58
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
59
import eu.etaxonomy.cdm.model.term.DefinedTerm;
60
import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
61
import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
62
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
63
import eu.etaxonomy.cdm.persistence.query.MatchMode;
64
import eu.etaxonomy.cdm.persistence.query.OrderHint;
65
import eu.etaxonomy.cdm.persistence.query.TaxonTitleType;
66

    
67

    
68
public interface ITaxonService
69
             extends IIdentifiableEntityService<TaxonBase>, IPublishableService<TaxonBase>{
70

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

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

    
87
    /**
88
     * Swaps given synonym and accepted taxon.
89
     * In particular:
90
     * <ul>
91
     * 		<li>A new accepted taxon with the synonyms name is created</li>
92
     * 		<li>The synonym is deleted from the old accepted taxons synonym list</li>
93
     * 		<li>A new synonym with the name of the old accepted taxon is created</li>
94
     * 		<li>The newly created synonym get related to the newly created accepted taxon</li>
95
     * </ul>
96
     *
97
     * @param synonym
98
     * @param acceptedTaxon
99
     * @param setNameInSource
100
     * @return
101
     */
102
    public UpdateResult swapSynonymAndAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon, boolean setNameInSource, boolean newUuidForAcceptedTaxon, SecReferenceHandlingSwapEnum secHandling, Reference secRefAcc, Reference secRefSyn);
103

    
104
    public UpdateResult swapSynonymAndAcceptedTaxon(UUID synonymUUid, UUID acceptedTaxonUuid, boolean setNameInSource, boolean newUuidForAcceptedTaxon, SecReferenceHandlingSwapEnum secHandling, UUID newSecAcc, UUID newSecSyn);
105

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

    
139
    /**
140
     * @param synonymUuid
141
     * @param acceptedTaxonUuid
142
     * @param newParentNodeUuid
143
     * @param deleteSynonym
144
     * @return
145
     * @throws HomotypicalGroupChangeException
146
     */
147
    public UpdateResult changeSynonymToAcceptedTaxon(UUID synonymUuid, UUID acceptedTaxonUuid, UUID newParentNodeUuid, UUID newSecRef, String microRef, SecReferenceHandlingEnum secHandling,
148
            boolean deleteSynonym)
149
            throws HomotypicalGroupChangeException;
150

    
151
    /**
152
     * Change a synonym into a related concept
153
     *
154
     * @param synonym
155
     * 				the synonym to change into the concept taxon
156
     * @param toTaxon
157
     * 				the taxon the newly created concept should be related to
158
     * @param taxonRelationshipType
159
     * 				the type of relationship
160
     * @param reference
161
     * @param microReference
162
     * @return
163
     * 				update result with the newly created concept
164
     */
165
    public UpdateResult changeSynonymToRelatedTaxon(Synonym synonym, Taxon toTaxon, TaxonRelationshipType taxonRelationshipType, Reference reference, String microReference);
166

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

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

    
208
    /**
209
     * See {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
210
     * @param oldSynonym
211
     * @param newTaxon
212
     * @param moveHomotypicGroup
213
     * @param newSynonymType
214
     * @return
215
     * @throws HomotypicalGroupChangeException
216
     */
217
    public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym, Taxon newTaxon, boolean moveHomotypicGroup,
218
            SynonymType newSynonymType) throws HomotypicalGroupChangeException;
219

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

    
247
    /**
248
     * @see {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
249
     */
250
    public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym,
251
            UUID newTaxonUUID, boolean moveHomotypicGroup,
252
            SynonymType newSynonymType,
253
            UUID newSecundumUuid, String newSecundumDetail, boolean keepSecundumIfUndefined)
254
            throws HomotypicalGroupChangeException;
255

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

    
272

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

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

    
305

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

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

    
339

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

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

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

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

    
390
     * @param taxon the accepted taxon
391
     * @param propertyPaths the property path
392
     * @return the list of groups of synonyms
393
     */
394
    public List<List<Synonym>> getSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
395

    
396

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

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

    
425
     * @param taxon
426
     * @param propertyPaths
427
     * @return
428
     */
429
    public List<List<Synonym>> getHeterotypicSynonymyGroups(Taxon taxon, List<String> propertyPaths);
430

    
431
    /**
432
     * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
433
     *
434
     * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
435
     * @param queryString
436
     * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
437
     * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
438
     * @param orderHints
439
     *            Supports path like <code>orderHints.propertyNames</code> which
440
     *            include *-to-one properties like createdBy.username or
441
     *            authorTeam.persistentTitleCache
442
     * @param propertyPaths properties to be initialized
443
     * @return a Pager Taxon instances
444
     * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
445
     */
446
    @Override
447
    public Pager<TaxonBase> search(Class<? extends TaxonBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
448

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

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

    
486
    /**
487
     * Returns a list of IdentifiableEntity instances (in particular, TaxonName and TaxonBase instances)
488
     * that match the properties specified in the configurator.
489
     *
490
     * Note: The search result includes a search on titleCache (with {@link MatchMode#BEGINNING} or {@link MatchMode#ANYWHERE} )
491
     * for all records with protected titleCache (see #9561). Maybe this should be parameterized in future.
492
     */
493
    public Pager<IdentifiableEntity> findTaxaAndNames(IFindTaxaAndNamesConfigurator configurator);
494

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

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

    
593

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

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

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

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

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

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

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

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

    
793
    /**
794
     * Returns a map of taxon names that have identical name caches but derive from different sources.
795
     * The sources are defined via the sources reference uuid.
796
     *
797
     * @return map of nameCaches and taxon name maps where the key is the UUID of the according sourceRefUuid
798
     */
799
    public Map<String, Map<UUID,Set<TaxonName>>> findIdenticalTaxonNames(List<UUID> sourceRefUuids, List<String> propertyPaths);
800

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

    
817

    
818
   /**
819
     * Removes a synonym.<BR><BR>
820
     *
821
     * In detail it removes
822
     *  <li>the synonym concept</li>
823
     *  <BR><BR>
824
     *  If <code>removeNameIfPossible</code> is true
825
     *  it also removes the synonym name if it is not used in any other context
826
     *  (part of a concept, in DescriptionElementSource, part of a name relationship, used inline, ...)<BR><BR>
827
     *  If <code>newHomotypicGroupIfNeeded</code> is <code>true</code> and the synonym name
828
     *  is not deleted and the name is homotypic to the taxon
829
     *  the name is moved to a new homotypic group.<BR><BR>
830
     *
831
     *  If synonym is <code>null</code> the method has no effect.
832
     *
833
     * @param taxon
834
     * @param synonym
835
     * @param removeNameIfPossible
836
     * @return deleteResult
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
    public Taxon findBestMatchingTaxon(String taxonName);
853

    
854
    public Taxon findBestMatchingTaxon(MatchingTaxonConfigurator config);
855

    
856
    public Synonym findBestMatchingSynonym(String taxonName, boolean includeUnpublished);
857

    
858
     public List<UuidAndTitleCache<? extends IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
859

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

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

    
877
    public Taxon findAcceptedTaxonFor(UUID synonymUuid, UUID classificationUuid, boolean includeUnpublished,
878
            List<String> propertyPaths) throws UnpublishedException;
879

    
880
    public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
881

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

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

    
921
    public DeleteResult deleteTaxon(UUID taxonUuid, TaxonDeletionConfigurator config, UUID classificationUuid);
922

    
923
	public UpdateResult moveFactualDateToAnotherTaxon(UUID fromTaxonUuid,
924
			UUID toTaxonUuid);
925

    
926
    public UpdateResult changeSynonymToRelatedTaxon(UUID synonymUuid, UUID toTaxonUuid, TaxonRelationshipType taxonRelationshipType,
927
            Reference citation, String microcitation);
928

    
929
    public UpdateResult changeRelatedTaxonToSynonym(UUID fromTaxonUuid, UUID toTaxonUuid,
930
            TaxonRelationshipType oldRelationshipType, SynonymType synonymType) throws DataChangeNoRollbackException;
931

    
932
    /**
933
     * Returns a list of taxon relationships for a given taxon as DTO.
934
     */
935
    public TaxonRelationshipsDTO listTaxonRelationships(UUID taxonUuid,
936
            Set<TaxonRelationshipType> directTypes,
937
            Set<TaxonRelationshipType> inversTypes, Direction direction, boolean groupMisapplications,
938
            boolean includeUnpublished, Integer pageSize, Integer pageNumber);
939

    
940
    public <S extends TaxonBase> Pager<S> page(Class<S> clazz, List<Restriction<?>> restrictions, Integer pageSize, Integer pageIndex,
941
            List<OrderHint> orderHints, List<String> propertyPaths, boolean includeUnpublished);
942

    
943
}
(58-58/97)