2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.persistence
.dao
.taxon
;
12 import java
.util
.List
;
14 import java
.util
.UUID
;
16 import org
.hibernate
.criterion
.Criterion
;
18 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
;
19 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
.Direction
;
20 import eu
.etaxonomy
.cdm
.model
.common
.UuidAndTitleCache
;
21 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
22 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
23 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
24 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationship
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
31 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
32 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
33 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
34 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.IIdentifiableDao
;
35 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.ITitledDao
;
36 import eu
.etaxonomy
.cdm
.persistence
.dao
.initializer
.IBeanInitializer
;
37 import eu
.etaxonomy
.cdm
.persistence
.fetch
.CdmFetch
;
38 import eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
;
39 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
45 public interface ITaxonDao
extends IIdentifiableDao
<TaxonBase
>, ITitledDao
<TaxonBase
> {
48 * Returns a list of TaxonBase instances where the taxon.titleCache property matches the name parameter,
49 * and taxon.sec matches the sec parameter.
54 public List
<TaxonBase
> getTaxaByName(String name
, Reference sec
);
57 * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
58 * where the taxonBase.name.nameCache property matches the String queryString, and taxon.sec matches the sec parameter.
63 public List
<TaxonBase
> getTaxaByName(String queryString
, Boolean accepted
, Reference sec
);
66 * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
67 * where the taxonBase.name.nameCache property matches the String queryString.
75 public List
<TaxonBase
> getTaxaByName(String queryString
, MatchMode matchMode
,
76 Boolean accepted
, Integer pageSize
, Integer pageNumber
);
80 * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
81 * where the taxonBase.name.nameCache property matches the String queryString.
85 * @param classification TODO
87 * @param namedAreas TODO
90 * @param propertyPaths TODO
91 * @return list of found taxa
93 public List
<TaxonBase
> getTaxaByName(boolean doTaxa
, boolean doSynonyms
, boolean doMisappliedNames
, String queryString
, Classification classification
,
94 MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
100 * @param classification TODO
105 * @param propertyPaths
108 public long countTaxaByName(boolean doTaxa
, boolean doSynonyms
, boolean doMisappliedNames
, String queryString
, Classification classification
,
110 MatchMode matchMode
, Set
<NamedArea
> namedAreas
);
113 // * @param queryString
114 // * @param matchMode
118 // public Integer countTaxaByName(String queryString, MatchMode matchMode,
119 // Boolean accepted);
122 // * Returns a count of TaxonBase instances where the
123 // * taxon.name properties match the parameters passed.
125 // * @param queryString search string
126 // * @param matchMode way how search string shall be matched: exact, beginning, or anywhere
127 // * @param selectModel all taxon base, taxa, or synonyms
129 // public Integer countTaxaByName(String queryString, MatchMode matchMode, SelectMode selectMode);
132 * Returns a count of TaxonBase instances where the
133 * taxon.name properties match the parameters passed.
138 * @param infragenericEpithet
139 * @param specificEpithet
140 * @param infraspecificEpithet
142 * @return a count of TaxonBase instances
144 public int countTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
,String specificEpithet
, String infraspecificEpithet
, Rank rank
);
147 * Returns a list of TaxonBase instances where the
148 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
149 * <i>null</i> will search for those taxa with a value of null in that field
152 * {@link #findByName(String, MatchMode, int, int, boolean)}
153 * which searches for {@link TaxonNameBase}<strong><code>.titleCache</code>
159 * @param infragenericEpithet
160 * @param specificEpithet
161 * @param infraspecificEpithet
163 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
164 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
165 * @return a list of TaxonBase instances
167 public List
<TaxonBase
> findTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
170 * Find taxa by searching for Taxa and Synonyms where the
171 * {@link TaxonNameBase}<strong><code>.titleCache</code></strong> matches
172 * the name specified as queryString <code>taxonName</code>
175 * {@link #findTaxaByName(Class, String, String, String, String, Rank, Integer, Integer)}
176 * which searches for {@link TaxonNameBase}<strong><code>.nameCache</code>
179 * the taqxon Name to search for
180 * @param classification TODO
182 * @param namedAreas TODO
185 * @param onlyAcccepted
188 public List
<TaxonBase
> findByNameTitleCache(boolean doTaxa
, boolean doSynonyms
, String queryString
, Classification classification
, MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageNumber
, Integer pageSize
, List
<String
> propertyPaths
) ;
191 * Returns a taxon corresponding to the given uuid
194 * The uuid of the taxon requested
196 * Custom criteria to be added to the default list of applied criteria.
197 * @param propertyPaths
201 public TaxonBase
findByUuid(UUID uuid
, List
<Criterion
> criteria
, List
<String
> propertyPaths
);
204 * Returns a list of Taxon entities corresponding to the given uuid list.
207 * @param propertyPaths
210 public List
<?
extends TaxonBase
> findByUuids(List
<UUID
> uuids
, List
<Criterion
> criteria
, List
<String
> propertyPaths
);
214 * @param classification
219 * @param propertyPaths
220 * @return A List of arrays. Each entry array holds the following entities: Taxon, CommonName, Description, Feature
222 public List
<Object
[]> getTaxaByCommonName(String queryString
, Classification classification
,
223 MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageSize
,
224 Integer pageNumber
, List
<String
> propertyPaths
);
228 * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
229 * @return The List<Taxon> of root taxa.
230 * @deprecated obsolete when using classification
233 public List
<Taxon
> getRootTaxa(Reference sec
);
237 * Computes all Taxon instances that do not have a taxonomic parent.
238 * @param sec The concept reference that the taxon belongs to
239 * @param cdmFetch not used yet !! TODO
240 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
241 * @param withMisaplications if false only taxa are returned that have no isMisappliedNameFor relationship.
243 * @return The List<Taxon> of root taxa.
244 * @deprecated obsolete when using classification
247 public List
<Taxon
> getRootTaxa(Reference sec
, CdmFetch cdmFetch
, Boolean onlyWithChildren
, Boolean withMisapplications
);
251 * Computes all Taxon instances which name is of a certain Rank.
254 * The rank of the taxon name
256 * The concept reference that the taxon belongs to
258 * not used yet !! TODO
259 * @param onlyWithChildren
260 * if true only taxa are returned that have taxonomic children. <Br>
262 * @param withMisaplications
263 * if false only taxa are returned that have no
264 * isMisappliedNameFor relationship.
265 * @param propertyPaths
266 * properties to be initialized, For detailed description and
267 * examples <b>please refer to:</b>
268 * {@link IBeanInitializer#initialize(Object, List)}. <Br>
270 * @return The List<Taxon> of root taxa.
271 * @deprecated obsolete when using classification
275 getRootTaxa(Rank rank
, Reference sec
, CdmFetch cdmFetch
, Boolean onlyWithChildren
, Boolean withMisapplications
, List
<String
> propertyPaths
);
279 * @param pagesize max maximum number of returned taxa
280 * @param page page to start, with 0 being first page
283 public List
<TaxonBase
> getAllTaxonBases(Integer pagesize
, Integer page
);
291 public List
<Taxon
> getAllTaxa(Integer limit
, Integer start
);
298 public List
<Synonym
> getAllSynonyms(Integer limit
, Integer start
);
300 public List
<RelationshipBase
> getAllRelationships(Integer limit
, Integer start
);
302 public int countAllRelationships();
307 * @param onlyAcccepted
310 public int countMatchesByName(String queryString
, MatchMode matchMode
, boolean onlyAcccepted
);
315 * @param onlyAcccepted
319 public int countMatchesByName(String queryString
, MatchMode matchMode
, boolean onlyAcccepted
, List
<Criterion
> criteria
);
322 * Returns a count of the TaxonRelationships (of where relationship.type ==
323 * type, if this argument is supplied) where the supplied taxon either is
324 * relatedFrom or relatedTo depending on the <code>direction</code>
328 * The taxon that is relatedFrom
330 * The type of TaxonRelationship (can be null)
332 * specifies the direction of the relationship
333 * @return the number of TaxonRelationship instances
335 public int countTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
336 Direction direction
);
339 * Returns the TaxonRelationships (of where relationship.type == type, if
340 * this argument is supplied) where the supplied taxon either is
341 * relatedFrom or relatedTo depending on the <code>direction</code>
345 * The taxon that is relatedTo
347 * The type of TaxonRelationship (can be null)
349 * The maximum number of relationships returned (can be null for
352 * The offset (in pageSize chunks) from the start of the result
355 * Properties to order by
356 * @param propertyPaths
357 * Properties to initialize in the returned entities, following
358 * the syntax described in
359 * {@link IBeanInitializer#initialize(Object, List)}
361 * specifies the direction of the relationship
362 * @return a List of TaxonRelationship instances
364 public List
<TaxonRelationship
> getTaxonRelationships(Taxon taxon
,
365 TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
,
366 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
,
367 Direction direction
);
370 * Returns a count of the SynonymRelationships (of where relationship.type == type,
371 * if this arguement is supplied) where the supplied taxon is relatedTo.
373 * @param taxon The taxon that is relatedTo
374 * @param type The type of SynonymRelationship (can be null)
375 * @return the number of SynonymRelationship instances
377 public int countSynonyms(Taxon taxon
, SynonymRelationshipType type
);
380 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
381 * where the supplied taxon is relatedTo.
383 * @param taxon The taxon that is relatedTo
384 * @param type The type of SynonymRelationship (can be null)
385 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
386 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
387 * * @param orderHints Properties to order by
388 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
389 * @return a List of SynonymRelationship instances
391 public List
<SynonymRelationship
> getSynonyms(Taxon taxon
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
394 * Returns a count of the SynonymRelationships (of where relationship.type == type,
395 * if this arguement is supplied) where the supplied synonym is relatedFrom.
397 * @param taxon The synonym that is relatedFrom
398 * @param type The type of SynonymRelationship (can be null)
399 * @return the number of SynonymRelationship instances
401 public int countSynonyms(Synonym synonym
, SynonymRelationshipType type
);
404 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
405 * where the supplied synonym is relatedFrom.
407 * @param taxon The synonym that is relatedFrom
408 * @param type The type of SynonymRelationship (can be null)
409 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
410 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
411 * * @param orderHints Properties to order by
412 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link IBeanInitializer#initialize(Object, List)}
413 * @return a List of SynonymRelationship instances
415 public List
<SynonymRelationship
> getSynonyms(Synonym synoynm
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
421 public List
<UuidAndTitleCache
<TaxonNode
>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(Classification classification
);
424 * Creates all inferred synonyms for the species in the tree and insert it to the database
426 * @return List of inferred synonyms
428 //public List<Synonym> insertAllInferredSynonymy(Classification tree);
432 public List
<TaxonNameBase
> findIdenticalTaxonNames(List
<String
> propertyPath
);
433 public String
getPhylumName(TaxonNameBase name
);
435 public long countTaxaByCommonName(String searchString
,
436 Classification classification
, MatchMode matchMode
,
437 Set
<NamedArea
> namedAreas
);
440 * Deletes all synonym relationships of a given synonym.
441 * If taxon is given only those relationships to the taxon
443 * @param synonym the synonym
444 * @param taxon the taxon, may be <code>null</code>
446 * @deprecated This method must no longer being used since the
447 * SynonymRelationship is annotated at the {@link Taxon} and at
448 * the {@link Synonym} with <code>orphanDelete=true</code>. Just
449 * remove the from and to entities from the relationship and
450 * hibernate will care for the deletion. Using this method can cause
451 * <code>StaleStateException</code> (see http://dev.e-taxonomy.eu/trac/ticket/3797)
454 public long deleteSynonymRelationships(Synonym syn
, Taxon taxon
);
456 public List
<UUID
> findIdenticalTaxonNameIds(List
<String
> propertyPath
);
458 public List
<TaxonNameBase
> findIdenticalNamesNew(List
<String
> propertyPaths
);
461 public Integer
countSynonymRelationships(TaxonBase taxonBase
,
462 SynonymRelationshipType type
, Direction relatedfrom
);
464 public List
<SynonymRelationship
> getSynonymRelationships(TaxonBase taxonBase
,
465 SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
,
466 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
,
467 Direction relatedfrom
);
472 public List
<UuidAndTitleCache
<TaxonBase
>> getUuidAndTitleCacheTaxon();
477 public List
<UuidAndTitleCache
<TaxonBase
>> getUuidAndTitleCacheSynonym();
479 public List
<UuidAndTitleCache
<TaxonBase
>> getTaxaByNameForEditor(boolean doTaxa
, boolean doSynonyms
, String queryString
, Classification classification
,
480 MatchMode matchMode
, Set
<NamedArea
> namedAreas
);
482 public List
<String
> taxaByNameNotInDB(List
<String
> taxonNames
);
484 public List
<Taxon
> listAcceptedTaxaFor(Synonym synonym
, Classification classificationFilter
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
,
485 List
<String
> propertyPaths
);
487 public long countAcceptedTaxaFor(Synonym synonym
, Classification classificationFilter
);