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
.name
.HomotypicalGroup
;
47 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
48 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
49 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
50 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
51 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
52 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymType
;
53 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
54 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
55 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
56 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
57 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
58 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTerm
;
59 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.Restriction
;
60 import eu
.etaxonomy
.cdm
.persistence
.dao
.initializer
.IBeanInitializer
;
61 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
62 import eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
;
63 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
64 import eu
.etaxonomy
.cdm
.persistence
.query
.TaxonTitleType
;
67 public interface ITaxonService
68 extends IIdentifiableEntityService
<TaxonBase
>, IPublishableService
<TaxonBase
>{
73 * NOTE: Also taxa with <code>publish=false</code> are returned.
76 public TaxonBase
load(UUID uuid
, List
<String
> propertyPaths
);
79 * Returns a list of taxa that matches the name string and the sec reference
80 * @param name the name string to search for
81 * @param sec the taxons sec reference
82 * @return a list of taxa matching the name and the sec reference
84 public List
<TaxonBase
> searchByName(String name
, boolean includeUnpublished
, Reference sec
);
87 * Swaps given synonym and accepted taxon.
90 * <li>A new accepted taxon with the synonyms name is created</li>
91 * <li>The synonym is deleted from the old accepted taxons synonym list</li>
92 * <li>A new synonym with the name of the old accepted taxon is created</li>
93 * <li>The newly created synonym get related to the newly created accepted taxon</li>
97 * @param acceptedTaxon
98 * @param setNameInSource
101 public UpdateResult
swapSynonymAndAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
, boolean setNameInSource
, boolean newUuidForAcceptedTaxon
);
103 public UpdateResult
swapSynonymAndAcceptedTaxon(UUID synonymUUid
, UUID acceptedTaxonUuid
, boolean setNameInSource
, boolean newUuidForAcceptedTaxon
);
106 * Changes a synonym into an accepted taxon and removes
107 * the synonym relationship to the given accepted taxon.
108 * Other synonyms homotypic to the synonym to change are
109 * moved to the same new accepted taxon as homotypic
110 * synonyms. The new accepted taxon has the same name and
111 * the same sec reference as the old synonym.<BR>
112 * If the given accepted taxon and the synonym are homotypic
113 * to each other an exception may be thrown as taxonomically it doesn't
114 * make sense to have two accepted taxa in the same homotypic group
115 * but also it is than difficult to decide how to handle other names
116 * in the homotypic group. It is up to the implementing class to
117 * handle this situation via an exception or in another way.
121 * the synonym to change into an accepted taxon
122 * @param acceptedTaxon
123 * an accepted taxon, the synonym had a relationship to
124 * @param deleteSynonym
125 * if true the method tries to delete the old synonym from the database
127 * the newly created accepted taxon
128 * @throws IllegalArgumentException
129 * if the given accepted taxon and the synonym are homotypic
130 * to each other an exception may be thrown as taxonomically it doesn't
131 * make sense to have two accepted taxa in the same homotypic group
132 * but also it is than difficult to decide how to handle other names
133 * in the homotypic group. It is up to the implementing class to
134 * handle this situation via an exception or in another way.
136 public UpdateResult
changeSynonymToAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
,Reference newSecRef
, String microRef
, SecReferenceHandlingEnum secHandling
, boolean deleteSynonym
) throws HomotypicalGroupChangeException
;
140 * @param acceptedTaxonUuid
141 * @param newParentNodeUuid
142 * @param deleteSynonym
144 * @throws HomotypicalGroupChangeException
146 public UpdateResult
changeSynonymToAcceptedTaxon(UUID synonymUuid
, UUID acceptedTaxonUuid
, UUID newParentNodeUuid
, UUID newSecRef
, String microRef
, SecReferenceHandlingEnum secHandling
,
147 boolean deleteSynonym
)
148 throws HomotypicalGroupChangeException
;
151 * Change a synonym into a related concept
154 * the synonym to change into the concept taxon
156 * the taxon the newly created concept should be related to
157 * @param taxonRelationshipType
158 * the type of relationship
160 * @param microReference
162 * update result with the newly created concept
164 public UpdateResult
changeSynonymToRelatedTaxon(Synonym synonym
, Taxon toTaxon
, TaxonRelationshipType taxonRelationshipType
, Reference reference
, String microReference
);
168 * Change a related concept into synonym
171 * the concept taxon to change into a synonym
173 * the taxon the newly created synonym should be related to
174 * @param oldRelationshipType
175 * the type of old concept relationship
176 * @param synonymRelationshipType
177 * the type of new synonym relationship
180 * update result with the newly created synonym
181 * @throws DataChangeNoRollbackException
183 public UpdateResult
changeRelatedTaxonToSynonym(Taxon fromTaxon
, Taxon toTaxon
,
184 TaxonRelationshipType oldRelationshipType
,
185 SynonymType synonymType
) throws DataChangeNoRollbackException
;
188 * Changes the homotypic group of a synonym into the new homotypic group.
189 * All relations to taxa are updated correctly depending on the homotypic
190 * group of the accepted taxon. <BR>
191 * All existing basionym relationships to and from this name are removed.<BR>
192 * If the parameter <code>targetTaxon</code> is defined, the synonym is
193 * added to this taxon irrespctive of if it has been related to this
195 * If <code>setBasionymRelationIfApplicable</code> is true a basionym relationship
196 * between the existing basionym(s) of the new homotypic group and the synonyms name
200 * @param newHomotypicalGroup
202 * @param setBasionymRelationIfApplicable
204 public void changeHomotypicalGroupOfSynonym(Synonym synonym
, HomotypicalGroup newHomotypicalGroup
,
205 Taxon targetTaxon
, boolean setBasionymRelationIfApplicable
);
208 * See {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
211 * @param moveHomotypicGroup
212 * @param newSynonymType
214 * @throws HomotypicalGroupChangeException
216 public UpdateResult
moveSynonymToAnotherTaxon(Synonym oldSynonym
, Taxon newTaxon
, boolean moveHomotypicGroup
,
217 SynonymType newSynonymType
) throws HomotypicalGroupChangeException
;
220 * Moves a synonym to another taxon and removes the old synonym relationship.
222 * @param oldSynonym the old synonym to move.
223 * @param newTaxon the taxon the synonym will be moved to
224 * @param moveHomotypicGroup if the synonym belongs to a homotypic group with other synonyms and
225 * <code>moveHomotypicGroup</code> is <code>true</code> all these synonyms are moved to the new taxon,
226 * if <code>false</code> a {@link HomotypicalGroupChangeException} is thrown.
227 * <code>moveHomotypicGroup</code> has no effect if the synonym is the only synonym in it's homotypic group.
228 * @param newSynonymType the synonym type of the new synonyms. Default is
229 * {@link SynonymType#HETEROTYPIC_SYNONYM_OF() heterotypic}.
230 * @param newSecundum The secundum for the new synonyms).
231 * @param newSecundumDetail The secundum micro reference for the new synonym(s).
232 * @param keepSecundumIfUndefined if no <code>newSecundum</code> and/or no <code>newSecundumDetail</code>
233 * is defined they are taken from the old synonym(s) if <code>keepSecundumIfUndefined</code> is
234 * <code>true</code>. If <code>false</code> the secundum and the secundum detail will be taken
235 * only from the <code>newSecundum</code> and <code>newSecundumDetail</code> even if they are
236 * undefined (<code>null</code>).
237 * @return The new synonym relationship. If <code>moveHomotypicGroup</code> is <code>true</code> additionally
238 * created new synonym relationships must be retrieved separately from the new taxon.
239 * @throws HomotypicalGroupChangeException Exception is thrown if (1) synonym is homotypic to the old accepted taxon or
240 * (2) synonym is in homotypic group with other synonyms and <code>moveHomotypicGroup</code> is false
242 public UpdateResult
moveSynonymToAnotherTaxon(Synonym oldSynonym
, Taxon newTaxon
, boolean moveHomotypicGroup
,
243 SynonymType newSynonymType
, UUID newSecundumUuid
,
244 String newSecundumDetail
, boolean keepSecundumIfUndefined
) throws HomotypicalGroupChangeException
;
247 * @see {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
249 public UpdateResult
moveSynonymToAnotherTaxon(Synonym oldSynonym
,
250 UUID newTaxonUUID
, boolean moveHomotypicGroup
,
251 SynonymType newSynonymType
,
252 UUID newSecundumUuid
, String newSecundumDetail
, boolean keepSecundumIfUndefined
)
253 throws HomotypicalGroupChangeException
;
256 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
257 * where the supplied taxon is relatedTo.
259 * @param taxon The taxon that is relatedTo
260 * @param type The type of TaxonRelationship (can be null)
261 * @param includeUnpublished should unpublished related taxa also be returned?
262 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
263 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
264 * @param orderHints Properties to order by
265 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
266 * @return a List of TaxonRelationship instances
268 public List
<TaxonRelationship
> listToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
269 boolean includeUnpublished
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
273 * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
274 * where the supplied taxon is relatedTo.
276 * @param taxon The taxon that is relatedTo
277 * @param type The type of TaxonRelationship (can be null)
278 * @param includeUnpublished should unpublished related taxa also be returned?
279 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
280 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
281 * @param orderHints Properties to order by
282 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
283 * @return a Pager of TaxonRelationship instances
285 public Pager
<TaxonRelationship
> pageToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
286 boolean includeUnpublished
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
289 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
290 * where the supplied taxon is relatedFrom.
292 * @param taxon The taxon that is relatedFrom
293 * @param type The type of TaxonRelationship (can be null)
294 * @param includeUnpublished should unpublished related taxa also be returned?
295 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
296 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
297 * @param orderHints Properties to order by
298 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
299 * @return a List of TaxonRelationship instances
301 public List
<TaxonRelationship
> listFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
302 boolean includeUnpublished
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
306 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
307 * where the supplied taxon is relatedFrom.
309 * @param taxon The taxon that is relatedFrom
310 * @param type The type of TaxonRelationship (can be null)
311 * @param includeUnpublished should unpublished related taxa also be returned?
312 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
313 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
314 * @param orderHints Properties to order by
315 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
316 * @return a Pager of TaxonRelationship instances
318 public Pager
<TaxonRelationship
> pageFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
319 boolean includeUnpublished
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
322 * lists all taxa which are related to the <code>taxon</code> given as
326 * @param includeRelationships
328 * <code>1</code> for one level, <code>null</code> for infinite
329 * depth, <code>0</code> will completely omit collecting related taxa.
332 * @param propertyPaths
335 public Set
<Taxon
> listRelatedTaxa(Taxon taxon
, Set
<TaxonRelationshipEdge
> includeRelationships
, Integer maxDepth
,
336 boolean includeUnpublished
, Integer limit
, Integer start
, List
<String
> propertyPaths
);
340 * Returns all or a page of all taxon concept relationships in the database.
341 * The result can be filtered by relationship types.
343 * @param types The taxon relationship type filter, if <code>null</code> no filter is set, if empty the result will also be empty
344 * @param pageSize the page size
345 * @param pageStart the number of the page
346 * @param orderHints the order hints
347 * @param propertyPaths the property path to initialize the resulting objects
348 * @return list of taxon relationships matching the filter criteria
350 public List
<TaxonRelationship
> listTaxonRelationships(Set
<TaxonRelationshipType
> types
,
351 Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
354 * Lists all classifications the given taxon/synonym is used in{@link Synonym}
359 * @param propertyPaths
362 public List
<Classification
> listClassifications(TaxonBase taxonBase
, Integer limit
, Integer start
, List
<String
> propertyPaths
);
365 * Returns the Synonyms (with the given synonym relationship type, if this argument is supplied)
366 * that do have the supplied taxon as accepted taxon.
368 * @param taxon The accepted taxon
369 * @param type The type of Synonym (can be null)
370 * @param pageSize The maximum number of synonyms returned (can be null for returning synonyms)
371 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
372 * * @param orderHints Properties to order by
373 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
374 * @return a Pager of {@link Synonym} instances
376 public Pager
<Synonym
> getSynonyms(Taxon taxon
, SynonymType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
379 * This method returns in the first entry the list of synonyms of the
380 * homotypic group of the accepted taxon. All other entries represent the lists of heterotypic
381 * synonym groups. For detailed information about these 2 groups see
382 * {@link #getHomotypicSynonymsByHomotypicGroup(Taxon, List)} and
383 * {@link #getHeterotypicSynonymyGroups(Taxon, List)}
385 * @see #getSynonyms()
386 * @see SynonymType#HETEROTYPIC_SYNONYM_OF()
387 * @see eu.etaxonomy.cdm.model.name.HomotypicalGroup
389 * @param taxon the accepted taxon
390 * @param propertyPaths the property path
391 * @return the list of groups of synonyms
393 public List
<List
<Synonym
>> getSynonymsByHomotypicGroup(Taxon taxon
, List
<String
> propertyPaths
);
397 * Returns the list of all synonyms that share the same homotypical group with the given taxon.
398 * Only those homotypic synonyms are returned that do have a synonym relationship with the accepted taxon.
400 * @param propertyPaths
403 public List
<Synonym
> getHomotypicSynonymsByHomotypicGroup(Taxon taxon
, List
<String
> propertyPaths
);
406 * Returns the ordered list of all {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup homotypical groups}
407 * that contain {@link Synonym synonyms} that are heterotypic to the given taxon.
408 * {@link eu.etaxonomy.cdm.model.name.TaxonName Taxon names} of heterotypic synonyms
409 * belong to a homotypical group which cannot be the homotypical group to which the
410 * taxon name of the given taxon belongs. This method does not return the homotypic group the given
411 * taxon belongs to.<BR>
412 * This method does neglect the type of synonym relationship that is defined between the given taxon
413 * and the synonym. So the synonym relationship may be homotypic however a synonym is returned
414 * in one of the result lists as long as the synonym does not belong to the same homotypic group as
415 * the given taxon.<BR>
416 * The list returned is ordered according to the date of publication of the
417 * first published name within each homotypical group.
419 * @see #getHeterotypicSynonymyGroups()
420 * @see #getSynonyms()
421 * @see SynonymType#HETEROTYPIC_SYNONYM_OF()
422 * @see eu.etaxonomy.cdm.model.name.HomotypicalGroup
425 * @param propertyPaths
428 public List
<List
<Synonym
>> getHeterotypicSynonymyGroups(Taxon taxon
, List
<String
> propertyPaths
);
431 * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
433 * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
435 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
436 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
438 * Supports path like <code>orderHints.propertyNames</code> which
439 * include *-to-one properties like createdBy.username or
440 * authorTeam.persistentTitleCache
441 * @param propertyPaths properties to be initialized
442 * @return a Pager Taxon instances
443 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
446 public Pager
<TaxonBase
> search(Class
<?
extends TaxonBase
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
449 * Returns a list of TaxonBase instances where the
450 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
451 * <i>null</i> will search for those taxa with a value of null in that field
453 * @param clazz optionally filter by class (can be null to return all taxa)
455 * @param infragenericEpithet
456 * @param specificEpithet
457 * @param infraspecificEpithet
459 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
460 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
461 * @return a list of TaxonBase instances
463 public <T
extends TaxonBase
> Pager
<T
> findTaxaByName(Class
<T
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
,
464 String infraspecificEpithet
, String authorshipCache
, Rank rank
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
467 * Returns a list of TaxonBase instances where the
468 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
469 * <i>null</i> will search for those taxa with a value of null in that field
471 * @param clazz optionally filter by class
473 * @param infragenericEpithet
474 * @param specificEpithet
475 * @param infraspecificEpithet
477 * @param authorshipCache
478 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
479 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
480 * @return a List of TaxonBase instances
482 public <T
extends TaxonBase
> List
<T
> listTaxaByName(Class
<T
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
,
483 String infraspecificEpithet
, String authorshipCache
, Rank rank
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
486 * Returns a list of IdentifiableEntity instances (in particular, TaxonName and TaxonBase instances)
487 * that match the properties specified in the configurator.
489 * Note: The search result includes a search on titleCache (with {@link MatchMode#BEGINNING} or {@link MatchMode#ANYWHERE} )
490 * for all records with protected titleCache (see #9561). Maybe this should be parameterized in future.
492 public Pager
<IdentifiableEntity
> findTaxaAndNames(IFindTaxaAndNamesConfigurator configurator
);
495 * performes a union searches for TaxonBase instances on all available
496 * free text indexes. At the time of writing this documentation it combines
497 * {@link #findByDescriptionElementFullText(Class, String, Classification, List, List, boolean, Integer, Integer, List, List)}
498 * and {@link #findByFullText(Class, String, Classification, List, boolean, Integer, Integer, List, List)
502 * @param classification
503 * Additional filter criterion: If a taxonomic classification
504 * three is specified here the result set will only contain taxa
505 * of the given classification
507 * Additional filter criterion: Search only in these languages.
508 * Not all text fields in the cdm model are multilingual, thus
509 * this setting will only apply to the multilingiual fields.
510 * Other fields are searched nevertheless if this parameter is
512 * @param highlightFragments
515 * The maximum number of objects returned (can be null for all
518 * The offset (in pageSize chunks) from the start of the result
521 * Supports path like <code>orderHints.propertyNames</code> which
522 * include *-to-one properties like createdBy.username or
523 * authorTeam.persistentTitleCache
524 * @param propertyPaths
525 * properties to initialize - see
526 * {@link IBeanInitializer#initialize(Object, List)}
527 * @return a paged list of instances of type T matching the queryString and
528 * the additional filter criteria
530 * @throws LuceneCorruptIndexException
531 * @throws IOException
532 * @throws LuceneParseException
533 * @throws LuceneMultiSearchException
534 * @deprecated this search should fully be covered by the new method
535 * {@link #findTaxaAndNamesByFullText(EnumSet, String, Classification, Set, List, boolean, Integer, Integer, List, List)}
536 * , maybe we should rename this latter method to give it a more meaningful name
539 public Pager
<SearchResult
<TaxonBase
>> findByEverythingFullText(String queryString
,
540 Classification classification
, TaxonNode subtree
, boolean includeUnpublished
, List
<Language
> languages
, boolean highlightFragments
,
541 Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) throws IOException
, LuceneParseException
, LuceneMultiSearchException
;
544 * Searches for TaxonBase instances using the TaxonBase free text index.
546 * <h4>This is an experimental feature, it may be moved, modified, or even
547 * removed in future releases!!!</h4>
550 * Additional filter criterion: The specific TaxonBase subclass
554 * @param classification
555 * Additional filter criterion: If a taxonomic classification
556 * three is specified here the result set will only contain taxa
557 * of the given classification
559 * Additional filter criterion: Search only in these languages.
560 * Not all text fields in the cdm model are multilingual, thus
561 * this setting will only apply to the multilingiual fields.
562 * Other fields are searched nevertheless if this parameter is
564 * @param highlightFragments
567 * The maximum number of objects returned (can be null for all
570 * The offset (in pageSize chunks) from the start of the result
573 * Supports path like <code>orderHints.propertyNames</code> which
574 * include *-to-one properties like createdBy.username or
575 * authorTeam.persistentTitleCache
576 * @param propertyPaths
577 * properties to initialize - see
578 * {@link IBeanInitializer#initialize(Object, List)}
579 * @return a paged list of instances of type T matching the queryString and
580 * the additional filter criteria
581 * @throws LuceneCorruptIndexException
582 * @throws IOException
583 * @throws LuceneParseException
585 public Pager
<SearchResult
<TaxonBase
>> findByFullText(Class
<?
extends TaxonBase
> clazz
, String queryString
,
586 Classification classification
, TaxonNode subtree
,
587 boolean includeUnpublished
, List
<Language
> languages
,
588 boolean highlightFragments
, Integer pageSize
, Integer pageNumber
,
589 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
)
590 throws IOException
, LuceneParseException
;
595 * @param statusFilter
596 * @param classification
597 * Additional filter criterion: If a taxonomic classification
598 * three is specified here the result set will only contain taxa
599 * of the given classification
600 * @param highlightFragments
602 * The maximum number of objects returned (can be null for all
605 * The offset (in pageSize chunks) from the start of the result
608 * Supports path like <code>orderHints.propertyNames</code> which
609 * include *-to-one properties like createdBy.username or
610 * authorTeam.persistentTitleCache
611 * @param propertyPath
612 * Common properties to initialize the instances of the
613 * CDM types ({@link Taxon} and {@link Synonym}
614 * this method can return - see {@link IBeanInitializer#initialize(Object, List)}
615 * @return a paged list of instances of {@link Taxon} instances
616 * @throws IOException
617 * @throws LuceneParseException
619 //TODO needed? currently only used in test
620 public Pager
<SearchResult
<TaxonBase
>> findByDistribution(List
<NamedArea
> areaFilter
, List
<PresenceAbsenceTerm
> statusFilter
,
621 Classification classification
, TaxonNode subtree
,
622 Integer pageSize
, Integer pageNumber
,
623 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) throws IOException
, LuceneParseException
;
626 * Searches for TaxonBase instances using the TaxonBase free text index.
630 * <h4>This is an experimental feature, it may be moved, modified, or even
631 * removed in future releases!!!</h4>
633 * Additional filter criterion: defaults to [doTaxa] if set null
636 * @param classification
637 * Additional filter criterion: If a taxonomic classification
638 * three is specified here the result set will only contain taxa
639 * of the given classification
642 * @param distributionStatus
644 * Additional filter criterion: Search only in these languages.
645 * Not all text fields in the cdm model are multilingual, thus
646 * this setting will only apply to the multilingiual fields.
647 * Other fields are searched nevertheless if this parameter is
649 * @param highlightFragments
652 * The maximum number of objects returned (can be null for all
655 * The offset (in pageSize chunks) from the start of the result
658 * Supports path like <code>orderHints.propertyNames</code> which
659 * include *-to-one properties like createdBy.username or
660 * authorTeam.persistentTitleCache
661 * @param propertyPath
662 * Common properties to initialize the instances of the
663 * CDM types ({@link Taxon} and {@link Synonym}
664 * this method can return - see {@link IBeanInitializer#initialize(Object, List)}
665 * @return a paged list of instances of {@link Taxon}, {@link Synonym}, matching the queryString and
666 * the additional filter criteria
667 * @throws LuceneCorruptIndexException
668 * @throws IOException
669 * @throws LuceneParseException
670 * @throws LuceneMultiSearchException
672 public Pager
<SearchResult
<TaxonBase
>> findTaxaAndNamesByFullText(
673 EnumSet
<TaxaAndNamesSearchMode
> searchModes
,
674 String queryString
, Classification classification
, TaxonNode subtree
,
675 Set
<NamedArea
> namedAreas
, Set
<PresenceAbsenceTerm
> distributionStatus
,
676 List
<Language
> languages
, boolean highlightFragments
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
,
677 List
<String
> propertyPaths
) throws IOException
, LuceneParseException
, LuceneMultiSearchException
;
680 * Searches for TaxonBase instances by using the DescriptionElement free text index.
682 * <h4>This is an experimental feature, it may be moved, modified, or even
683 * removed in future releases!!!</h4>
686 * Additional filter criterion:
688 * the query string to filter by
689 * @param classification
690 * Additional filter criterion: If a taxonomic classification
691 * tree is specified here the result set will only contain taxa
692 * of the given classification
694 * Additional filter criterion: If a taxonomic classification
695 * subtree is specified here the result set will only contain taxa
696 * of the given subtree
700 * Additional filter criterion: Search only in these languages.
701 * Not all text fields in the CDM model are multi-lingual, thus
702 * this setting will only apply to the multi-lingual fields.
703 * Other fields are searched nevertheless if this parameter is
705 * @param highlightFragments
708 * The maximum number of objects returned (can be null for all
711 * The offset (in pageSize chunks) from the start of the result
714 * Supports path like <code>orderHints.propertyNames</code> which
715 * include *-to-one properties like createdBy.username or
716 * authorTeam.persistentTitleCache
717 * @param propertyPaths
718 * properties to initialize - see
719 * {@link IBeanInitializer#initialize(Object, List)}
720 * @return a paged list of instances of type T matching the queryString and
721 * the additional filter criteria
722 * @throws IOException
723 * @throws LuceneCorruptIndexException
724 * @throws LuceneParseException
726 public Pager
<SearchResult
<TaxonBase
>> findByDescriptionElementFullText(Class
<?
extends DescriptionElementBase
> clazz
,
727 String queryString
, Classification classification
, TaxonNode subtree
, List
<Feature
> features
, List
<Language
> languages
, boolean highlightFragments
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) throws IOException
, LuceneParseException
;
730 * Lists all Media found in an any TaxonDescription associated with this
734 * @param includeRelationships
735 * the given list of TaxonRelationshipEdges will be taken into
736 * account when retrieving media associated with the given taxon.
738 * @param limitToGalleries
739 * whether to take only TaxonDescription into account which are
742 * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
745 public List
<Media
> listTaxonDescriptionMedia(Taxon taxon
, Set
<TaxonRelationshipEdge
> includeRelationships
, boolean limitToGalleries
, List
<String
> propertyPath
);
748 * Lists all Media found in an any TaxonDescription, NameDescription,
749 * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
752 * @param includeRelationships
753 * the given list of TaxonRelationshipEdges will be taken into
754 * account when retrieving media associated with the given taxon.
756 * @param limitToGalleries
757 * whether to take only descriptions into account which are
758 * marked as gallery, can be NULL
759 * @param includeTaxonDescriptions
760 * whether to take TaxonDescriptions into account, can be NULL
761 * @param includeOccurrences
762 * whether to take TaxonDescriptions into account, can be NULL
763 * @param includeTaxonNameDescriptions
764 * whether to take TaxonNameDescriptions into account, can be NULL
765 * @param propertyPath
768 public List
<Media
> listMedia(Taxon taxon
, Set
<TaxonRelationshipEdge
> includeRelationships
,
769 Boolean limitToGalleries
, Boolean includeTaxonDescriptions
, Boolean includeOccurrences
,
770 Boolean includeTaxonNameDescriptions
, List
<String
> propertyPath
);
772 public List
<TaxonBase
> findTaxaByID(Set
<Integer
> listOfIDs
);
775 * Returns the TaxonBase with the given UUID
776 * using the given match mode and initialization strategy
779 * @param propertyPaths
782 public TaxonBase
findTaxonByUuid(UUID uuid
, List
<String
> propertyPaths
);
785 * Counts the number of synonyms
786 * @param onlyAttachedToTaxon if <code>true</code> only those synonyms being attached to
787 * an accepted taxon are counted
788 * @return the number of synonyms
790 public long countSynonyms(boolean onlyAttachedToTaxon
);
793 * Returns a map of taxon names that have identical name caches but derive from different sources.
794 * The sources are defined via the sources reference uuid.
796 * @return map of nameCaches and taxon name maps where the key is the UUID of the according sourceRefUuid
798 public Map
<String
, Map
<UUID
,Set
<TaxonName
>>> findIdenticalTaxonNames(List
<UUID
> sourceRefUuids
, List
<String
> propertyPaths
);
801 * Returns all {@link Taxon taxa} which are {@link TaxonRelationshipType#CONGRUENT_TO() congruent} or
802 * {@link TaxonRelationshipType#INCLUDES() included} in the taxon represented by the given taxon uuid.
803 * The result also returns the path to these taxa represented by the uuids of
804 * the {@link TaxonRelationshipType taxon relationships types} and doubtful information.
805 * If classificationUuids is set only taxa of classifications are returned which are included
806 * in the given {@link Classification classifications}. ALso the path to these taxa may not include
807 * taxa from other classifications.
808 * @param taxonUuid uuid of the original taxon
809 * @param classificationUuids List of uuids of classifications used as a filter
810 * @param includeDoubtful set to <code>true</code> if also doubtfully included taxa should be included in the result
811 * @return a DTO which includes a list of taxa with the pathes from the original taxon to the given taxon as well
812 * as doubtful and date information. The original taxon is included in the result.
814 public IncludedTaxaDTO
listIncludedTaxa(UUID taxonUuid
, IncludedTaxonConfiguration configuration
);
818 * Removes a synonym.<BR><BR>
820 * In detail it removes
821 * <li>the synonym concept</li>
823 * If <code>removeNameIfPossible</code> is true
824 * it also removes the synonym name if it is not used in any other context
825 * (part of a concept, in DescriptionElementSource, part of a name relationship, used inline, ...)<BR><BR>
826 * If <code>newHomotypicGroupIfNeeded</code> is <code>true</code> and the synonym name
827 * is not deleted and the name is homotypic to the taxon
828 * the name is moved to a new homotypic group.<BR><BR>
830 * If synonym is <code>null</code> the method has no effect.
834 * @param removeNameIfPossible
835 * @return deleteResult
837 public DeleteResult
deleteSynonym(Synonym synonym
, SynonymDeletionConfigurator config
);
842 * The method essentially loads the synonym and calls the
843 * {@link #deleteSynonym(Synonym, SynonymDeletionConfigurator) deleteSynonym} method
849 public DeleteResult
deleteSynonym(UUID synonymUuid
, SynonymDeletionConfigurator config
);
851 public Taxon
findBestMatchingTaxon(String taxonName
);
853 public Taxon
findBestMatchingTaxon(MatchingTaxonConfigurator config
);
855 public Synonym
findBestMatchingSynonym(String taxonName
, boolean includeUnpublished
);
857 public List
<UuidAndTitleCache
<?
extends IdentifiableEntity
>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator
);
860 * Creates the specified inferred synonyms for the taxon in the classification, but do not insert it to the database
863 * @return list of inferred synonyms
865 public List
<Synonym
> createInferredSynonyms(Taxon taxon
, Classification tree
, SynonymType type
, boolean doWithMisappliedNames
);
868 * Creates all inferred synonyms for the taxon in the classification, but do not insert it to the database
872 * @return list of inferred synonyms
874 public List
<Synonym
> createAllInferredSynonyms(Taxon taxon
, Classification tree
, boolean doWithMisappliedNames
);
876 public Taxon
findAcceptedTaxonFor(UUID synonymUuid
, UUID classificationUuid
, boolean includeUnpublished
,
877 List
<String
> propertyPaths
) throws UnpublishedException
;
879 public List
<TaxonBase
> findTaxaByName(MatchingTaxonConfigurator config
);
882 * @param clazz the optional {@link TaxonBase} subclass
883 * @param identifier the identifier string
884 * @param identifierType the identifier type
885 * @param subtreeFilter filter on a classification subtree (TaxonNode)
886 * @param matchmode the match mode for the identifier string
887 * @param includeEntity should the taxon as an object be included in the result
888 * @param pageSize page size
889 * @param pageNumber page number
890 * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
891 * @return the resulting {@link IdentifiedEntityDTO} pager
892 * @see IIdentifiableEntityService#findByIdentifier(Class, String, DefinedTerm, MatchMode, boolean, Integer, Integer, List)
894 public <S
extends TaxonBase
> Pager
<IdentifiedEntityDTO
<S
>> findByIdentifier(
895 Class
<S
> clazz
, String identifier
, DefinedTerm identifierType
, TaxonNode subtreeFilter
,
896 MatchMode matchmode
, boolean includeEntity
, Integer pageSize
,
897 Integer pageNumber
, List
<String
> propertyPaths
);
900 * Returns a pager for {@link MarkedEntityDTO DTOs} that hold the marker including type, title and uuid
901 * and the according {@link TaxonBase} information (uuid, title and the taxon object itself (optional)).
903 * @param clazz The optional {@link TaxonBase} subclass
904 * @param markerType the obligatory marker type, if not given, the results will always be empty
905 * @param markerValue the optional
906 * @param subtreeFilter filter on a classification subtree (TaxonNode)
907 * @param includeEntity should the taxon as an object be included in the result
908 * @param titleType which label to give the returned entity, taxon.titleCache, name.titleCache or name.nameCache
909 * @param pageSize page size
910 * @param pageNumber page number
911 * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
912 * @return the resulting {@link MarkedEntityDTO} pager
913 * @see IIdentifiableEntityService#findByMarker(Class, MarkerType, Boolean, boolean, Integer, Integer, List)
915 public <S
extends TaxonBase
> Pager
<MarkedEntityDTO
<S
>> findByMarker(
916 Class
<S
> clazz
, MarkerType markerType
, Boolean markerValue
,
917 TaxonNode subtreeFilter
, boolean includeEntity
, TaxonTitleType titleType
,
918 Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
920 public DeleteResult
deleteTaxon(UUID taxonUuid
, TaxonDeletionConfigurator config
, UUID classificationUuid
);
922 public UpdateResult
moveFactualDateToAnotherTaxon(UUID fromTaxonUuid
,
925 public UpdateResult
changeSynonymToRelatedTaxon(UUID synonymUuid
, UUID toTaxonUuid
, TaxonRelationshipType taxonRelationshipType
,
926 Reference citation
, String microcitation
);
928 public UpdateResult
changeRelatedTaxonToSynonym(UUID fromTaxonUuid
, UUID toTaxonUuid
,
929 TaxonRelationshipType oldRelationshipType
, SynonymType synonymType
) throws DataChangeNoRollbackException
;
932 * Returns a list of taxon relationships for a given taxon as DTO.
934 public TaxonRelationshipsDTO
listTaxonRelationships(UUID taxonUuid
,
935 Set
<TaxonRelationshipType
> directTypes
,
936 Set
<TaxonRelationshipType
> inversTypes
, Direction direction
, boolean groupMisapplications
,
937 boolean includeUnpublished
, Integer pageSize
, Integer pageNumber
);
939 public <S
extends TaxonBase
> Pager
<S
> page(Class
<S
> clazz
, List
<Restriction
<?
>> restrictions
, Integer pageSize
, Integer pageIndex
,
940 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
, boolean includeUnpublished
);