2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.api
.service
;
12 import java
.io
.IOException
;
13 import java
.util
.EnumSet
;
14 import java
.util
.List
;
17 import java
.util
.UUID
;
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
;
68 public interface ITaxonService
69 extends IIdentifiableEntityService
<TaxonBase
>, IPublishableService
<TaxonBase
>{
74 * NOTE: Also taxa with <code>publish=false</code> are returned.
77 public TaxonBase
load(UUID uuid
, List
<String
> propertyPaths
);
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
85 public List
<TaxonBase
> searchByName(String name
, boolean includeUnpublished
, Reference sec
);
88 * Swaps given synonym and accepted taxon.
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>
98 * @param acceptedTaxon
99 * @param setNameInSource
102 public UpdateResult
swapSynonymAndAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
, boolean setNameInSource
, boolean newUuidForAcceptedTaxon
, SecReferenceHandlingSwapEnum secHandling
, Reference secRefAcc
, Reference secRefSyn
);
104 public UpdateResult
swapSynonymAndAcceptedTaxon(UUID synonymUUid
, UUID acceptedTaxonUuid
, boolean setNameInSource
, boolean newUuidForAcceptedTaxon
, SecReferenceHandlingSwapEnum secHandling
, UUID newSecAcc
, UUID newSecSyn
);
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.
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
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.
137 public UpdateResult
changeSynonymToAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
,Reference newSecRef
, String microRef
, SecReferenceHandlingEnum secHandling
, boolean deleteSynonym
) throws HomotypicalGroupChangeException
;
141 * @param acceptedTaxonUuid
142 * @param newParentNodeUuid
143 * @param deleteSynonym
145 * @throws HomotypicalGroupChangeException
147 public UpdateResult
changeSynonymToAcceptedTaxon(UUID synonymUuid
, UUID acceptedTaxonUuid
, UUID newParentNodeUuid
, UUID newSecRef
, String microRef
, SecReferenceHandlingEnum secHandling
,
148 boolean deleteSynonym
)
149 throws HomotypicalGroupChangeException
;
152 * Change a synonym into a related concept
155 * the synonym to change into the concept taxon
157 * the taxon the newly created concept should be related to
158 * @param taxonRelationshipType
159 * the type of relationship
161 * @param microReference
163 * update result with the newly created concept
165 public UpdateResult
changeSynonymToRelatedTaxon(Synonym synonym
, Taxon toTaxon
, TaxonRelationshipType taxonRelationshipType
, Reference reference
, String microReference
);
169 * Change a related concept into synonym
172 * the concept taxon to change into a synonym
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
181 * update result with the newly created synonym
182 * @throws DataChangeNoRollbackException
184 public UpdateResult
changeRelatedTaxonToSynonym(Taxon fromTaxon
, Taxon toTaxon
,
185 TaxonRelationshipType oldRelationshipType
,
186 SynonymType synonymType
) throws DataChangeNoRollbackException
;
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
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
201 * @param newHomotypicalGroup
203 * @param setBasionymRelationIfApplicable
205 public void changeHomotypicalGroupOfSynonym(Synonym synonym
, HomotypicalGroup newHomotypicalGroup
,
206 Taxon targetTaxon
, boolean setBasionymRelationIfApplicable
);
209 * See {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
212 * @param moveHomotypicGroup
213 * @param newSynonymType
215 * @throws HomotypicalGroupChangeException
217 public UpdateResult
moveSynonymToAnotherTaxon(Synonym oldSynonym
, Taxon newTaxon
, boolean moveHomotypicGroup
,
218 SynonymType newSynonymType
) throws HomotypicalGroupChangeException
;
221 * Moves a synonym to another taxon and removes the old synonym relationship.
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
243 public UpdateResult
moveSynonymToAnotherTaxon(Synonym oldSynonym
, Taxon newTaxon
, boolean moveHomotypicGroup
,
244 SynonymType newSynonymType
, UUID newSecundumUuid
,
245 String newSecundumDetail
, boolean keepSecundumIfUndefined
) throws HomotypicalGroupChangeException
;
248 * @see {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
250 public UpdateResult
moveSynonymToAnotherTaxon(Synonym oldSynonym
,
251 UUID newTaxonUUID
, boolean moveHomotypicGroup
,
252 SynonymType newSynonymType
,
253 UUID newSecundumUuid
, String newSecundumDetail
, boolean keepSecundumIfUndefined
)
254 throws HomotypicalGroupChangeException
;
257 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
258 * where the supplied taxon is relatedTo.
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
269 public List
<TaxonRelationship
> listToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
270 boolean includeUnpublished
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
274 * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
275 * where the supplied taxon is relatedTo.
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
286 public Pager
<TaxonRelationship
> pageToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
287 boolean includeUnpublished
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
290 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
291 * where the supplied taxon is relatedFrom.
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
302 public List
<TaxonRelationship
> listFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
303 boolean includeUnpublished
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
307 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
308 * where the supplied taxon is relatedFrom.
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
319 public Pager
<TaxonRelationship
> pageFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
320 boolean includeUnpublished
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
323 * lists all taxa which are related to the <code>taxon</code> given as
327 * @param includeRelationships
329 * <code>1</code> for one level, <code>null</code> for infinite
330 * depth, <code>0</code> will completely omit collecting related taxa.
333 * @param propertyPaths
336 public Set
<Taxon
> listRelatedTaxa(Taxon taxon
, Set
<TaxonRelationshipEdge
> includeRelationships
, Integer maxDepth
,
337 boolean includeUnpublished
, Integer limit
, Integer start
, List
<String
> propertyPaths
);
341 * Returns all or a page of all taxon concept relationships in the database.
342 * The result can be filtered by relationship types.
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
351 public List
<TaxonRelationship
> listTaxonRelationships(Set
<TaxonRelationshipType
> types
,
352 Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
355 * Lists all classifications the given taxon/synonym is used in{@link Synonym}
360 * @param propertyPaths
363 public List
<Classification
> listClassifications(TaxonBase taxonBase
, Integer limit
, Integer start
, List
<String
> propertyPaths
);
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.
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
377 public Pager
<Synonym
> getSynonyms(Taxon taxon
, SynonymType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
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)}
386 * @see #getSynonyms()
387 * @see SynonymType#HETEROTYPIC_SYNONYM_OF()
388 * @see eu.etaxonomy.cdm.model.name.HomotypicalGroup
390 * @param taxon the accepted taxon
391 * @param propertyPaths the property path
392 * @return the list of groups of synonyms
394 public List
<List
<Synonym
>> getSynonymsByHomotypicGroup(Taxon taxon
, List
<String
> propertyPaths
);
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.
401 * @param propertyPaths
404 public List
<Synonym
> getHomotypicSynonymsByHomotypicGroup(Taxon taxon
, List
<String
> propertyPaths
);
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.
420 * @see #getHeterotypicSynonymyGroups()
421 * @see #getSynonyms()
422 * @see SynonymType#HETEROTYPIC_SYNONYM_OF()
423 * @see eu.etaxonomy.cdm.model.name.HomotypicalGroup
426 * @param propertyPaths
429 public List
<List
<Synonym
>> getHeterotypicSynonymyGroups(Taxon taxon
, List
<String
> propertyPaths
);
432 * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
434 * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
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)
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>
447 public Pager
<TaxonBase
> search(Class
<?
extends TaxonBase
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
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
454 * @param clazz optionally filter by class (can be null to return all taxa)
456 * @param infragenericEpithet
457 * @param specificEpithet
458 * @param infraspecificEpithet
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
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
);
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
472 * @param clazz optionally filter by class
474 * @param infragenericEpithet
475 * @param specificEpithet
476 * @param infraspecificEpithet
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
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
);
487 * Returns a list of IdentifiableEntity instances (in particular, TaxonName and TaxonBase instances)
488 * that match the properties specified in the configurator.
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.
493 public Pager
<IdentifiableEntity
> findTaxaAndNames(IFindTaxaAndNamesConfigurator configurator
);
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)
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
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
513 * @param highlightFragments
516 * The maximum number of objects returned (can be null for all
519 * The offset (in pageSize chunks) from the start of the result
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
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
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
;
545 * Searches for TaxonBase instances using the TaxonBase free text index.
547 * <h4>This is an experimental feature, it may be moved, modified, or even
548 * removed in future releases!!!</h4>
551 * Additional filter criterion: The specific TaxonBase subclass
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
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
565 * @param highlightFragments
568 * The maximum number of objects returned (can be null for all
571 * The offset (in pageSize chunks) from the start of the result
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
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
;
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
603 * The maximum number of objects returned (can be null for all
606 * The offset (in pageSize chunks) from the start of the result
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
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
;
627 * Searches for TaxonBase instances using the TaxonBase free text index.
631 * <h4>This is an experimental feature, it may be moved, modified, or even
632 * removed in future releases!!!</h4>
634 * Additional filter criterion: defaults to [doTaxa] if set null
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
643 * @param distributionStatus
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
650 * @param highlightFragments
653 * The maximum number of objects returned (can be null for all
656 * The offset (in pageSize chunks) from the start of the result
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
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
;
681 * Searches for TaxonBase instances by using the DescriptionElement free text index.
683 * <h4>This is an experimental feature, it may be moved, modified, or even
684 * removed in future releases!!!</h4>
687 * Additional filter criterion:
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
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
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
706 * @param highlightFragments
709 * The maximum number of objects returned (can be null for all
712 * The offset (in pageSize chunks) from the start of the result
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
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
;
731 * Lists all Media found in an any TaxonDescription associated with this
735 * @param includeRelationships
736 * the given list of TaxonRelationshipEdges will be taken into
737 * account when retrieving media associated with the given taxon.
739 * @param limitToGalleries
740 * whether to take only TaxonDescription into account which are
743 * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
746 public List
<Media
> listTaxonDescriptionMedia(Taxon taxon
, Set
<TaxonRelationshipEdge
> includeRelationships
, boolean limitToGalleries
, List
<String
> propertyPath
);
749 * Lists all Media found in an any TaxonDescription, NameDescription,
750 * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
753 * @param includeRelationships
754 * the given list of TaxonRelationshipEdges will be taken into
755 * account when retrieving media associated with the given taxon.
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
769 public List
<Media
> listMedia(Taxon taxon
, Set
<TaxonRelationshipEdge
> includeRelationships
,
770 Boolean limitToGalleries
, Boolean includeTaxonDescriptions
, Boolean includeOccurrences
,
771 Boolean includeTaxonNameDescriptions
, List
<String
> propertyPath
);
774 * Lists all Media found in an any TaxonDescription, NameDescription,
775 * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
778 * @param includeRelationships
779 * the given list of TaxonRelationshipEdges will be taken into
780 * account when retrieving media associated with the given taxon.
782 * @param limitToGalleries
783 * whether to take only descriptions into account which are
784 * marked as gallery, can be NULL
785 * @param includeTaxonDescriptions
786 * whether to take TaxonDescriptions into account, can be NULL
787 * @param includeOccurrences
788 * whether to take SpecimenDescriptions into account, can be NULL
789 * @param includeOriginals
790 * whether to take SpecimenDescriptions of the originals of associated derived units into account, can be NULL
791 * @param includeTaxonNameDescriptions
792 * whether to take TaxonNameDescriptions into account, can be NULL
793 * @param propertyPath
796 public List
<Media
> listMedia(Taxon taxon
, Set
<TaxonRelationshipEdge
> includeRelationships
,
797 Boolean limitToGalleries
, Boolean includeTaxonDescriptions
, Boolean includeOccurrences
, Boolean includeOriginals
,
798 Boolean includeTaxonNameDescriptions
, List
<String
> propertyPath
);
800 public List
<TaxonBase
> findTaxaByID(Set
<Integer
> listOfIDs
);
803 * Returns the TaxonBase with the given UUID
804 * using the given match mode and initialization strategy
807 * @param propertyPaths
810 public TaxonBase
findTaxonByUuid(UUID uuid
, List
<String
> propertyPaths
);
813 * Counts the number of synonyms
814 * @param onlyAttachedToTaxon if <code>true</code> only those synonyms being attached to
815 * an accepted taxon are counted
816 * @return the number of synonyms
818 public long countSynonyms(boolean onlyAttachedToTaxon
);
821 * Returns a map of taxon names that have identical name caches but derive from different sources.
822 * The sources are defined via the sources reference uuid.
824 * @return map of nameCaches and taxon name maps where the key is the UUID of the according sourceRefUuid
826 public Map
<String
, Map
<UUID
,Set
<TaxonName
>>> findIdenticalTaxonNames(List
<UUID
> sourceRefUuids
, List
<String
> propertyPaths
);
829 * Returns all {@link Taxon taxa} which are {@link TaxonRelationshipType#CONGRUENT_TO() congruent} or
830 * {@link TaxonRelationshipType#INCLUDES() included} in the taxon represented by the given taxon uuid.
831 * The result also returns the path to these taxa represented by the uuids of
832 * the {@link TaxonRelationshipType taxon relationships types} and doubtful information.
833 * If classificationUuids is set only taxa of classifications are returned which are included
834 * in the given {@link Classification classifications}. ALso the path to these taxa may not include
835 * taxa from other classifications.
836 * @param taxonUuid uuid of the original taxon
837 * @param classificationUuids List of uuids of classifications used as a filter
838 * @param includeDoubtful set to <code>true</code> if also doubtfully included taxa should be included in the result
839 * @return a DTO which includes a list of taxa with the pathes from the original taxon to the given taxon as well
840 * as doubtful and date information. The original taxon is included in the result.
842 public IncludedTaxaDTO
listIncludedTaxa(UUID taxonUuid
, IncludedTaxonConfiguration configuration
);
846 * Removes a synonym.<BR><BR>
848 * In detail it removes
849 * <li>the synonym concept</li>
851 * If <code>removeNameIfPossible</code> is true
852 * it also removes the synonym name if it is not used in any other context
853 * (part of a concept, in DescriptionElementSource, part of a name relationship, used inline, ...)<BR><BR>
854 * If <code>newHomotypicGroupIfNeeded</code> is <code>true</code> and the synonym name
855 * is not deleted and the name is homotypic to the taxon
856 * the name is moved to a new homotypic group.<BR><BR>
858 * If synonym is <code>null</code> the method has no effect.
862 * @param removeNameIfPossible
863 * @return deleteResult
865 public DeleteResult
deleteSynonym(Synonym synonym
, SynonymDeletionConfigurator config
);
870 * The method essentially loads the synonym and calls the
871 * {@link #deleteSynonym(Synonym, SynonymDeletionConfigurator) deleteSynonym} method
877 public DeleteResult
deleteSynonym(UUID synonymUuid
, SynonymDeletionConfigurator config
);
879 public Taxon
findBestMatchingTaxon(String taxonName
);
881 public Taxon
findBestMatchingTaxon(MatchingTaxonConfigurator config
);
883 public Synonym
findBestMatchingSynonym(String taxonName
, boolean includeUnpublished
);
885 public List
<UuidAndTitleCache
<?
extends IdentifiableEntity
>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator
);
888 * Creates the specified inferred synonyms for the taxon in the classification, but do not insert it to the database
891 * @return list of inferred synonyms
893 public List
<Synonym
> createInferredSynonyms(Taxon taxon
, Classification tree
, SynonymType type
, boolean doWithMisappliedNames
);
896 * Creates all inferred synonyms for the taxon in the classification, but do not insert it to the database
900 * @return list of inferred synonyms
902 public List
<Synonym
> createAllInferredSynonyms(Taxon taxon
, Classification tree
, boolean doWithMisappliedNames
);
904 public Taxon
findAcceptedTaxonFor(UUID synonymUuid
, UUID classificationUuid
, boolean includeUnpublished
,
905 List
<String
> propertyPaths
) throws UnpublishedException
;
907 public List
<TaxonBase
> findTaxaByName(MatchingTaxonConfigurator config
);
910 * @param clazz the optional {@link TaxonBase} subclass
911 * @param identifier the identifier string
912 * @param identifierType the identifier type
913 * @param subtreeFilter filter on a classification subtree (TaxonNode)
914 * @param matchmode the match mode for the identifier string
915 * @param includeEntity should the taxon as an object be included in the result
916 * @param pageSize page size
917 * @param pageNumber page number
918 * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
919 * @return the resulting {@link IdentifiedEntityDTO} pager
920 * @see IIdentifiableEntityService#findByIdentifier(Class, String, DefinedTerm, MatchMode, boolean, Integer, Integer, List)
922 public <S
extends TaxonBase
> Pager
<IdentifiedEntityDTO
<S
>> findByIdentifier(
923 Class
<S
> clazz
, String identifier
, DefinedTerm identifierType
, TaxonNode subtreeFilter
,
924 MatchMode matchmode
, boolean includeEntity
, Integer pageSize
,
925 Integer pageNumber
, List
<String
> propertyPaths
);
928 * Returns a pager for {@link MarkedEntityDTO DTOs} that hold the marker including type, title and uuid
929 * and the according {@link TaxonBase} information (uuid, title and the taxon object itself (optional)).
931 * @param clazz The optional {@link TaxonBase} subclass
932 * @param markerType the obligatory marker type, if not given, the results will always be empty
933 * @param markerValue the optional
934 * @param subtreeFilter filter on a classification subtree (TaxonNode)
935 * @param includeEntity should the taxon as an object be included in the result
936 * @param titleType which label to give the returned entity, taxon.titleCache, name.titleCache or name.nameCache
937 * @param pageSize page size
938 * @param pageNumber page number
939 * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
940 * @return the resulting {@link MarkedEntityDTO} pager
941 * @see IIdentifiableEntityService#findByMarker(Class, MarkerType, Boolean, boolean, Integer, Integer, List)
943 public <S
extends TaxonBase
> Pager
<MarkedEntityDTO
<S
>> findByMarker(
944 Class
<S
> clazz
, MarkerType markerType
, Boolean markerValue
,
945 TaxonNode subtreeFilter
, boolean includeEntity
, TaxonTitleType titleType
,
946 Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
948 public DeleteResult
deleteTaxon(UUID taxonUuid
, TaxonDeletionConfigurator config
, UUID classificationUuid
);
950 public UpdateResult
moveFactualDateToAnotherTaxon(UUID fromTaxonUuid
,
953 public UpdateResult
changeSynonymToRelatedTaxon(UUID synonymUuid
, UUID toTaxonUuid
, TaxonRelationshipType taxonRelationshipType
,
954 Reference citation
, String microcitation
);
956 public UpdateResult
changeRelatedTaxonToSynonym(UUID fromTaxonUuid
, UUID toTaxonUuid
,
957 TaxonRelationshipType oldRelationshipType
, SynonymType synonymType
) throws DataChangeNoRollbackException
;
960 * Returns a list of taxon relationships for a given taxon as DTO.
962 public TaxonRelationshipsDTO
listTaxonRelationships(UUID taxonUuid
,
963 Set
<TaxonRelationshipType
> directTypes
,
964 Set
<TaxonRelationshipType
> inversTypes
, Direction direction
, boolean groupMisapplications
,
965 boolean includeUnpublished
, Integer pageSize
, Integer pageNumber
);
967 public <S
extends TaxonBase
> Pager
<S
> page(Class
<S
> clazz
, List
<Restriction
<?
>> restrictions
, Integer pageSize
, Integer pageIndex
,
968 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
, boolean includeUnpublished
);