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 org
.hibernate
.criterion
.Criterion
;
16 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
;
17 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
18 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
26 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.IIdentifiableDao
;
27 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.ITitledDao
;
28 import eu
.etaxonomy
.cdm
.persistence
.fetch
.CdmFetch
;
34 public interface ITaxonDao
extends IIdentifiableDao
<TaxonBase
>, ITitledDao
<TaxonBase
> {
37 * Returns a count of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false)
38 * where the taxonBase.name.nameCache property matches the String queryString
43 * @return a count of the matching taxa
45 public int countTaxaByName(String queryString
, Boolean accepted
, ReferenceBase sec
);
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
, ReferenceBase 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
, ReferenceBase sec
);
66 * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
67 * @return The List<Taxon> of root taxa.
69 public List
<Taxon
> getRootTaxa(ReferenceBase sec
);
73 * Computes all Taxon instances that do not have a taxonomic parent.
74 * @param sec The concept reference that the taxon belongs to
75 * @param cdmFetch not used yet !! TODO
76 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
77 * @param withMisaplications if false only taxa are returned that have no isMisappliedNameFor relationship.
79 * @return The List<Taxon> of root taxa.
81 public List
<Taxon
> getRootTaxa(ReferenceBase sec
, CdmFetch cdmFetch
, Boolean onlyWithChildren
, Boolean withMisapplications
);
86 * @param pagesize max maximum number of returned taxa
87 * @param page page to start, with 0 being first page
90 public List
<TaxonBase
> getAllTaxonBases(Integer pagesize
, Integer page
);
98 public List
<Taxon
> getAllTaxa(Integer limit
, Integer start
);
105 public List
<Synonym
> getAllSynonyms(Integer limit
, Integer start
);
112 //public List<TaxonRelationship> getAllTaxonRelationships(Integer limit, Integer start);
119 //public List<SynonymRelationship> getAllSynonymRelationships(Integer limit, Integer start);
121 public List
<RelationshipBase
> getAllRelationships(Integer limit
, Integer start
);
124 * Find taxa by searching for @{link NameBase}
129 * @param onlyAcccepted
132 public List
<Taxon
> findByName(String queryString
, ITitledDao
.MATCH_MODE matchMode
, int page
, int pagesize
, boolean onlyAcccepted
);
137 * @param onlyAcccepted
140 public int countMatchesByName(String queryString
, ITitledDao
.MATCH_MODE matchMode
, boolean onlyAcccepted
);
145 * @param onlyAcccepted
149 public int countMatchesByName(String queryString
, ITitledDao
.MATCH_MODE matchMode
, boolean onlyAcccepted
, List
<Criterion
> criteria
);
152 * Returns a count of the TaxonRelationships (of where relationship.type == type,
153 * if this arguement is supplied) where the supplied taxon is relatedFrom.
155 * @param taxon The taxon that is relatedFrom
156 * @param type The type of TaxonRelationship (can be null)
157 * @return the number of TaxonRelationship instances
159 public int countRelatedTaxa(Taxon taxon
, TaxonRelationshipType type
);
162 * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
163 * where the supplied taxon is relatedTo.
165 * @param taxon The taxon that is relatedTo
166 * @param type The type of TaxonRelationship (can be null)
167 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
168 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
169 * @return a List of TaxonRelationship instances
171 public List
<TaxonRelationship
> getRelatedTaxa(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
);
174 * Returns a count of the SynonymRelationships (of where relationship.type == type,
175 * if this arguement is supplied) where the supplied taxon is relatedTo.
177 * @param taxon The taxon that is relatedTo
178 * @param type The type of SynonymRelationship (can be null)
179 * @return the number of SynonymRelationship instances
181 public int countSynonyms(Taxon taxon
, SynonymRelationshipType type
);
184 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied)
185 * where the supplied taxon is relatedTo.
187 * @param taxon The taxon that is relatedTo
188 * @param type The type of SynonymRelationship (can be null)
189 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
190 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
191 * @return a List of SynonymRelationship instances
193 public List
<SynonymRelationship
> getSynonyms(Taxon taxon
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
);
196 * Returns a count of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false) where the
197 * taxonBase.name.nameCache property matches the String queryString (as interpreted by the Lucene QueryParser)
201 * @return a count of the matching taxa
202 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
204 public int countTaxa(String queryString
, Boolean accepted
);
207 * Returns a List of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false) where the
208 * taxonBase.name.nameCache property matches the String queryString (as interpreted by the Lucene QueryParser)
212 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
213 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
214 * @return a List Taxon instances
215 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
217 public List
<TaxonBase
> searchTaxa(String queryString
, Boolean accepted
, Integer pageSize
, Integer pageNumber
);
220 * Returns a count of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false) where the
221 * taxon.name properties match the parameters passed.
225 * @param infragenericEpithet
226 * @param specificEpithet
227 * @param infraspecificEpithet
229 * @return a count of TaxonBase instances
231 public int countTaxaByName(Boolean accepted
, String uninomial
, String infragenericEpithet
,String specificEpithet
, String infraspecificEpithet
, Rank rank
);
234 * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false) where the
235 * taxon.name properties match the parameters passed.
237 * @param accepted Whether the taxon is accepted (true) a synonym (false), or either (null)
239 * @param infragenericEpithet
240 * @param specificEpithet
241 * @param infraspecificEpithet
243 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
244 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
245 * @return a list of TaxonBase instances
247 public List
<TaxonBase
> findTaxaByName(Boolean accepted
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
250 * Suggest a query that will return hits based upon an existing lucene query string (that is presumably misspelt and returns no hits)
251 * Used to implement "did you mean?"-type functionality using the lucene spellchecker.
253 * @param string Query string to check
254 * @return a suggested query string that will return hits or null if no such alternative spelling can be found.
256 public String
suggestQuery(String string
);
259 * Removes all TaxonBase entities from the index
261 public void purgeIndex();
264 * Index all TaxonBase entities currenly in the database (useful in concert with purgeIndex() to (re-)create
265 * indexes or in the case of corrupt indexes / mismatch between
266 * the database and the free-text indices)
268 public void rebuildIndex();
271 * Calls optimize on the relevant index (useful periodically to increase response times on the free-text search)
273 public void optimizeIndex();