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
.ReferenceBase
;
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
.TaxonomicTree
;
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
;
46 public interface ITaxonDao
extends IIdentifiableDao
<TaxonBase
>, ITitledDao
<TaxonBase
> {
49 * Returns a list of TaxonBase instances where the taxon.titleCache property matches the name parameter,
50 * and taxon.sec matches the sec parameter.
55 public List
<TaxonBase
> getTaxaByName(String name
, ReferenceBase sec
);
58 * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
59 * where the taxonBase.name.nameCache property matches the String queryString, and taxon.sec matches the sec parameter.
64 public List
<TaxonBase
> getTaxaByName(String queryString
, Boolean accepted
, ReferenceBase sec
);
67 * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
68 * where the taxonBase.name.nameCache property matches the String queryString.
76 public List
<TaxonBase
> getTaxaByName(String queryString
, MatchMode matchMode
,
77 Boolean accepted
, Integer pageSize
, Integer pageNumber
);
81 * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
82 * where the taxonBase.name.nameCache property matches the String queryString.
85 * @param taxonomicTree TODO
87 * @param namedAreas TODO
90 * @param propertyPaths TODO
91 * @return list of found taxa
93 public List
<TaxonBase
> getTaxaByName(Class
<?
extends TaxonBase
> clazz
, String queryString
, TaxonomicTree taxonomicTree
,
94 MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
99 * @param taxonomicTree TODO
104 * @param propertyPaths
107 public long countTaxaByName(Class
<?
extends TaxonBase
> clazz
, String queryString
, TaxonomicTree taxonomicTree
,
109 MatchMode matchMode
, Set
<NamedArea
> namedAreas
);
112 // * @param queryString
113 // * @param matchMode
117 // public Integer countTaxaByName(String queryString, MatchMode matchMode,
118 // Boolean accepted);
121 // * Returns a count of TaxonBase instances where the
122 // * taxon.name properties match the parameters passed.
124 // * @param queryString search string
125 // * @param matchMode way how search string shall be matched: exact, beginning, or anywhere
126 // * @param selectModel all taxon base, taxa, or synonyms
128 // public Integer countTaxaByName(String queryString, MatchMode matchMode, SelectMode selectMode);
131 * Returns a count of TaxonBase instances where the
132 * taxon.name properties match the parameters passed.
136 * @param infragenericEpithet
137 * @param specificEpithet
138 * @param infraspecificEpithet
140 * @return a count of TaxonBase instances
142 public int countTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
,String specificEpithet
, String infraspecificEpithet
, Rank rank
);
145 * Returns a list of TaxonBase instances where the
146 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
147 * <i>null</i> will search for those taxa with a value of null in that field
150 * {@link #findByName(String, MatchMode, int, int, boolean)}
151 * which searches for {@link TaxonNameBase}<strong><code>.titleCache</code>
154 * @param clazz optionally filter by class (can be null to return all taxa)
156 * @param infragenericEpithet
157 * @param specificEpithet
158 * @param infraspecificEpithet
160 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
161 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
162 * @return a list of TaxonBase instances
164 public List
<TaxonBase
> findTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
167 * Find taxa by searching for Taxa and Synonyms where the
168 * {@link TaxonNameBase}<strong><code>.titleCache</code></strong> matches
169 * the name specified as queryString <code>taxonName</code>
172 * {@link #findTaxaByName(Class, String, String, String, String, Rank, Integer, Integer)}
173 * which searches for {@link TaxonNameBase}<strong><code>.nameCache</code>
176 * the taqxon Name to search for
177 * @param taxonomicTree TODO
179 * @param namedAreas TODO
182 * @param onlyAcccepted
185 public List
<TaxonBase
> findByNameTitleCache(Class
<?
extends TaxonBase
>clazz
, String queryString
, TaxonomicTree taxonomicTree
, MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageNumber
, Integer pageSize
, List
<String
> propertyPaths
) ;
187 public List
<TaxonBase
> getTaxaByCommonName(String queryString
, TaxonomicTree taxonomicTree
,
188 MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageSize
,
189 Integer pageNumber
, List
<String
> propertyPaths
);
192 * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
193 * @return The List<Taxon> of root taxa.
194 * @deprecated obsolete when using taxonomicTree
196 public List
<Taxon
> getRootTaxa(ReferenceBase sec
);
200 * Computes all Taxon instances that do not have a taxonomic parent.
201 * @param sec The concept reference that the taxon belongs to
202 * @param cdmFetch not used yet !! TODO
203 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
204 * @param withMisaplications if false only taxa are returned that have no isMisappliedNameFor relationship.
206 * @return The List<Taxon> of root taxa.
207 * @deprecated obsolete when using taxonomicTree
209 public List
<Taxon
> getRootTaxa(ReferenceBase sec
, CdmFetch cdmFetch
, Boolean onlyWithChildren
, Boolean withMisapplications
);
213 * Computes all Taxon instances which name is of a certain Rank.
216 * The rank of the taxon name
218 * The concept reference that the taxon belongs to
220 * not used yet !! TODO
221 * @param onlyWithChildren
222 * if true only taxa are returned that have taxonomic children. <Br>
224 * @param withMisaplications
225 * if false only taxa are returned that have no
226 * isMisappliedNameFor relationship.
227 * @param propertyPaths
228 * properties to be initialized, For detailed description and
229 * examples <b>please refer to:</b>
230 * {@link BeanInitializer#initialize(Object, List)}. <Br>
232 * @return The List<Taxon> of root taxa.
233 * @deprecated obsolete when using taxonomicTree
236 getRootTaxa(Rank rank
, ReferenceBase sec
, CdmFetch cdmFetch
, Boolean onlyWithChildren
, Boolean withMisapplications
, List
<String
> propertyPaths
);
240 * @param pagesize max maximum number of returned taxa
241 * @param page page to start, with 0 being first page
244 public List
<TaxonBase
> getAllTaxonBases(Integer pagesize
, Integer page
);
252 public List
<Taxon
> getAllTaxa(Integer limit
, Integer start
);
259 public List
<Synonym
> getAllSynonyms(Integer limit
, Integer start
);
261 public List
<RelationshipBase
> getAllRelationships(Integer limit
, Integer start
);
263 public int countAllRelationships();
268 * @param onlyAcccepted
271 public int countMatchesByName(String queryString
, MatchMode matchMode
, boolean onlyAcccepted
);
276 * @param onlyAcccepted
280 public int countMatchesByName(String queryString
, MatchMode matchMode
, boolean onlyAcccepted
, List
<Criterion
> criteria
);
283 * Returns a count of the TaxonRelationships (of where relationship.type ==
284 * type, if this argument is supplied) where the supplied taxon either is
285 * relatedFrom or relatedTo depending on the <code>direction</code>
289 * The taxon that is relatedFrom
291 * The type of TaxonRelationship (can be null)
293 * specifies the direction of the relationship
294 * @return the number of TaxonRelationship instances
296 public int countTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
297 Direction direction
);
300 * Returns the TaxonRelationships (of where relationship.type == type, if
301 * this argument is supplied) where the supplied taxon either is
302 * relatedFrom or relatedTo depending on the <code>direction</code>
306 * The taxon that is relatedTo
308 * The type of TaxonRelationship (can be null)
310 * The maximum number of relationships returned (can be null for
313 * The offset (in pageSize chunks) from the start of the result
316 * Properties to order by
317 * @param propertyPaths
318 * Properties to initialize in the returned entities, following
319 * the syntax described in
320 * {@link BeanInitializer#initialize(Object, List)}
322 * specifies the direction of the relationship
323 * @return a List of TaxonRelationship instances
325 public List
<TaxonRelationship
> getTaxonRelationships(Taxon taxon
,
326 TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
,
327 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
,
328 Direction direction
);
331 * Returns a count of the SynonymRelationships (of where relationship.type == type,
332 * if this arguement is supplied) where the supplied taxon is relatedTo.
334 * @param taxon The taxon that is relatedTo
335 * @param type The type of SynonymRelationship (can be null)
336 * @return the number of SynonymRelationship instances
338 public int countSynonyms(Taxon taxon
, SynonymRelationshipType type
);
341 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
342 * where the supplied taxon is relatedTo.
344 * @param taxon The taxon that is relatedTo
345 * @param type The type of SynonymRelationship (can be null)
346 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
347 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
348 * * @param orderHints Properties to order by
349 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
350 * @return a List of SynonymRelationship instances
352 public List
<SynonymRelationship
> getSynonyms(Taxon taxon
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
355 * Returns a count of the SynonymRelationships (of where relationship.type == type,
356 * if this arguement is supplied) where the supplied synonym is relatedFrom.
358 * @param taxon The synonym that is relatedFrom
359 * @param type The type of SynonymRelationship (can be null)
360 * @return the number of SynonymRelationship instances
362 public int countSynonyms(Synonym synonym
, SynonymRelationshipType type
);
365 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
366 * where the supplied synonym is relatedFrom.
368 * @param taxon The synonym that is relatedFrom
369 * @param type The type of SynonymRelationship (can be null)
370 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
371 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
372 * * @param orderHints Properties to order by
373 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
374 * @return a List of SynonymRelationship instances
376 public List
<SynonymRelationship
> getSynonyms(Synonym synoynm
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
382 public List
<UuidAndTitleCache
<TaxonNode
>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByTaxonomicTree(TaxonomicTree taxonomicTree
);
385 * creates all inferred synonyms for the species in the tree and insert it to the database
387 * @return List of inferred synonyms
389 //public List<Synonym> insertAllInferredSynonymy(TaxonomicTree tree);
392 * creates all inferred synonyms for the taxon in the taxonomic tree, but do not insert it to the database
395 * @return list of inferred synonyms
397 public List
<Synonym
> createAllInferredSynonyms(Taxon taxon
, TaxonomicTree tree
);
399 * creates the specified inferred synonyms for the taxon in the taxonomic tree, but do not insert it to the database
402 * @return list of inferred synonyms
404 public List
<Synonym
> createInferredSynonyms(Taxon taxon
, TaxonomicTree tree
, SynonymRelationshipType type
);
406 public List
<TaxonNameBase
> findIdenticalTaxonNames(List
<String
> propertyPath
);
407 public String
getPhylumName(TaxonNameBase name
);
409 public long countTaxaByCommonName(String searchString
,
410 TaxonomicTree taxonomicTree
, MatchMode matchMode
,
411 Set
<NamedArea
> namedAreas
);
413 public long deleteSynonymRelationships(Synonym syn
);
415 public List
<UUID
> findIdenticalTaxonNameIds(List
<String
> propertyPath
);
417 public List
<TaxonNameBase
> findIdenticalNamesNew(List
<String
> propertyPaths
);
420 public Integer
countSynonymRelationships(TaxonBase taxonBase
,
421 SynonymRelationshipType type
, Direction relatedfrom
);
423 public List
<SynonymRelationship
> getSynonymRelationships(TaxonBase taxonBase
,
424 SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
,
425 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
,
426 Direction relatedfrom
);