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.
87 * @param classification TODO
89 * @param namedAreas TODO
92 * @param propertyPaths TODO
93 * @return list of found taxa
95 public List
<TaxonBase
> getTaxaByName(boolean doTaxa
, boolean doSynonyms
, boolean doMisappliedNames
, String queryString
, Classification classification
,
96 MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
);
102 * @param classification TODO
107 * @param propertyPaths
110 public long countTaxaByName(boolean doTaxa
, boolean doSynonyms
, boolean doMisappliedNames
, String queryString
, Classification classification
,
112 MatchMode matchMode
, Set
<NamedArea
> namedAreas
);
115 // * @param queryString
116 // * @param matchMode
120 // public Integer countTaxaByName(String queryString, MatchMode matchMode,
121 // Boolean accepted);
124 // * Returns a count of TaxonBase instances where the
125 // * taxon.name properties match the parameters passed.
127 // * @param queryString search string
128 // * @param matchMode way how search string shall be matched: exact, beginning, or anywhere
129 // * @param selectModel all taxon base, taxa, or synonyms
131 // public Integer countTaxaByName(String queryString, MatchMode matchMode, SelectMode selectMode);
134 * Returns a count of TaxonBase instances where the
135 * taxon.name properties match the parameters passed.
140 * @param infragenericEpithet
141 * @param specificEpithet
142 * @param infraspecificEpithet
144 * @return a count of TaxonBase instances
146 public int countTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
,String specificEpithet
, String infraspecificEpithet
, Rank rank
);
149 * Returns a list of TaxonBase instances where the
150 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
151 * <i>null</i> will search for those taxa with a value of null in that field
154 * {@link #findByName(String, MatchMode, int, int, boolean)}
155 * which searches for {@link TaxonNameBase}<strong><code>.titleCache</code>
161 * @param infragenericEpithet
162 * @param specificEpithet
163 * @param infraspecificEpithet
165 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
166 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
167 * @return a list of TaxonBase instances
169 public List
<TaxonBase
> findTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
172 * Find taxa by searching for Taxa and Synonyms where the
173 * {@link TaxonNameBase}<strong><code>.titleCache</code></strong> matches
174 * the name specified as queryString <code>taxonName</code>
177 * {@link #findTaxaByName(Class, String, String, String, String, Rank, Integer, Integer)}
178 * which searches for {@link TaxonNameBase}<strong><code>.nameCache</code>
181 * the taqxon Name to search for
182 * @param classification TODO
184 * @param namedAreas TODO
187 * @param onlyAcccepted
190 public List
<TaxonBase
> findByNameTitleCache(boolean doTaxa
, boolean doSynonyms
, String queryString
, Classification classification
, MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageNumber
, Integer pageSize
, List
<String
> propertyPaths
) ;
193 * Returns a taxon corresponding to the given uuid
196 * The uuid of the taxon requested
198 * Custom criteria to be added to the default list of applied criteria.
199 * @param propertyPaths
203 public TaxonBase
findByUuid(UUID uuid
, List
<Criterion
> criteria
, List
<String
> propertyPaths
);
207 * @param classification
212 * @param propertyPaths
213 * @return A List of arrays. Each entry array holds the following entities: Taxon, CommonName, Description, Feature
215 public List
<Object
[]> getTaxaByCommonName(String queryString
, Classification classification
,
216 MatchMode matchMode
, Set
<NamedArea
> namedAreas
, Integer pageSize
,
217 Integer pageNumber
, List
<String
> propertyPaths
);
221 * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
222 * @return The List<Taxon> of root taxa.
223 * @deprecated obsolete when using classification
225 public List
<Taxon
> getRootTaxa(Reference sec
);
229 * Computes all Taxon instances that do not have a taxonomic parent.
230 * @param sec The concept reference that the taxon belongs to
231 * @param cdmFetch not used yet !! TODO
232 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
233 * @param withMisaplications if false only taxa are returned that have no isMisappliedNameFor relationship.
235 * @return The List<Taxon> of root taxa.
236 * @deprecated obsolete when using classification
238 public List
<Taxon
> getRootTaxa(Reference sec
, CdmFetch cdmFetch
, Boolean onlyWithChildren
, Boolean withMisapplications
);
242 * Computes all Taxon instances which name is of a certain Rank.
245 * The rank of the taxon name
247 * The concept reference that the taxon belongs to
249 * not used yet !! TODO
250 * @param onlyWithChildren
251 * if true only taxa are returned that have taxonomic children. <Br>
253 * @param withMisaplications
254 * if false only taxa are returned that have no
255 * isMisappliedNameFor relationship.
256 * @param propertyPaths
257 * properties to be initialized, For detailed description and
258 * examples <b>please refer to:</b>
259 * {@link BeanInitializer#initialize(Object, List)}. <Br>
261 * @return The List<Taxon> of root taxa.
262 * @deprecated obsolete when using classification
265 getRootTaxa(Rank rank
, Reference sec
, CdmFetch cdmFetch
, Boolean onlyWithChildren
, Boolean withMisapplications
, List
<String
> propertyPaths
);
269 * @param pagesize max maximum number of returned taxa
270 * @param page page to start, with 0 being first page
273 public List
<TaxonBase
> getAllTaxonBases(Integer pagesize
, Integer page
);
281 public List
<Taxon
> getAllTaxa(Integer limit
, Integer start
);
288 public List
<Synonym
> getAllSynonyms(Integer limit
, Integer start
);
290 public List
<RelationshipBase
> getAllRelationships(Integer limit
, Integer start
);
292 public int countAllRelationships();
297 * @param onlyAcccepted
300 public int countMatchesByName(String queryString
, MatchMode matchMode
, boolean onlyAcccepted
);
305 * @param onlyAcccepted
309 public int countMatchesByName(String queryString
, MatchMode matchMode
, boolean onlyAcccepted
, List
<Criterion
> criteria
);
312 * Returns a count of the TaxonRelationships (of where relationship.type ==
313 * type, if this argument is supplied) where the supplied taxon either is
314 * relatedFrom or relatedTo depending on the <code>direction</code>
318 * The taxon that is relatedFrom
320 * The type of TaxonRelationship (can be null)
322 * specifies the direction of the relationship
323 * @return the number of TaxonRelationship instances
325 public int countTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
,
326 Direction direction
);
329 * Returns the TaxonRelationships (of where relationship.type == type, if
330 * this argument is supplied) where the supplied taxon either is
331 * relatedFrom or relatedTo depending on the <code>direction</code>
335 * The taxon that is relatedTo
337 * The type of TaxonRelationship (can be null)
339 * The maximum number of relationships returned (can be null for
342 * The offset (in pageSize chunks) from the start of the result
345 * Properties to order by
346 * @param propertyPaths
347 * Properties to initialize in the returned entities, following
348 * the syntax described in
349 * {@link BeanInitializer#initialize(Object, List)}
351 * specifies the direction of the relationship
352 * @return a List of TaxonRelationship instances
354 public List
<TaxonRelationship
> getTaxonRelationships(Taxon taxon
,
355 TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
,
356 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
,
357 Direction direction
);
360 * Returns a count of the SynonymRelationships (of where relationship.type == type,
361 * if this arguement is supplied) where the supplied taxon is relatedTo.
363 * @param taxon The taxon that is relatedTo
364 * @param type The type of SynonymRelationship (can be null)
365 * @return the number of SynonymRelationship instances
367 public int countSynonyms(Taxon taxon
, SynonymRelationshipType type
);
370 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
371 * 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 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
376 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
377 * * @param orderHints Properties to order by
378 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
379 * @return a List of SynonymRelationship instances
381 public List
<SynonymRelationship
> getSynonyms(Taxon taxon
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
384 * Returns a count of the SynonymRelationships (of where relationship.type == type,
385 * if this arguement is supplied) where the supplied synonym is relatedFrom.
387 * @param taxon The synonym that is relatedFrom
388 * @param type The type of SynonymRelationship (can be null)
389 * @return the number of SynonymRelationship instances
391 public int countSynonyms(Synonym synonym
, SynonymRelationshipType type
);
394 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
395 * 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 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
400 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
401 * * @param orderHints Properties to order by
402 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
403 * @return a List of SynonymRelationship instances
405 public List
<SynonymRelationship
> getSynonyms(Synonym synoynm
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
411 public List
<UuidAndTitleCache
<TaxonNode
>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(Classification classification
);
414 * Creates all inferred synonyms for the species in the tree and insert it to the database
416 * @return List of inferred synonyms
418 //public List<Synonym> insertAllInferredSynonymy(Classification tree);
422 public List
<TaxonNameBase
> findIdenticalTaxonNames(List
<String
> propertyPath
);
423 public String
getPhylumName(TaxonNameBase name
);
425 public long countTaxaByCommonName(String searchString
,
426 Classification classification
, MatchMode matchMode
,
427 Set
<NamedArea
> namedAreas
);
430 * Deletes all synonym relationships of a given synonym.
431 * If taxon is given only those relationships to the taxon
433 * @param synonym the synonym
434 * @param taxon the taxon, may be <code>null</code>
437 public long deleteSynonymRelationships(Synonym syn
, Taxon taxon
);
439 public List
<UUID
> findIdenticalTaxonNameIds(List
<String
> propertyPath
);
441 public List
<TaxonNameBase
> findIdenticalNamesNew(List
<String
> propertyPaths
);
444 public Integer
countSynonymRelationships(TaxonBase taxonBase
,
445 SynonymRelationshipType type
, Direction relatedfrom
);
447 public List
<SynonymRelationship
> getSynonymRelationships(TaxonBase taxonBase
,
448 SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
,
449 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
,
450 Direction relatedfrom
);
455 public List
<UuidAndTitleCache
<TaxonBase
>> getUuidAndTitleCacheTaxon();
460 public List
<UuidAndTitleCache
<TaxonBase
>> getUuidAndTitleCacheSynonym();
462 public List
<UuidAndTitleCache
<TaxonBase
>> getTaxaByNameForEditor(boolean doTaxa
, boolean doSynonyms
, String queryString
, Classification classification
,
463 MatchMode matchMode
, Set
<NamedArea
> namedAreas
);
465 public List
<String
> taxaByNameNotInDB(List
<String
> taxonNames
);