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
.UuidAndTitleCache
;
20 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
.Direction
;
21 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
22 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
23 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
24 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
25 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
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
.model
.taxon
.Classification
;
35 import eu
.etaxonomy
.cdm
.persistence
.dao
.BeanInitializer
;
36 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.IIdentifiableDao
;
37 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.ITitledDao
;
38 import eu
.etaxonomy
.cdm
.persistence
.fetch
.CdmFetch
;
39 import eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
;
40 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
41 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
47 public interface ITaxonDao
extends IIdentifiableDao
<TaxonBase
>, ITitledDao
<TaxonBase
> {
50 * Returns a list of TaxonBase instances where the taxon.titleCache property matches the name parameter,
51 * and taxon.sec matches the sec parameter.
56 public List
<TaxonBase
> getTaxaByName(String name
, Reference sec
);
59 * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
60 * where the taxonBase.name.nameCache property matches the String queryString, and taxon.sec matches the sec parameter.
65 public List
<TaxonBase
> getTaxaByName(String queryString
, Boolean accepted
, Reference sec
);
68 * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
69 * where the taxonBase.name.nameCache property matches the String queryString.
77 public List
<TaxonBase
> getTaxaByName(String queryString
, MatchMode matchMode
,
78 Boolean accepted
, Integer pageSize
, Integer pageNumber
);
82 * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
83 * where the taxonBase.name.nameCache property matches the String queryString.
86 * @param classification TODO
88 * @param namedAreas TODO
91 * @param propertyPaths TODO
92 * @return list of found taxa
94 public List
<TaxonBase
> getTaxaByName(Class
<?
extends TaxonBase
> clazz
, String queryString
, Classification classification
,
95 MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
100 * @param classification TODO
105 * @param propertyPaths
108 public long countTaxaByName(Class
<?
extends TaxonBase
> clazz
, 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.
137 * @param infragenericEpithet
138 * @param specificEpithet
139 * @param infraspecificEpithet
141 * @return a count of TaxonBase instances
143 public int countTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
,String specificEpithet
, String infraspecificEpithet
, Rank rank
);
146 * Returns a list of TaxonBase instances where the
147 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
148 * <i>null</i> will search for those taxa with a value of null in that field
151 * {@link #findByName(String, MatchMode, int, int, boolean)}
152 * which searches for {@link TaxonNameBase}<strong><code>.titleCache</code>
155 * @param clazz optionally filter by class (can be null to return all taxa)
157 * @param infragenericEpithet
158 * @param specificEpithet
159 * @param infraspecificEpithet
161 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
162 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
163 * @return a list of TaxonBase instances
165 public List
<TaxonBase
> findTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
168 * Find taxa by searching for Taxa and Synonyms where the
169 * {@link TaxonNameBase}<strong><code>.titleCache</code></strong> matches
170 * the name specified as queryString <code>taxonName</code>
173 * {@link #findTaxaByName(Class, String, String, String, String, Rank, Integer, Integer)}
174 * which searches for {@link TaxonNameBase}<strong><code>.nameCache</code>
177 * the taqxon Name to search for
178 * @param classification TODO
180 * @param namedAreas TODO
183 * @param onlyAcccepted
186 public List
<TaxonBase
> findByNameTitleCache(Class
<?
extends TaxonBase
>clazz
, String queryString
, Classification classification
, MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageNumber
, Integer pageSize
, List
<String
> propertyPaths
) ;
188 public List
<TaxonBase
> getTaxaByCommonName(String queryString
, Classification classification
,
189 MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageSize
,
190 Integer pageNumber
, List
<String
> propertyPaths
);
193 * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
194 * @return The List<Taxon> of root taxa.
195 * @deprecated obsolete when using classification
197 public List
<Taxon
> getRootTaxa(Reference sec
);
201 * Computes all Taxon instances that do not have a taxonomic parent.
202 * @param sec The concept reference that the taxon belongs to
203 * @param cdmFetch not used yet !! TODO
204 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
205 * @param withMisaplications if false only taxa are returned that have no isMisappliedNameFor relationship.
207 * @return The List<Taxon> of root taxa.
208 * @deprecated obsolete when using classification
210 public List
<Taxon
> getRootTaxa(Reference sec
, CdmFetch cdmFetch
, Boolean onlyWithChildren
, Boolean withMisapplications
);
214 * Computes all Taxon instances which name is of a certain Rank.
217 * The rank of the taxon name
219 * The concept reference that the taxon belongs to
221 * not used yet !! TODO
222 * @param onlyWithChildren
223 * if true only taxa are returned that have taxonomic children. <Br>
225 * @param withMisaplications
226 * if false only taxa are returned that have no
227 * isMisappliedNameFor relationship.
228 * @param propertyPaths
229 * properties to be initialized, For detailed description and
230 * examples <b>please refer to:</b>
231 * {@link BeanInitializer#initialize(Object, List)}. <Br>
233 * @return The List<Taxon> of root taxa.
234 * @deprecated obsolete when using classification
237 getRootTaxa(Rank rank
, Reference sec
, CdmFetch cdmFetch
, Boolean onlyWithChildren
, Boolean withMisapplications
, List
<String
> propertyPaths
);
241 * @param pagesize max maximum number of returned taxa
242 * @param page page to start, with 0 being first page
245 public List
<TaxonBase
> getAllTaxonBases(Integer pagesize
, Integer page
);
253 public List
<Taxon
> getAllTaxa(Integer limit
, Integer start
);
260 public List
<Synonym
> getAllSynonyms(Integer limit
, Integer start
);
262 public List
<RelationshipBase
> getAllRelationships(Integer limit
, Integer start
);
264 public int countAllRelationships();
269 * @param onlyAcccepted
272 public int countMatchesByName(String queryString
, MatchMode matchMode
, boolean onlyAcccepted
);
277 * @param onlyAcccepted
281 public int countMatchesByName(String queryString
, MatchMode matchMode
, boolean onlyAcccepted
, List
<Criterion
> criteria
);
284 * Returns a count of the TaxonRelationships (of where relationship.type ==
285 * type, if this argument is supplied) where the supplied taxon either is
286 * relatedFrom or relatedTo depending on the <code>direction</code>
290 * The taxon that is relatedFrom
292 * The type of TaxonRelationship (can be null)
294 * specifies the direction of the relationship
295 * @return the number of TaxonRelationship instances
297 public int countTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
298 Direction direction
);
301 * Returns the TaxonRelationships (of where relationship.type == type, if
302 * this argument is supplied) where the supplied taxon either is
303 * relatedFrom or relatedTo depending on the <code>direction</code>
307 * The taxon that is relatedTo
309 * The type of TaxonRelationship (can be null)
311 * The maximum number of relationships returned (can be null for
314 * The offset (in pageSize chunks) from the start of the result
317 * Properties to order by
318 * @param propertyPaths
319 * Properties to initialize in the returned entities, following
320 * the syntax described in
321 * {@link BeanInitializer#initialize(Object, List)}
323 * specifies the direction of the relationship
324 * @return a List of TaxonRelationship instances
326 public List
<TaxonRelationship
> getTaxonRelationships(Taxon taxon
,
327 TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
,
328 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
,
329 Direction direction
);
332 * Returns a count of the SynonymRelationships (of where relationship.type == type,
333 * if this arguement is supplied) where the supplied taxon is relatedTo.
335 * @param taxon The taxon that is relatedTo
336 * @param type The type of SynonymRelationship (can be null)
337 * @return the number of SynonymRelationship instances
339 public int countSynonyms(Taxon taxon
, SynonymRelationshipType type
);
342 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
343 * where the supplied taxon is relatedTo.
345 * @param taxon The taxon that is relatedTo
346 * @param type The type of SynonymRelationship (can be null)
347 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
348 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
349 * * @param orderHints Properties to order by
350 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
351 * @return a List of SynonymRelationship instances
353 public List
<SynonymRelationship
> getSynonyms(Taxon taxon
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
356 * Returns a count of the SynonymRelationships (of where relationship.type == type,
357 * if this arguement is supplied) where the supplied synonym is relatedFrom.
359 * @param taxon The synonym that is relatedFrom
360 * @param type The type of SynonymRelationship (can be null)
361 * @return the number of SynonymRelationship instances
363 public int countSynonyms(Synonym synonym
, SynonymRelationshipType type
);
366 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
367 * where the supplied synonym is relatedFrom.
369 * @param taxon The synonym that is relatedFrom
370 * @param type The type of SynonymRelationship (can be null)
371 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
372 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
373 * * @param orderHints Properties to order by
374 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
375 * @return a List of SynonymRelationship instances
377 public List
<SynonymRelationship
> getSynonyms(Synonym synoynm
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
383 public List
<UuidAndTitleCache
<TaxonNode
>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(Classification classification
);
386 * Creates all inferred synonyms for the species in the tree and insert it to the database
388 * @return List of inferred synonyms
390 //public List<Synonym> insertAllInferredSynonymy(Classification tree);
393 * Creates all inferred synonyms for the taxon in the classification, but do not insert it to the database
396 * @return list of inferred synonyms
398 public List
<Synonym
> createAllInferredSynonyms(Taxon taxon
, Classification tree
);
400 * Creates the specified inferred synonyms for the taxon in the classification, but do not insert it to the database
403 * @return list of inferred synonyms
405 public List
<Synonym
> createInferredSynonyms(Taxon taxon
, Classification tree
, SynonymRelationshipType type
);
407 public List
<TaxonNameBase
> findIdenticalTaxonNames(List
<String
> propertyPath
);
408 public String
getPhylumName(TaxonNameBase name
);
410 public long countTaxaByCommonName(String searchString
,
411 Classification classification
, MatchMode matchMode
,
412 Set
<NamedArea
> namedAreas
);
414 public long deleteSynonymRelationships(Synonym syn
);
416 public List
<UUID
> findIdenticalTaxonNameIds(List
<String
> propertyPath
);
418 public List
<TaxonNameBase
> findIdenticalNamesNew(List
<String
> propertyPaths
);
421 public Integer
countSynonymRelationships(TaxonBase taxonBase
,
422 SynonymRelationshipType type
, Direction relatedfrom
);
424 public List
<SynonymRelationship
> getSynonymRelationships(TaxonBase taxonBase
,
425 SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
,
426 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
,
427 Direction relatedfrom
);
432 public List
<UuidAndTitleCache
<TaxonBase
>> getUuidAndTitleCacheTaxon();
437 public List
<UuidAndTitleCache
<TaxonBase
>> getUuidAndTitleCacheSynonym();
439 public List
<UuidAndTitleCache
<TaxonBase
>> getTaxaByNameForEditor(Class
<?
extends TaxonBase
> clazz
, String queryString
, Classification classification
,
440 MatchMode matchMode
, Set
<NamedArea
> namedAreas
);