ref #10260 change IdentifierType class in cdmlib and add urlPattern attribute
[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.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.model.term.IdentifierType;
61 import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
62 import eu.etaxonomy.cdm.persistence.dao.initializer.IBeanInitializer;
63 import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
64 import eu.etaxonomy.cdm.persistence.query.MatchMode;
65 import eu.etaxonomy.cdm.persistence.query.OrderHint;
66 import eu.etaxonomy.cdm.persistence.query.TaxonTitleType;
67
68
69 public interface ITaxonService
70 extends IIdentifiableEntityService<TaxonBase>, IPublishableService<TaxonBase>{
71
72 /**
73 * {@inheritDoc}
74 * <BR><BR>
75 * NOTE: Also taxa with <code>publish=false</code> are returned.
76 */
77 @Override
78 public TaxonBase load(UUID uuid, List<String> propertyPaths);
79
80 /**
81 * Returns a list of taxa that matches the name string and the sec reference
82 * @param name the name string to search for
83 * @param sec the taxons sec reference
84 * @return a list of taxa matching the name and the sec reference
85 */
86 public List<TaxonBase> searchByName(String name, boolean includeUnpublished, Reference sec);
87
88 /**
89 * Swaps given synonym and accepted taxon.
90 * In particular:
91 * <ul>
92 * <li>A new accepted taxon with the synonyms name is created</li>
93 * <li>The synonym is deleted from the old accepted taxons synonym list</li>
94 * <li>A new synonym with the name of the old accepted taxon is created</li>
95 * <li>The newly created synonym get related to the newly created accepted taxon</li>
96 * </ul>
97 *
98 * @param synonym
99 * @param acceptedTaxon
100 * @param setNameInSource
101 * @return
102 */
103 public UpdateResult swapSynonymAndAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon, boolean setNameInSource, boolean newUuidForAcceptedTaxon, SecReferenceHandlingSwapEnum secHandling, Reference secRefAcc, Reference secRefSyn);
104
105 public UpdateResult swapSynonymAndAcceptedTaxon(UUID synonymUUid, UUID acceptedTaxonUuid, boolean setNameInSource, boolean newUuidForAcceptedTaxon, SecReferenceHandlingSwapEnum secHandling, UUID newSecAcc, UUID newSecSyn);
106
107 /**
108 * Changes a synonym into an accepted taxon and removes
109 * the synonym relationship to the given accepted taxon.
110 * Other synonyms homotypic to the synonym to change are
111 * moved to the same new accepted taxon as homotypic
112 * synonyms. The new accepted taxon has the same name and
113 * the same sec reference as the old synonym.<BR>
114 * If the given accepted taxon and the synonym are homotypic
115 * to each other an exception may be thrown as taxonomically it doesn't
116 * make sense to have two accepted taxa in the same homotypic group
117 * but also it is than difficult to decide how to handle other names
118 * in the homotypic group. It is up to the implementing class to
119 * handle this situation via an exception or in another way.
120 *
121 *
122 * @param synonym
123 * the synonym to change into an accepted taxon
124 * @param acceptedTaxon
125 * an accepted taxon, the synonym had a relationship to
126 * @param deleteSynonym
127 * if true the method tries to delete the old synonym from the database
128 * @return
129 * the newly created accepted taxon
130 * @throws IllegalArgumentException
131 * if the given accepted taxon and the synonym are homotypic
132 * to each other an exception may be thrown as taxonomically it doesn't
133 * make sense to have two accepted taxa in the same homotypic group
134 * but also it is than difficult to decide how to handle other names
135 * in the homotypic group. It is up to the implementing class to
136 * handle this situation via an exception or in another way.
137 */
138 public UpdateResult changeSynonymToAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon,Reference newSecRef, String microRef, SecReferenceHandlingEnum secHandling, boolean deleteSynonym) throws HomotypicalGroupChangeException;
139
140 /**
141 * @param synonymUuid
142 * @param acceptedTaxonUuid
143 * @param newParentNodeUuid
144 * @param deleteSynonym
145 * @return
146 * @throws HomotypicalGroupChangeException
147 */
148 public UpdateResult changeSynonymToAcceptedTaxon(UUID synonymUuid, UUID acceptedTaxonUuid, UUID newParentNodeUuid, UUID newSecRef, String microRef, SecReferenceHandlingEnum secHandling,
149 boolean deleteSynonym)
150 throws HomotypicalGroupChangeException;
151
152 /**
153 * Change a synonym into a related concept
154 *
155 * @param synonym
156 * the synonym to change into the concept taxon
157 * @param toTaxon
158 * the taxon the newly created concept should be related to
159 * @param taxonRelationshipType
160 * the type of relationship
161 * @param reference
162 * @param microReference
163 * @return
164 * update result with the newly created concept
165 */
166 public UpdateResult changeSynonymToRelatedTaxon(Synonym synonym, Taxon toTaxon, TaxonRelationshipType taxonRelationshipType, Reference reference, String microReference);
167
168 /**
169 *
170 * Change a related concept into synonym
171 *
172 * @param synonym
173 * the concept taxon to change into a synonym
174 * @param toTaxon
175 * the taxon the newly created synonym should be related to
176 * @param oldRelationshipType
177 * the type of old concept relationship
178 * @param synonymRelationshipType
179 * the type of new synonym relationship
180 *
181 * @return
182 * update result with the newly created synonym
183 * @throws DataChangeNoRollbackException
184 */
185 public UpdateResult changeRelatedTaxonToSynonym(Taxon fromTaxon, Taxon toTaxon,
186 TaxonRelationshipType oldRelationshipType,
187 SynonymType synonymType) throws DataChangeNoRollbackException;
188
189 /**
190 * Changes the homotypic group of a synonym into the new homotypic group.
191 * All relations to taxa are updated correctly depending on the homotypic
192 * group of the accepted taxon. <BR>
193 * All existing basionym relationships to and from this name are removed.<BR>
194 * If the parameter <code>targetTaxon</code> is defined, the synonym is
195 * added to this taxon irrespctive of if it has been related to this
196 * taxon before.<BR>
197 * If <code>setBasionymRelationIfApplicable</code> is true a basionym relationship
198 * between the existing basionym(s) of the new homotypic group and the synonyms name
199 * is added.<BR>
200 *
201 * @param synonym
202 * @param newHomotypicalGroup
203 * @param taxon
204 * @param setBasionymRelationIfApplicable
205 */
206 public void changeHomotypicalGroupOfSynonym(Synonym synonym, HomotypicalGroup newHomotypicalGroup,
207 Taxon targetTaxon, boolean setBasionymRelationIfApplicable);
208
209 /**
210 * See {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
211 * @param oldSynonym
212 * @param newTaxon
213 * @param moveHomotypicGroup
214 * @param newSynonymType
215 * @return
216 * @throws HomotypicalGroupChangeException
217 */
218 public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym, Taxon newTaxon, boolean moveHomotypicGroup,
219 SynonymType newSynonymType) throws HomotypicalGroupChangeException;
220
221 /**
222 * Moves a synonym to another taxon and removes the old synonym relationship.
223 *
224 * @param oldSynonym the old synonym to move.
225 * @param newTaxon the taxon the synonym will be moved to
226 * @param moveHomotypicGroup if the synonym belongs to a homotypic group with other synonyms and
227 * <code>moveHomotypicGroup</code> is <code>true</code> all these synonyms are moved to the new taxon,
228 * if <code>false</code> a {@link HomotypicalGroupChangeException} is thrown.
229 * <code>moveHomotypicGroup</code> has no effect if the synonym is the only synonym in it's homotypic group.
230 * @param newSynonymType the synonym type of the new synonyms. Default is
231 * {@link SynonymType#HETEROTYPIC_SYNONYM_OF() heterotypic}.
232 * @param newSecundum The secundum for the new synonyms).
233 * @param newSecundumDetail The secundum micro reference for the new synonym(s).
234 * @param keepSecundumIfUndefined if no <code>newSecundum</code> and/or no <code>newSecundumDetail</code>
235 * is defined they are taken from the old synonym(s) if <code>keepSecundumIfUndefined</code> is
236 * <code>true</code>. If <code>false</code> the secundum and the secundum detail will be taken
237 * only from the <code>newSecundum</code> and <code>newSecundumDetail</code> even if they are
238 * undefined (<code>null</code>).
239 * @return The new synonym relationship. If <code>moveHomotypicGroup</code> is <code>true</code> additionally
240 * created new synonym relationships must be retrieved separately from the new taxon.
241 * @throws HomotypicalGroupChangeException Exception is thrown if (1) synonym is homotypic to the old accepted taxon or
242 * (2) synonym is in homotypic group with other synonyms and <code>moveHomotypicGroup</code> is false
243 */
244 public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym, Taxon newTaxon, boolean moveHomotypicGroup,
245 SynonymType newSynonymType, UUID newSecundumUuid,
246 String newSecundumDetail, boolean keepSecundumIfUndefined) throws HomotypicalGroupChangeException;
247
248 /**
249 * @see {@link #moveSynonymToAnotherTaxon(Synonym, Taxon, boolean, SynonymType, Reference, String, boolean)}
250 */
251 public UpdateResult moveSynonymToAnotherTaxon(Synonym oldSynonym,
252 UUID newTaxonUUID, boolean moveHomotypicGroup,
253 SynonymType newSynonymType,
254 UUID newSecundumUuid, String newSecundumDetail, boolean keepSecundumIfUndefined)
255 throws HomotypicalGroupChangeException;
256
257 /**
258 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
259 * where the supplied taxon is relatedTo.
260 *
261 * @param taxon The taxon that is relatedTo
262 * @param type The type of TaxonRelationship (can be null)
263 * @param includeUnpublished should unpublished related taxa also be returned?
264 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
265 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
266 * @param orderHints Properties to order by
267 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
268 * @return a List of TaxonRelationship instances
269 */
270 public List<TaxonRelationship> listToTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
271 boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
272
273
274 /**
275 * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
276 * where the supplied taxon is relatedTo.
277 *
278 * @param taxon The taxon that is relatedTo
279 * @param type The type of TaxonRelationship (can be null)
280 * @param includeUnpublished should unpublished related taxa also be returned?
281 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
282 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
283 * @param orderHints Properties to order by
284 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
285 * @return a Pager of TaxonRelationship instances
286 */
287 public Pager<TaxonRelationship> pageToTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
288 boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
289
290 /**
291 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
292 * where the supplied taxon is relatedFrom.
293 *
294 * @param taxon The taxon that is relatedFrom
295 * @param type The type of TaxonRelationship (can be null)
296 * @param includeUnpublished should unpublished related taxa also be returned?
297 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
298 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
299 * @param orderHints Properties to order by
300 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
301 * @return a List of TaxonRelationship instances
302 */
303 public List<TaxonRelationship> listFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
304 boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
305
306
307 /**
308 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
309 * where the supplied taxon is relatedFrom.
310 *
311 * @param taxon The taxon that is relatedFrom
312 * @param type The type of TaxonRelationship (can be null)
313 * @param includeUnpublished should unpublished related taxa also be returned?
314 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
315 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
316 * @param orderHints Properties to order by
317 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
318 * @return a Pager of TaxonRelationship instances
319 */
320 public Pager<TaxonRelationship> pageFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type,
321 boolean includeUnpublished, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
322
323 /**
324 * lists all taxa which are related to the <code>taxon</code> given as
325 * parameter.
326 *
327 * @param taxon
328 * @param includeRelationships
329 * @param maxDepth
330 * <code>1</code> for one level, <code>null</code> for infinite
331 * depth, <code>0</code> will completely omit collecting related taxa.
332 * @param limit
333 * @param start
334 * @param propertyPaths
335 * @return
336 */
337 public Set<Taxon> listRelatedTaxa(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, Integer maxDepth,
338 boolean includeUnpublished, Integer limit, Integer start, List<String> propertyPaths);
339
340
341 /**
342 * Returns all or a page of all taxon concept relationships in the database.
343 * The result can be filtered by relationship types.
344 *
345 * @param types The taxon relationship type filter, if <code>null</code> no filter is set, if empty the result will also be empty
346 * @param pageSize the page size
347 * @param pageStart the number of the page
348 * @param orderHints the order hints
349 * @param propertyPaths the property path to initialize the resulting objects
350 * @return list of taxon relationships matching the filter criteria
351 */
352 public List<TaxonRelationship> listTaxonRelationships(Set<TaxonRelationshipType> types,
353 Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
354
355 /**
356 * Lists all classifications the given taxon/synonym is used in{@link Synonym}
357 *
358 * @param taxonBase
359 * @param limit
360 * @param start
361 * @param propertyPaths
362 * @return
363 */
364 public List<Classification> listClassifications(TaxonBase taxonBase, Integer limit, Integer start, List<String> propertyPaths);
365
366 /**
367 * Returns the Synonyms (with the given synonym relationship type, if this argument is supplied)
368 * that do have the supplied taxon as accepted taxon.
369 *
370 * @param taxon The accepted taxon
371 * @param type The type of Synonym (can be null)
372 * @param pageSize The maximum number of synonyms returned (can be null for returning synonyms)
373 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
374 * * @param orderHints Properties to order by
375 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
376 * @return a Pager of {@link Synonym} instances
377 */
378 public Pager<Synonym> getSynonyms(Taxon taxon, SynonymType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
379
380 /**
381 * This method returns in the first entry the list of synonyms of the
382 * homotypic group of the accepted taxon. All other entries represent the lists of heterotypic
383 * synonym groups. For detailed information about these 2 groups see
384 * {@link #getHomotypicSynonymsByHomotypicGroup(Taxon, List)} and
385 * {@link #getHeterotypicSynonymyGroups(Taxon, List)}
386 *
387 * @see #getSynonyms()
388 * @see SynonymType#HETEROTYPIC_SYNONYM_OF()
389 * @see eu.etaxonomy.cdm.model.name.HomotypicalGroup
390
391 * @param taxon the accepted taxon
392 * @param propertyPaths the property path
393 * @return the list of groups of synonyms
394 */
395 public List<List<Synonym>> getSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
396
397
398 /**
399 * Returns the list of all synonyms that share the same homotypical group with the given taxon.
400 * Only those homotypic synonyms are returned that do have a synonym relationship with the accepted taxon.
401 * @param taxon
402 * @param propertyPaths
403 * @return
404 */
405 public List<Synonym> getHomotypicSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
406
407 /**
408 * Returns the ordered list of all {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup homotypical groups}
409 * that contain {@link Synonym synonyms} that are heterotypic to the given taxon.
410 * {@link eu.etaxonomy.cdm.model.name.TaxonName Taxon names} of heterotypic synonyms
411 * belong to a homotypical group which cannot be the homotypical group to which the
412 * taxon name of the given taxon belongs. This method does not return the homotypic group the given
413 * taxon belongs to.<BR>
414 * This method does neglect the type of synonym relationship that is defined between the given taxon
415 * and the synonym. So the synonym relationship may be homotypic however a synonym is returned
416 * in one of the result lists as long as the synonym does not belong to the same homotypic group as
417 * the given taxon.<BR>
418 * The list returned is ordered according to the date of publication of the
419 * first published name within each homotypical group.
420 *
421 * @see #getHeterotypicSynonymyGroups()
422 * @see #getSynonyms()
423 * @see SynonymType#HETEROTYPIC_SYNONYM_OF()
424 * @see eu.etaxonomy.cdm.model.name.HomotypicalGroup
425
426 * @param taxon
427 * @param propertyPaths
428 * @return
429 */
430 public List<List<Synonym>> getHeterotypicSynonymyGroups(Taxon taxon, List<String> propertyPaths);
431
432 /**
433 * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
434 *
435 * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
436 * @param queryString
437 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
438 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
439 * @param orderHints
440 * Supports path like <code>orderHints.propertyNames</code> which
441 * include *-to-one properties like createdBy.username or
442 * authorTeam.persistentTitleCache
443 * @param propertyPaths properties to be initialized
444 * @return a Pager Taxon instances
445 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
446 */
447 @Override
448 public Pager<TaxonBase> search(Class<? extends TaxonBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
449
450 /**
451 * Returns a list of TaxonBase instances where the
452 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
453 * <i>null</i> will search for those taxa with a value of null in that field
454 *
455 * @param clazz optionally filter by class (can be null to return all taxa)
456 * @param uninomial
457 * @param infragenericEpithet
458 * @param specificEpithet
459 * @param infraspecificEpithet
460 * @param rank
461 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
462 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
463 * @return a list of TaxonBase instances
464 */
465 public <T extends TaxonBase> Pager<T> findTaxaByName(Class<T> clazz, String uninomial, String infragenericEpithet, String specificEpithet,
466 String infraspecificEpithet, String authorshipCache, Rank rank, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
467
468 /**
469 * Returns a list of TaxonBase instances where the
470 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
471 * <i>null</i> will search for those taxa with a value of null in that field
472 *
473 * @param clazz optionally filter by class
474 * @param uninomial
475 * @param infragenericEpithet
476 * @param specificEpithet
477 * @param infraspecificEpithet
478 * @param rank
479 * @param authorshipCache
480 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
481 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
482 * @return a List of TaxonBase instances
483 */
484 public <T extends TaxonBase> List<T> listTaxaByName(Class<T> clazz, String uninomial, String infragenericEpithet, String specificEpithet,
485 String infraspecificEpithet, String authorshipCache, Rank rank, Integer pageSize, Integer pageNumber, List<String> propertyPaths);
486
487 /**
488 * Returns a list of IdentifiableEntity instances (in particular, TaxonName and TaxonBase instances)
489 * that match the properties specified in the configurator.
490 *
491 * Note: The search result includes a search on titleCache (with {@link MatchMode#BEGINNING} or {@link MatchMode#ANYWHERE} )
492 * for all records with protected titleCache (see #9561). Maybe this should be parameterized in future.
493 */
494 public Pager<IdentifiableEntity> findTaxaAndNames(IFindTaxaAndNamesConfigurator configurator);
495
496 /**
497 * performes a union searches for TaxonBase instances on all available
498 * free text indexes. At the time of writing this documentation it combines
499 * {@link #findByDescriptionElementFullText(Class, String, Classification, List, List, boolean, Integer, Integer, List, List)}
500 * and {@link #findByFullText(Class, String, Classification, List, boolean, Integer, Integer, List, List)
501 *
502 * @param queryString
503 * the query string
504 * @param classification
505 * Additional filter criterion: If a taxonomic classification
506 * three is specified here the result set will only contain taxa
507 * of the given classification
508 * @param languages
509 * Additional filter criterion: Search only in these languages.
510 * Not all text fields in the cdm model are multilingual, thus
511 * this setting will only apply to the multilingiual fields.
512 * Other fields are searched nevertheless if this parameter is
513 * set or not.
514 * @param highlightFragments
515 * TODO
516 * @param pageSize
517 * The maximum number of objects returned (can be null for all
518 * objects)
519 * @param pageNumber
520 * The offset (in pageSize chunks) from the start of the result
521 * set (0 - based)
522 * @param orderHints
523 * Supports path like <code>orderHints.propertyNames</code> which
524 * include *-to-one properties like createdBy.username or
525 * authorTeam.persistentTitleCache
526 * @param propertyPaths
527 * properties to initialize - see
528 * {@link IBeanInitializer#initialize(Object, List)}
529 * @return a paged list of instances of type T matching the queryString and
530 * the additional filter criteria
531 * @return
532 * @throws LuceneCorruptIndexException
533 * @throws IOException
534 * @throws LuceneParseException
535 * @throws LuceneMultiSearchException
536 * @deprecated this search should fully be covered by the new method
537 * {@link #findTaxaAndNamesByFullText(EnumSet, String, Classification, Set, List, boolean, Integer, Integer, List, List)}
538 * , maybe we should rename this latter method to give it a more meaningful name
539 */
540 @Deprecated
541 public Pager<SearchResult<TaxonBase>> findByEverythingFullText(String queryString,
542 Classification classification, TaxonNode subtree, boolean includeUnpublished, List<Language> languages, boolean highlightFragments,
543 Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException, LuceneMultiSearchException;
544
545 /**
546 * Searches for TaxonBase instances using the TaxonBase free text index.
547 *
548 * <h4>This is an experimental feature, it may be moved, modified, or even
549 * removed in future releases!!!</h4>
550 *
551 * @param clazz
552 * Additional filter criterion: The specific TaxonBase subclass
553 * to search for
554 * @param queryString
555 * the query string
556 * @param classification
557 * Additional filter criterion: If a taxonomic classification
558 * three is specified here the result set will only contain taxa
559 * of the given classification
560 * @param languages
561 * Additional filter criterion: Search only in these languages.
562 * Not all text fields in the cdm model are multilingual, thus
563 * this setting will only apply to the multilingiual fields.
564 * Other fields are searched nevertheless if this parameter is
565 * set or not.
566 * @param highlightFragments
567 * TODO
568 * @param pageSize
569 * The maximum number of objects returned (can be null for all
570 * objects)
571 * @param pageNumber
572 * The offset (in pageSize chunks) from the start of the result
573 * set (0 - based)
574 * @param orderHints
575 * Supports path like <code>orderHints.propertyNames</code> which
576 * include *-to-one properties like createdBy.username or
577 * authorTeam.persistentTitleCache
578 * @param propertyPaths
579 * properties to initialize - see
580 * {@link IBeanInitializer#initialize(Object, List)}
581 * @return a paged list of instances of type T matching the queryString and
582 * the additional filter criteria
583 * @throws LuceneCorruptIndexException
584 * @throws IOException
585 * @throws LuceneParseException
586 */
587 public Pager<SearchResult<TaxonBase>> findByFullText(Class<? extends TaxonBase> clazz, String queryString,
588 Classification classification, TaxonNode subtree,
589 boolean includeUnpublished, List<Language> languages,
590 boolean highlightFragments, Integer pageSize, Integer pageNumber,
591 List<OrderHint> orderHints, List<String> propertyPaths)
592 throws IOException, LuceneParseException;
593
594
595 /**
596 * @param areaFilter
597 * @param statusFilter
598 * @param classification
599 * Additional filter criterion: If a taxonomic classification
600 * three is specified here the result set will only contain taxa
601 * of the given classification
602 * @param highlightFragments
603 * @param pageSize
604 * The maximum number of objects returned (can be null for all
605 * objects)
606 * @param pageNumber
607 * The offset (in pageSize chunks) from the start of the result
608 * set (0 - based)
609 * @param orderHints
610 * Supports path like <code>orderHints.propertyNames</code> which
611 * include *-to-one properties like createdBy.username or
612 * authorTeam.persistentTitleCache
613 * @param propertyPath
614 * Common properties to initialize the instances of the
615 * CDM types ({@link Taxon} and {@link Synonym}
616 * this method can return - see {@link IBeanInitializer#initialize(Object, List)}
617 * @return a paged list of instances of {@link Taxon} instances
618 * @throws IOException
619 * @throws LuceneParseException
620 */
621 //TODO needed? currently only used in test
622 public Pager<SearchResult<TaxonBase>> findByDistribution(List<NamedArea> areaFilter, List<PresenceAbsenceTerm> statusFilter,
623 Classification classification, TaxonNode subtree,
624 Integer pageSize, Integer pageNumber,
625 List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException;
626
627 /**
628 * Searches for TaxonBase instances using the TaxonBase free text index.
629 *
630 *
631 *
632 * <h4>This is an experimental feature, it may be moved, modified, or even
633 * removed in future releases!!!</h4>
634 * @param searchModes
635 * Additional filter criterion: defaults to [doTaxa] if set null
636 * @param queryString
637 * the query string
638 * @param classification
639 * Additional filter criterion: If a taxonomic classification
640 * three is specified here the result set will only contain taxa
641 * of the given classification
642 * @param subtree
643 * @param namedAreas
644 * @param distributionStatus
645 * @param languages
646 * Additional filter criterion: Search only in these languages.
647 * Not all text fields in the cdm model are multilingual, thus
648 * this setting will only apply to the multilingiual fields.
649 * Other fields are searched nevertheless if this parameter is
650 * set or not.
651 * @param highlightFragments
652 * TODO
653 * @param pageSize
654 * The maximum number of objects returned (can be null for all
655 * objects)
656 * @param pageNumber
657 * The offset (in pageSize chunks) from the start of the result
658 * set (0 - based)
659 * @param orderHints
660 * Supports path like <code>orderHints.propertyNames</code> which
661 * include *-to-one properties like createdBy.username or
662 * authorTeam.persistentTitleCache
663 * @param propertyPath
664 * Common properties to initialize the instances of the
665 * CDM types ({@link Taxon} and {@link Synonym}
666 * this method can return - see {@link IBeanInitializer#initialize(Object, List)}
667 * @return a paged list of instances of {@link Taxon}, {@link Synonym}, matching the queryString and
668 * the additional filter criteria
669 * @throws LuceneCorruptIndexException
670 * @throws IOException
671 * @throws LuceneParseException
672 * @throws LuceneMultiSearchException
673 */
674 public Pager<SearchResult<TaxonBase>> findTaxaAndNamesByFullText(
675 EnumSet<TaxaAndNamesSearchMode> searchModes,
676 String queryString, Classification classification, TaxonNode subtree,
677 Set<NamedArea> namedAreas, Set<PresenceAbsenceTerm> distributionStatus,
678 List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,
679 List<String> propertyPaths) throws IOException, LuceneParseException, LuceneMultiSearchException;
680
681 /**
682 * Searches for TaxonBase instances by using the DescriptionElement free text index.
683 *
684 * <h4>This is an experimental feature, it may be moved, modified, or even
685 * removed in future releases!!!</h4>
686 *
687 * @param clazz
688 * Additional filter criterion:
689 * @param queryString
690 * the query string to filter by
691 * @param classification
692 * Additional filter criterion: If a taxonomic classification
693 * tree is specified here the result set will only contain taxa
694 * of the given classification
695 * @param subtree
696 * Additional filter criterion: If a taxonomic classification
697 * subtree is specified here the result set will only contain taxa
698 * of the given subtree
699 * @param features
700 * TODO
701 * @param languages
702 * Additional filter criterion: Search only in these languages.
703 * Not all text fields in the CDM model are multi-lingual, thus
704 * this setting will only apply to the multi-lingual fields.
705 * Other fields are searched nevertheless if this parameter is
706 * set or not.
707 * @param highlightFragments
708 * TODO
709 * @param pageSize
710 * The maximum number of objects returned (can be null for all
711 * objects)
712 * @param pageNumber
713 * The offset (in pageSize chunks) from the start of the result
714 * set (0 - based)
715 * @param orderHints
716 * Supports path like <code>orderHints.propertyNames</code> which
717 * include *-to-one properties like createdBy.username or
718 * authorTeam.persistentTitleCache
719 * @param propertyPaths
720 * properties to initialize - see
721 * {@link IBeanInitializer#initialize(Object, List)}
722 * @return a paged list of instances of type T matching the queryString and
723 * the additional filter criteria
724 * @throws IOException
725 * @throws LuceneCorruptIndexException
726 * @throws LuceneParseException
727 */
728 public Pager<SearchResult<TaxonBase>> findByDescriptionElementFullText(Class<? extends DescriptionElementBase> clazz,
729 String queryString, Classification classification, TaxonNode subtree, List<Feature> features, List<Language> languages, boolean highlightFragments, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) throws IOException, LuceneParseException;
730
731 /**
732 * Lists all Media found in an any TaxonDescription associated with this
733 * taxon.
734 *
735 * @param taxon
736 * @param includeRelationships
737 * the given list of TaxonRelationshipEdges will be taken into
738 * account when retrieving media associated with the given taxon.
739 * Can be NULL.
740 * @param limitToGalleries
741 * whether to take only TaxonDescription into account which are
742 * marked as gallery
743 * @return
744 * @deprecated use {@link #listMedia(Taxon, Set, boolean, boolean, List)} instead
745 */
746 @Deprecated
747 public List<Media> listTaxonDescriptionMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, boolean limitToGalleries, List<String> propertyPath);
748
749 /**
750 * Lists all Media found in an any TaxonDescription, NameDescription,
751 * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
752 *
753 * @param taxon
754 * @param includeRelationships
755 * the given list of TaxonRelationshipEdges will be taken into
756 * account when retrieving media associated with the given taxon.
757 * Can be NULL.
758 * @param limitToGalleries
759 * whether to take only descriptions into account which are
760 * marked as gallery, can be NULL
761 * @param includeTaxonDescriptions
762 * whether to take TaxonDescriptions into account, can be NULL
763 * @param includeOccurrences
764 * whether to take TaxonDescriptions into account, can be NULL
765 * @param includeTaxonNameDescriptions
766 * whether to take TaxonNameDescriptions into account, can be NULL
767 * @param propertyPath
768 * @return
769 */
770 public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
771 Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences,
772 Boolean includeTaxonNameDescriptions, List<String> propertyPath);
773
774 /**
775 * Lists all Media found in an any TaxonDescription, NameDescription,
776 * SpecimenOrObservationBase, DnaSample Chromatograms, etc. associated with this taxon.
777 *
778 * @param taxon
779 * @param includeRelationships
780 * the given list of TaxonRelationshipEdges will be taken into
781 * account when retrieving media associated with the given taxon.
782 * Can be NULL.
783 * @param limitToGalleries
784 * whether to take only descriptions into account which are
785 * marked as gallery, can be NULL
786 * @param includeTaxonDescriptions
787 * whether to take TaxonDescriptions into account, can be NULL
788 * @param includeOccurrences
789 * whether to take SpecimenDescriptions into account, can be NULL
790 * @param includeOriginals
791 * whether to take SpecimenDescriptions of the originals of associated derived units into account, can be NULL
792 * @param includeTaxonNameDescriptions
793 * whether to take TaxonNameDescriptions into account, can be NULL
794 * @param propertyPath
795 * @return
796 */
797 public List<Media> listMedia(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships,
798 Boolean limitToGalleries, Boolean includeTaxonDescriptions, Boolean includeOccurrences, Boolean includeOriginals,
799 Boolean includeTaxonNameDescriptions, List<String> propertyPath);
800
801 public List<TaxonBase> findTaxaByID(Set<Integer> listOfIDs);
802
803 /**
804 * Returns the TaxonBase with the given UUID
805 * using the given match mode and initialization strategy
806 *
807 * @param uuid
808 * @param propertyPaths
809 * @return
810 */
811 public TaxonBase findTaxonByUuid(UUID uuid, List<String> propertyPaths);
812
813 /**
814 * Counts the number of synonyms
815 * @param onlyAttachedToTaxon if <code>true</code> only those synonyms being attached to
816 * an accepted taxon are counted
817 * @return the number of synonyms
818 */
819 public long countSynonyms(boolean onlyAttachedToTaxon);
820
821 /**
822 * Returns a map of taxon names that have identical name caches but derive from different sources.
823 * The sources are defined via the sources reference uuid.
824 *
825 * @return map of nameCaches and taxon name maps where the key is the UUID of the according sourceRefUuid
826 */
827 public Map<String, Map<UUID,Set<TaxonName>>> findIdenticalTaxonNames(List<UUID> sourceRefUuids, List<String> propertyPaths);
828
829 /**
830 * Returns all {@link Taxon taxa} which are {@link TaxonRelationshipType#CONGRUENT_TO() congruent} or
831 * {@link TaxonRelationshipType#INCLUDES() included} in the taxon represented by the given taxon uuid.
832 * The result also returns the path to these taxa represented by the uuids of
833 * the {@link TaxonRelationshipType taxon relationships types} and doubtful information.
834 * If classificationUuids is set only taxa of classifications are returned which are included
835 * in the given {@link Classification classifications}. ALso the path to these taxa may not include
836 * taxa from other classifications.
837 * @param taxonUuid uuid of the original taxon
838 * @param classificationUuids List of uuids of classifications used as a filter
839 * @param includeDoubtful set to <code>true</code> if also doubtfully included taxa should be included in the result
840 * @return a DTO which includes a list of taxa with the pathes from the original taxon to the given taxon as well
841 * as doubtful and date information. The original taxon is included in the result.
842 */
843 public IncludedTaxaDTO listIncludedTaxa(UUID taxonUuid, IncludedTaxonConfiguration configuration);
844
845
846 /**
847 * Removes a synonym.<BR><BR>
848 *
849 * In detail it removes
850 * <li>the synonym concept</li>
851 * <BR><BR>
852 * If <code>removeNameIfPossible</code> is true
853 * it also removes the synonym name if it is not used in any other context
854 * (part of a concept, in DescriptionElementSource, part of a name relationship, used inline, ...)<BR><BR>
855 * If <code>newHomotypicGroupIfNeeded</code> is <code>true</code> and the synonym name
856 * is not deleted and the name is homotypic to the taxon
857 * the name is moved to a new homotypic group.<BR><BR>
858 *
859 * If synonym is <code>null</code> the method has no effect.
860 *
861 * @param taxon
862 * @param synonym
863 * @param removeNameIfPossible
864 * @return deleteResult
865 */
866 public DeleteResult deleteSynonym(Synonym synonym, SynonymDeletionConfigurator config);
867
868 /**
869 * Removes a synonym.
870 *
871 * The method essentially loads the synonym and calls the
872 * {@link #deleteSynonym(Synonym, SynonymDeletionConfigurator) deleteSynonym} method
873 *
874 * @param synonymUuid
875 * @param config
876 * @return
877 */
878 public DeleteResult deleteSynonym(UUID synonymUuid, SynonymDeletionConfigurator config);
879
880 public Taxon findBestMatchingTaxon(String taxonName);
881
882 public Taxon findBestMatchingTaxon(MatchingTaxonConfigurator config);
883
884 public Synonym findBestMatchingSynonym(String taxonName, boolean includeUnpublished);
885
886 public List<UuidAndTitleCache<? extends IdentifiableEntity>> findTaxaAndNamesForEditor(IFindTaxaAndNamesConfigurator configurator);
887
888 /**
889 * Creates the specified inferred synonyms for the taxon in the classification, but do not insert it to the database
890 * @param taxon
891 * @param tree
892 * @return list of inferred synonyms
893 */
894 public List<Synonym> createInferredSynonyms(Taxon taxon, Classification tree, SynonymType type, boolean doWithMisappliedNames);
895
896 /**
897 * Creates all inferred synonyms for the taxon in the classification, but do not insert it to the database
898 * @param taxon
899 * @param tree
900 * @param iDatabase
901 * @return list of inferred synonyms
902 */
903 public List<Synonym> createAllInferredSynonyms(Taxon taxon, Classification tree, boolean doWithMisappliedNames);
904
905 public Taxon findAcceptedTaxonFor(UUID synonymUuid, UUID classificationUuid, boolean includeUnpublished,
906 List<String> propertyPaths) throws UnpublishedException;
907
908 public List<TaxonBase> findTaxaByName(MatchingTaxonConfigurator config);
909
910 /**
911 * @param clazz the optional {@link TaxonBase} subclass
912 * @param identifier the identifier string
913 * @param identifierType the identifier type
914 * @param subtreeFilter filter on a classification subtree (TaxonNode)
915 * @param matchmode the match mode for the identifier string
916 * @param includeEntity should the taxon as an object be included in the result
917 * @param pageSize page size
918 * @param pageNumber page number
919 * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
920 * @return the resulting {@link IdentifiedEntityDTO} pager
921 * @see IIdentifiableEntityService#findByIdentifier(Class, String, DefinedTerm, MatchMode, boolean, Integer, Integer, List)
922 */
923 public <S extends TaxonBase> Pager<IdentifiedEntityDTO<S>> findByIdentifier(
924 Class<S> clazz, String identifier, IdentifierType identifierType, TaxonNode subtreeFilter,
925 MatchMode matchmode, boolean includeEntity, Integer pageSize,
926 Integer pageNumber, List<String> propertyPaths);
927
928 /**
929 * Returns a pager for {@link MarkedEntityDTO DTOs} that hold the marker including type, title and uuid
930 * and the according {@link TaxonBase} information (uuid, title and the taxon object itself (optional)).
931 *
932 * @param clazz The optional {@link TaxonBase} subclass
933 * @param markerType the obligatory marker type, if not given, the results will always be empty
934 * @param markerValue the optional
935 * @param subtreeFilter filter on a classification subtree (TaxonNode)
936 * @param includeEntity should the taxon as an object be included in the result
937 * @param titleType which label to give the returned entity, taxon.titleCache, name.titleCache or name.nameCache
938 * @param pageSize page size
939 * @param pageNumber page number
940 * @param propertyPaths property path for initializing the returned taxon object (requires includeEntity=true)
941 * @return the resulting {@link MarkedEntityDTO} pager
942 * @see IIdentifiableEntityService#findByMarker(Class, MarkerType, Boolean, boolean, Integer, Integer, List)
943 */
944 public <S extends TaxonBase> Pager<MarkedEntityDTO<S>> findByMarker(
945 Class<S> clazz, MarkerType markerType, Boolean markerValue,
946 TaxonNode subtreeFilter, boolean includeEntity, TaxonTitleType titleType,
947 Integer pageSize, Integer pageNumber, List<String> propertyPaths);
948
949 public DeleteResult deleteTaxon(UUID taxonUuid, TaxonDeletionConfigurator config, UUID classificationUuid);
950
951 public UpdateResult moveFactualDateToAnotherTaxon(UUID fromTaxonUuid,
952 UUID toTaxonUuid);
953
954 public UpdateResult changeSynonymToRelatedTaxon(UUID synonymUuid, UUID toTaxonUuid, TaxonRelationshipType taxonRelationshipType,
955 Reference citation, String microcitation);
956
957 public UpdateResult changeRelatedTaxonToSynonym(UUID fromTaxonUuid, UUID toTaxonUuid,
958 TaxonRelationshipType oldRelationshipType, SynonymType synonymType) throws DataChangeNoRollbackException;
959
960 /**
961 * Returns a list of taxon relationships for a given taxon as DTO.
962 */
963 public TaxonRelationshipsDTO listTaxonRelationships(UUID taxonUuid,
964 Set<TaxonRelationshipType> directTypes,
965 Set<TaxonRelationshipType> inversTypes, Direction direction, boolean groupMisapplications,
966 boolean includeUnpublished, Integer pageSize, Integer pageNumber);
967
968 public <S extends TaxonBase> Pager<S> page(Class<S> clazz, List<Restriction<?>> restrictions, Integer pageSize, Integer pageIndex,
969 List<OrderHint> orderHints, List<String> propertyPaths, boolean includeUnpublished);
970
971 }