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 * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
132 * @return The List<Taxon> of root taxa.
133 * @deprecated obsolete when using taxonomicTree
135 public List
<Taxon
> getRootTaxa(ReferenceBase sec
);
139 * Computes all Taxon instances that do not have a taxonomic parent.
140 * @param sec The concept reference that the taxon belongs to
141 * @param cdmFetch not used yet !! TODO
142 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
143 * @param withMisaplications if false only taxa are returned that have no isMisappliedNameFor relationship.
145 * @return The List<Taxon> of root taxa.
146 * @deprecated obsolete when using taxonomicTree
148 public List
<Taxon
> getRootTaxa(ReferenceBase sec
, CdmFetch cdmFetch
, Boolean onlyWithChildren
, Boolean withMisapplications
);
152 * Computes all Taxon instances which name is of a certain Rank.
155 * The rank of the taxon name
157 * The concept reference that the taxon belongs to
159 * not used yet !! TODO
160 * @param onlyWithChildren
161 * if true only taxa are returned that have taxonomic children. <Br>
163 * @param withMisaplications
164 * if false only taxa are returned that have no
165 * isMisappliedNameFor relationship.
166 * @param propertyPaths
167 * properties to be initialized, For detailed description and
168 * examples <b>please refer to:</b>
169 * {@link BeanInitializer#initialize(Object, List)}. <Br>
171 * @return The List<Taxon> of root taxa.
172 * @deprecated obsolete when using taxonomicTree
175 getRootTaxa(Rank rank
, ReferenceBase sec
, CdmFetch cdmFetch
, Boolean onlyWithChildren
, Boolean withMisapplications
, List
<String
> propertyPaths
);
179 * @param pagesize max maximum number of returned taxa
180 * @param page page to start, with 0 being first page
183 public List
<TaxonBase
> getAllTaxonBases(Integer pagesize
, Integer page
);
191 public List
<Taxon
> getAllTaxa(Integer limit
, Integer start
);
198 public List
<Synonym
> getAllSynonyms(Integer limit
, Integer start
);
200 public List
<RelationshipBase
> getAllRelationships(Integer limit
, Integer start
);
202 public int countAllRelationships();
205 * Find taxa by searching for @{link NameBase}
210 * @param onlyAcccepted
213 public List
<Taxon
> findByName(String queryString
, MatchMode matchMode
, int page
, int pagesize
, boolean onlyAcccepted
);
218 * @param onlyAcccepted
221 public int countMatchesByName(String queryString
, MatchMode matchMode
, boolean onlyAcccepted
);
226 * @param onlyAcccepted
230 public int countMatchesByName(String queryString
, MatchMode matchMode
, boolean onlyAcccepted
, List
<Criterion
> criteria
);
233 * Returns a count of the TaxonRelationships (of where relationship.type ==
234 * type, if this argument is supplied) where the supplied taxon either is
235 * relatedFrom or relatedTo depending on the <code>direction</code>
239 * The taxon that is relatedFrom
241 * The type of TaxonRelationship (can be null)
243 * specifies the direction of the relationship
244 * @return the number of TaxonRelationship instances
246 public int countTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
247 Direction direction
);
250 * Returns the TaxonRelationships (of where relationship.type == type, if
251 * this argument is supplied) where the supplied taxon either is
252 * relatedFrom or relatedTo depending on the <code>direction</code>
256 * The taxon that is relatedTo
258 * The type of TaxonRelationship (can be null)
260 * The maximum number of relationships returned (can be null for
263 * The offset (in pageSize chunks) from the start of the result
266 * Properties to order by
267 * @param propertyPaths
268 * Properties to initialize in the returned entities, following
269 * the syntax described in
270 * {@link BeanInitializer#initialize(Object, List)}
272 * specifies the direction of the relationship
273 * @return a List of TaxonRelationship instances
275 public List
<TaxonRelationship
> getTaxonRelationships(Taxon taxon
,
276 TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
,
277 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
,
278 Direction direction
);
281 * Returns a count of the SynonymRelationships (of where relationship.type == type,
282 * if this arguement is supplied) where the supplied taxon is relatedTo.
284 * @param taxon The taxon that is relatedTo
285 * @param type The type of SynonymRelationship (can be null)
286 * @return the number of SynonymRelationship instances
288 public int countSynonyms(Taxon taxon
, SynonymRelationshipType type
);
291 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
292 * where the supplied taxon is relatedTo.
294 * @param taxon The taxon that is relatedTo
295 * @param type The type of SynonymRelationship (can be null)
296 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
297 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
298 * * @param orderHints Properties to order by
299 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
300 * @return a List of SynonymRelationship instances
302 public List
<SynonymRelationship
> getSynonyms(Taxon taxon
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
305 * Returns a count of the SynonymRelationships (of where relationship.type == type,
306 * if this arguement is supplied) where the supplied synonym is relatedFrom.
308 * @param taxon The synonym that is relatedFrom
309 * @param type The type of SynonymRelationship (can be null)
310 * @return the number of SynonymRelationship instances
312 public int countSynonyms(Synonym synonym
, SynonymRelationshipType type
);
315 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
316 * where the supplied synonym is relatedFrom.
318 * @param taxon The synonym that is relatedFrom
319 * @param type The type of SynonymRelationship (can be null)
320 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
321 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
322 * * @param orderHints Properties to order by
323 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
324 * @return a List of SynonymRelationship instances
326 public List
<SynonymRelationship
> getSynonyms(Synonym synoynm
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
329 * Returns a count of TaxonBase instances where the
330 * taxon.name properties match the parameters passed.
334 * @param infragenericEpithet
335 * @param specificEpithet
336 * @param infraspecificEpithet
338 * @return a count of TaxonBase instances
340 public int countTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
,String specificEpithet
, String infraspecificEpithet
, Rank rank
);
343 * Returns a list of TaxonBase instances where the
344 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
345 * <i>null</i> will search for those taxa with a value of null in that field
347 * @param clazz optionally filter by class (can be null to return all taxa)
349 * @param infragenericEpithet
350 * @param specificEpithet
351 * @param infraspecificEpithet
353 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
354 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
355 * @return a list of TaxonBase instances
357 public List
<TaxonBase
> findTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
363 public List
<UuidAndTitleCache
<TaxonNode
>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByTaxonomicTree(TaxonomicTree taxonomicTree
);
365 public List
<TaxonBase
> getTaxaByCommonName(String queryString
, TaxonomicTree taxonomicTree
,
366 MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageSize
,
367 Integer pageNumber
, List
<String
> propertyPaths
);
369 * creates all inferred synonyms for the species in the tree and insert it to the database
371 * @return List of inferred synonyms
373 //public List<Synonym> insertAllInferredSynonymy(TaxonomicTree tree);
375 * creates all inferred synonyms for the taxon in the taxonomic tree, but do not insert it to the database
378 * @return list of inferred synonyms
380 public List
<Synonym
> createAllInferredSynonyms(Taxon taxon
, TaxonomicTree tree
);
382 * creates the specified inferred synonyms for the taxon in the taxonomic tree, but do not insert it to the database
385 * @return list of inferred synonyms
387 public List
<Synonym
> createInferredSynonyms(Taxon taxon
, TaxonomicTree tree
, SynonymRelationshipType type
);
389 public List
<TaxonNameBase
> findIdenticalTaxonNames(List
<String
> propertyPath
);
390 public String
getPhylumName(TaxonNameBase name
);
392 public long countTaxaByCommonName(String searchString
,
393 TaxonomicTree taxonomicTree
, MatchMode matchMode
,
394 Set
<NamedArea
> namedAreas
);
396 public long deleteSynonymRelationships(Synonym syn
);
398 public List
<UUID
> findIdenticalTaxonNameIds(List
<String
> propertyPath
);
400 public List
<TaxonNameBase
> findIdenticalNamesNew(List
<String
> propertyPaths
);
403 public Integer
countSynonymRelationships(TaxonBase taxonBase
,
404 SynonymRelationshipType type
, Direction relatedfrom
);
406 public List
<SynonymRelationship
> getSynonymRelationships(TaxonBase taxonBase
,
407 SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
,
408 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
,
409 Direction relatedfrom
);