cleanup
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / ITaxonService.java
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.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;
65
66
67 public interface ITaxonService
68 extends IIdentifiableEntityService<TaxonBase>, IPublishableService<TaxonBase>{
69
70 /**
71 * {@inheritDoc}
72 * <BR><BR>
73 * NOTE: Also taxa with <code>publish=false</code> are returned.
74 */
75 @Override
76 public TaxonBase load(UUID uuid, List<String> propertyPaths);
77
78 /**
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
83 */
84 public List<TaxonBase> searchByName(String name, boolean includeUnpublished, Reference sec);
85
86 /**
87 * Swaps given synonym and accepted taxon.
88 * In particular:
89 * <ul>
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>
94 * </ul>
95 *
96 * @param synonym
97 * @param acceptedTaxon
98 * @param setNameInSource
99 * @return
100 */
101 public UpdateResult swapSynonymAndAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon, boolean setNameInSource, boolean newUuidForAcceptedTaxon);
102
103 public UpdateResult swapSynonymAndAcceptedTaxon(UUID synonymUUid, UUID acceptedTaxonUuid, boolean setNameInSource, boolean newUuidForAcceptedTaxon);
104
105 /**
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.
118 *
119 *
120 * @param synonym
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
126 * @return
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.
135 */
136 public UpdateResult changeSynonymToAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon,Reference newSecRef, String microRef, SecReferenceHandlingEnum secHandling, boolean deleteSynonym) throws HomotypicalGroupChangeException;
137
138 /**
139 * @param synonymUuid
140 * @param acceptedTaxonUuid
141 * @param newParentNodeUuid
142 * @param deleteSynonym
143 * @return
144 * @throws HomotypicalGroupChangeException
145 */
146 public UpdateResult changeSynonymToAcceptedTaxon(UUID synonymUuid, UUID acceptedTaxonUuid, UUID newParentNodeUuid, UUID newSecRef, String microRef, SecReferenceHandlingEnum secHandling,
147 boolean deleteSynonym)
148 throws HomotypicalGroupChangeException;
149
150 /**
151 * Change a synonym into a related concept
152 *
153 * @param synonym
154 * the synonym to change into the concept taxon
155 * @param toTaxon
156 * the taxon the newly created concept should be related to
157 * @param taxonRelationshipType
158 * the type of relationship
159 * @param reference
160 * @param microReference
161 * @return
162 * update result with the newly created concept
163 */
164 public UpdateResult changeSynonymToRelatedTaxon(Synonym synonym, Taxon toTaxon, TaxonRelationshipType taxonRelationshipType, Reference reference, String microReference);
165
166 /**
167 *
168 * Change a related concept into synonym
169 *
170 * @param synonym
171 * the concept taxon to change into a synonym
172 * @param toTaxon
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
178 *
179 * @return
180 * update result with the newly created synonym
181 * @throws DataChangeNoRollbackException
182 */
183 public UpdateResult changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
184 TaxonRelationshipType oldRelationshipType,
185 SynonymType synonymType) throws DataChangeNoRollbackException;
186
187 /**
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
194 * taxon before.<BR>
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
197 * is added.<BR>
198 *
199 * @param synonym
200 * @param newHomotypicalGroup
201 * @param taxon
202 * @param setBasionymRelationIfApplicable
203 */
204 public void changeHomotypicalGroupOfSynonym(Synonym synonym, HomotypicalGroup newHomotypicalGroup,
205 Taxon targetTaxon, boolean setBasionymRelationIfApplicable);
206
207 /**
208 * See {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
209 * @param oldSynonym
210 * @param newTaxon
211 * @param moveHomotypicGroup
212 * @param newSynonymType
213 * @return
214 * @throws HomotypicalGroupChangeException
215 */
216 public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym, Taxon newTaxon, boolean moveHomotypicGroup,
217 SynonymType newSynonymType) throws HomotypicalGroupChangeException;
218
219 /**
220 * Moves a synonym to another taxon and removes the old synonym relationship.
221 *
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
241 */
242 public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym, Taxon newTaxon, boolean moveHomotypicGroup,
243 SynonymType newSynonymType, UUID newSecundumUuid,
244 String newSecundumDetail, boolean keepSecundumIfUndefined) throws HomotypicalGroupChangeException;
245
246 /**
247 * @see {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
248 */
249 public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym,
250 UUID newTaxonUUID, boolean moveHomotypicGroup,
251 SynonymType newSynonymType,
252 UUID newSecundumUuid, String newSecundumDetail, boolean keepSecundumIfUndefined)
253 throws HomotypicalGroupChangeException;
254
255 /**
256 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
257 * where the supplied taxon is relatedTo.
258 *
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
267 */
268 public List<TaxonRelationship> listToTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
269 boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
270
271
272 /**
273 * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
274 * where the supplied taxon is relatedTo.
275 *
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
284 */
285 public Pager<TaxonRelationship> pageToTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
286 boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
287
288 /**
289 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
290 * where the supplied taxon is relatedFrom.
291 *
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
300 */
301 public List<TaxonRelationship> listFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
302 boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
303
304
305 /**
306 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
307 * where the supplied taxon is relatedFrom.
308 *
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
317 */
318 public Pager<TaxonRelationship> pageFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
319 boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
320
321 /**
322 * lists all taxa which are related to the <code>taxon</code> given as
323 * parameter.
324 *
325 * @param taxon
326 * @param includeRelationships
327 * @param maxDepth
328 * <code>1</code> for one level, <code>null</code> for infinite
329 * depth, <code>0</code> will completely omit collecting related taxa.
330 * @param limit
331 * @param start
332 * @param propertyPaths
333 * @return
334 */
335 public Set<Taxon> listRelatedTaxa(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, Integer maxDepth,
336 boolean includeUnpublished, Integer limit, Integer start, List<String> propertyPaths);
337
338
339 /**
340 * Returns all or a page of all taxon concept relationships in the database.
341 * The result can be filtered by relationship types.
342 *
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
349 */
350 public List<TaxonRelationship> listTaxonRelationships(Set<TaxonRelationshipType> types,
351 Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
352
353 /**
354 * Lists all classifications the given taxon/synonym is used in{@link Synonym}
355 *
356 * @param taxonBase
357 * @param limit
358 * @param start
359 * @param propertyPaths
360 * @return
361 */
362 public List<Classification> listClassifications(TaxonBase taxonBase, Integer limit, Integer start, List<String> propertyPaths);
363
364 /**
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.
367 *
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
375 */
376 public Pager<Synonym> getSynonyms(Taxon taxon, SynonymType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
377
378 /**
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)}
384 *
385 * @see #getSynonyms()
386 * @see SynonymType#HETEROTYPIC_SYNONYM_OF()
387 * @see eu.etaxonomy.cdm.model.name.HomotypicalGroup
388
389 * @param taxon the accepted taxon
390 * @param propertyPaths the property path
391 * @return the list of groups of synonyms
392 */
393 public List<List<Synonym>> getSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
394
395
396 /**
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.
399 * @param taxon
400 * @param propertyPaths
401 * @return
402 */
403 public List<Synonym> getHomotypicSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
404
405 /**
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.
418 *
419 * @see #getHeterotypicSynonymyGroups()
420 * @see #getSynonyms()
421 * @see SynonymType#HETEROTYPIC_SYNONYM_OF()
422 * @see eu.etaxonomy.cdm.model.name.HomotypicalGroup
423
424 * @param taxon
425 * @param propertyPaths
426 * @return
427 */
428 public List<List<Synonym>> getHeterotypicSynonymyGroups(Taxon taxon, List<String> propertyPaths);
429
430 /**
431 * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
432 *
433 * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
434 * @param queryString
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)
437 * @param orderHints
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>
444 */
445 @Override
446 public Pager<TaxonBase> search(Class<? extends TaxonBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
447
448 /**
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
452 *
453 * @param clazz optionally filter by class (can be null to return all taxa)
454 * @param uninomial
455 * @param infragenericEpithet
456 * @param specificEpithet
457 * @param infraspecificEpithet
458 * @param rank
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
462 */
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);
465
466 /**
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
470 *
471 * @param clazz optionally filter by class
472 * @param uninomial
473 * @param infragenericEpithet
474 * @param specificEpithet
475 * @param infraspecificEpithet
476 * @param rank
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
481 */
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);
484
485 /**
486 * Returns a list of IdentifiableEntity instances (in particular, TaxonName and TaxonBase instances)
487 * that match the properties specified in the configurator.
488 *
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.
491 */
492 public Pager<IdentifiableEntity> findTaxaAndNames(IFindTaxaAndNamesConfigurator configurator);
493
494 /**
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)
499 *
500 * @param queryString
501 * the query string
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
506 * @param languages
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
511 * set or not.
512 * @param highlightFragments
513 * TODO
514 * @param pageSize
515 * The maximum number of objects returned (can be null for all
516 * objects)
517 * @param pageNumber
518 * The offset (in pageSize chunks) from the start of the result
519 * set (0 - based)
520 * @param orderHints
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
529 * @return
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
537 */
538 @Deprecated
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;
542
543 /**
544 * Searches for TaxonBase instances using the TaxonBase free text index.
545 *
546 * <h4>This is an experimental feature, it may be moved, modified, or even
547 * removed in future releases!!!</h4>
548 *
549 * @param clazz
550 * Additional filter criterion: The specific TaxonBase subclass
551 * to search for
552 * @param queryString
553 * the query string
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
558 * @param languages
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
563 * set or not.
564 * @param highlightFragments
565 * TODO
566 * @param pageSize
567 * The maximum number of objects returned (can be null for all
568 * objects)
569 * @param pageNumber
570 * The offset (in pageSize chunks) from the start of the result
571 * set (0 - based)
572 * @param orderHints
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
584 */
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;
591
592
593 /**
594 * @param areaFilter
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
601 * @param pageSize
602 * The maximum number of objects returned (can be null for all
603 * objects)
604 * @param pageNumber
605 * The offset (in pageSize chunks) from the start of the result
606 * set (0 - based)
607 * @param orderHints
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
618 */
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;
624
625 /**
626 * Searches for TaxonBase instances using the TaxonBase free text index.
627 *
628 *
629 *
630 * <h4>This is an experimental feature, it may be moved, modified, or even
631 * removed in future releases!!!</h4>
632 * @param searchModes
633 * Additional filter criterion: defaults to [doTaxa] if set null
634 * @param queryString
635 * the query string
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
640 * @param subtree
641 * @param namedAreas
642 * @param distributionStatus
643 * @param languages
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
648 * set or not.
649 * @param highlightFragments
650 * TODO
651 * @param pageSize
652 * The maximum number of objects returned (can be null for all
653 * objects)
654 * @param pageNumber
655 * The offset (in pageSize chunks) from the start of the result
656 * set (0 - based)
657 * @param orderHints
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
671 */
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;
678
679 /**
680 * Searches for TaxonBase instances by using the DescriptionElement free text index.
681 *
682 * <h4>This is an experimental feature, it may be moved, modified, or even
683 * removed in future releases!!!</h4>
684 *
685 * @param clazz
686 * Additional filter criterion:
687 * @param queryString
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
693 * @param subtree
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
697 * @param features
698 * TODO
699 * @param languages
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
704 * set or not.
705 * @param highlightFragments
706 * TODO
707 * @param pageSize
708 * The maximum number of objects returned (can be null for all
709 * objects)
710 * @param pageNumber
711 * The offset (in pageSize chunks) from the start of the result
712 * set (0 - based)
713 * @param orderHints
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
725 */
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;
728
729 /**
730 * Lists all Media found in an any TaxonDescription associated with this
731 * taxon.
732 *
733 * @param taxon
734 * @param includeRelationships
735 * the given list of TaxonRelationshipEdges will be taken into
736 * account when retrieving media associated with the given taxon.
737 * Can be NULL.
738 * @param limitToGalleries
739 * whether to take only TaxonDescription into account which are
740 * marked as gallery
741 * @return
742 * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
743 */
744 @Deprecated
745 public List<Media> listTaxonDescriptionMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, boolean limitToGalleries, List<String> propertyPath);
746
747 /**
748 * Lists all Media found in an any TaxonDescription, NameDescription,
749 * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
750 *
751 * @param taxon
752 * @param includeRelationships
753 * the given list of TaxonRelationshipEdges will be taken into
754 * account when retrieving media associated with the given taxon.
755 * Can be NULL.
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
766 * @return
767 */
768 public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
769 Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences,
770 Boolean includeTaxonNameDescriptions, List<String> propertyPath);
771
772 public List<TaxonBase> findTaxaByID(Set<Integer> listOfIDs);
773
774 /**
775 * Returns the TaxonBase with the given UUID
776 * using the given match mode and initialization strategy
777 *
778 * @param uuid
779 * @param propertyPaths
780 * @return
781 */
782 public TaxonBase findTaxonByUuid(UUID uuid, List<String> propertyPaths);
783
784 /**
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
789 */
790 public long countSynonyms(boolean onlyAttachedToTaxon);
791
792 /**
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.
795 *
796 * @return map of nameCaches and taxon name maps where the key is the UUID of the according sourceRefUuid
797 */
798 public Map<String, Map<UUID,Set<TaxonName>>> findIdenticalTaxonNames(List<UUID> sourceRefUuids, List<String> propertyPaths);
799
800 /**
801 * Returns all {@link Taxon taxa} which are {@link TaxonRelationshipType#CONGRUENT_TO() congruent} or
802 * {@link TaxonRelationshipType#INCLUDES() included} in the taxon represented by the given taxon uuid.
803 * The result also returns the path to these taxa represented by the uuids of
804 * the {@link TaxonRelationshipType taxon relationships types} and doubtful information.
805 * If classificationUuids is set only taxa of classifications are returned which are included
806 * in the given {@link Classification classifications}. ALso the path to these taxa may not include
807 * taxa from other classifications.
808 * @param taxonUuid uuid of the original taxon
809 * @param classificationUuids List of uuids of classifications used as a filter
810 * @param includeDoubtful set to <code>true</code> if also doubtfully included taxa should be included in the result
811 * @return a DTO which includes a list of taxa with the pathes from the original taxon to the given taxon as well
812 * as doubtful and date information. The original taxon is included in the result.
813 */
814 public IncludedTaxaDTO listIncludedTaxa(UUID taxonUuid, IncludedTaxonConfiguration configuration);
815
816
817 /**
818 * Removes a synonym.<BR><BR>
819 *
820 * In detail it removes
821 * <li>the synonym concept</li>
822 * <BR><BR>
823 * If <code>removeNameIfPossible</code> is true
824 * it also removes the synonym name if it is not used in any other context
825 * (part of a concept, in DescriptionElementSource, part of a name relationship, used inline, ...)<BR><BR>
826 * If <code>newHomotypicGroupIfNeeded</code> is <code>true</code> and the synonym name
827 * is not deleted and the name is homotypic to the taxon
828 * the name is moved to a new homotypic group.<BR><BR>
829 *
830 * If synonym is <code>null</code> the method has no effect.
831 *
832 * @param taxon
833 * @param synonym
834 * @param removeNameIfPossible
835 * @return deleteResult
836 */
837 public DeleteResult deleteSynonym(Synonym synonym, SynonymDeletionConfigurator config);
838
839 /**
840 * Removes a synonym.
841 *
842 * The method essentially loads the synonym and calls the
843 * {@link #deleteSynonym(Synonym, SynonymDeletionConfigurator) deleteSynonym} method
844 *
845 * @param synonymUuid
846 * @param config
847 * @return
848 */
849 public DeleteResult deleteSynonym(UUID synonymUuid, SynonymDeletionConfigurator config);
850
851 public Taxon findBestMatchingTaxon(String taxonName);
852
853 public Taxon findBestMatchingTaxon(MatchingTaxonConfigurator config);
854
855 public Synonym findBestMatchingSynonym(String taxonName, boolean includeUnpublished);
856
857 public List<UuidAndTitleCache<? extends IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
858
859 /**
860 * Creates the specified inferred synonyms for the taxon in the classification, but do not insert it to the database
861 * @param taxon
862 * @param tree
863 * @return list of inferred synonyms
864 */
865 public List<Synonym> createInferredSynonyms(Taxon taxon, Classification tree, SynonymType type, boolean doWithMisappliedNames);
866
867 /**
868 * Creates all inferred synonyms for the taxon in the classification, but do not insert it to the database
869 * @param taxon
870 * @param tree
871 * @param iDatabase
872 * @return list of inferred synonyms
873 */
874 public List<Synonym> createAllInferredSynonyms(Taxon taxon, Classification tree, boolean doWithMisappliedNames);
875
876 public Taxon findAcceptedTaxonFor(UUID synonymUuid, UUID classificationUuid, boolean includeUnpublished,
877 List<String> propertyPaths) throws UnpublishedException;
878
879 public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
880
881 /**
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)
893 */
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);
898
899 /**
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)).
902 *
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)
914 */
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);
919
920 public DeleteResult deleteTaxon(UUID taxonUuid, TaxonDeletionConfigurator config, UUID classificationUuid);
921
922 public UpdateResult moveFactualDateToAnotherTaxon(UUID fromTaxonUuid,
923 UUID toTaxonUuid);
924
925 public UpdateResult changeSynonymToRelatedTaxon(UUID synonymUuid, UUID toTaxonUuid, TaxonRelationshipType taxonRelationshipType,
926 Reference citation, String microcitation);
927
928 public UpdateResult changeRelatedTaxonToSynonym(UUID fromTaxonUuid, UUID toTaxonUuid,
929 TaxonRelationshipType oldRelationshipType, SynonymType synonymType) throws DataChangeNoRollbackException;
930
931 /**
932 * Returns a list of taxon relationships for a given taxon as DTO.
933 */
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);
938
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);
941
942 }