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