Project

General

Profile

Download (11.7 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

    
10
package eu.etaxonomy.cdm.persistence.dao.taxon;
11

    
12
import java.util.List;
13

    
14
import org.hibernate.criterion.Criterion;
15

    
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;
29
import eu.etaxonomy.cdm.persistence.query.MatchMode;
30

    
31
/**
32
 * @author a.mueller
33
 *
34
 */
35
public interface ITaxonDao extends IIdentifiableDao<TaxonBase>, ITitledDao<TaxonBase> {
36
	
37
	/**
38
	 * Returns a count of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false) 
39
	 * where the taxonBase.name.nameCache property matches the String queryString
40
	 * 
41
	 * @param queryString
42
	 * @param accepted
43
	 * @param sec
44
	 * @return a count of the matching taxa
45
	 */
46
	public int countTaxaByName(String queryString, Boolean accepted, ReferenceBase sec);
47

    
48
	/** 
49
	 * Returns a list of TaxonBase instances where the taxon.titleCache property matches the name parameter, 
50
	 * and taxon.sec matches the sec parameter.
51
	 * @param name
52
	 * @param sec
53
	 * @return
54
	 */
55
	public List<TaxonBase> getTaxaByName(String name, ReferenceBase sec);
56
	
57
	/** 
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.
60
	 * @param name
61
	 * @param sec
62
	 * @return
63
	 */
64
	public List<TaxonBase> getTaxaByName(String queryString, Boolean accepted, ReferenceBase sec);
65

    
66
	/** 
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.
69
	 * @param queryString
70
	 * @param matchMode
71
	 * @param accepted
72
	 * @param pageSize
73
	 * @param pageNumber
74
	 * @return
75
	 */
76
	public List<TaxonBase> getTaxaByName(String queryString, MatchMode matchMode, 
77
			Boolean accepted, Integer pageSize, Integer pageNumber);
78
		
79
	/**
80
	 * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
81
	 * @return The List<Taxon> of root taxa.
82
	 */
83
	public List<Taxon> getRootTaxa(ReferenceBase sec);
84

    
85
	
86
	/**
87
	 * Computes all Taxon instances that do not have a taxonomic parent.
88
	 * @param sec The concept reference that the taxon belongs to
89
	 * @param cdmFetch not used yet !! TODO
90
	 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
91
	 * @param withMisaplications if false only taxa are returned that have no isMisappliedNameFor relationship. 
92
	 * <Br>Default: true.
93
	 * @return The List<Taxon> of root taxa.
94
	 */
95
	public List<Taxon> getRootTaxa(ReferenceBase sec, CdmFetch cdmFetch, Boolean onlyWithChildren, Boolean withMisapplications);
96
	
97
	
98
	/**
99
	 * Computes all Taxon instances which name is of a certain Rank.
100
	 * @param rank The rank of the taxon name
101
	 * @param sec The concept reference that the taxon belongs to
102
	 * @param cdmFetch not used yet !! TODO
103
	 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
104
	 * @param withMisaplications if false only taxa are returned that have no isMisappliedNameFor relationship. 
105
	 * <Br>Default: true.
106
	 * @return The List<Taxon> of root taxa.
107
	 */
108
	public List<Taxon> 
109
	getRootTaxa(Rank rank, ReferenceBase sec, CdmFetch cdmFetch, Boolean onlyWithChildren, Boolean withMisapplications);
110

    
111
		/**
112
	 * TODO necessary? 
113
	 * @param pagesize max maximum number of returned taxa
114
	 * @param page page to start, with 0 being first page 
115
	 * @return
116
	 */
117
	public List<TaxonBase> getAllTaxonBases(Integer pagesize, Integer page);
118
	
119
	
120
	/**
121
	 * @param limit
122
	 * @param start 
123
	 * @return
124
	 */
125
	public List<Taxon> getAllTaxa(Integer limit, Integer start);
126

    
127
	/**
128
	 * @param limit
129
	 * @param start 
130
	 * @return
131
	 */
132
	public List<Synonym> getAllSynonyms(Integer limit, Integer start);
133

    
134
	/**
135
	 * @param limit
136
	 * @param start 
137
	 * @return
138
	 */
139
	//public List<TaxonRelationship> getAllTaxonRelationships(Integer limit, Integer start);
140
	
141
	/**
142
	 * @param limit
143
	 * @param start 
144
	 * @return
145
	 */
146
	//public List<SynonymRelationship> getAllSynonymRelationships(Integer limit, Integer start);
147

    
148
	public List<RelationshipBase> getAllRelationships(Integer limit, Integer start); 
149

    
150
	/**
151
	 * Find taxa by searching for @{link NameBase}
152
	 * @param queryString
153
	 * @param matchMode
154
	 * @param page
155
	 * @param pagesize
156
	 * @param onlyAcccepted
157
	 * @return
158
	 */
159
	public List<Taxon> findByName(String queryString, MatchMode matchMode, int page, int pagesize, boolean onlyAcccepted);
160
	
161
	/**
162
	 * @param queryString
163
	 * @param matchMode
164
	 * @param onlyAcccepted
165
	 * @return
166
	 */
167
	public int countMatchesByName(String queryString, MatchMode matchMode, boolean onlyAcccepted);
168
	
169
	/**
170
	 * @param queryString
171
	 * @param matchMode
172
	 * @param onlyAcccepted
173
	 * @param criteria
174
	 * @return
175
	 */
176
	public int countMatchesByName(String queryString, MatchMode matchMode, boolean onlyAcccepted, List<Criterion> criteria);
177
	
178
	/**
179
	 * Returns a count of the TaxonRelationships (of where relationship.type == type,
180
	 *  if this arguement is supplied) where the supplied taxon is relatedFrom.
181
	 * 
182
	 * @param taxon The taxon that is relatedFrom
183
	 * @param type The type of TaxonRelationship (can be null)
184
	 * @return the number of TaxonRelationship instances
185
	 */
186
	public int countRelatedTaxa(Taxon taxon, TaxonRelationshipType type);
187
	
188
	/**
189
	 * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied) 
190
	 * where the supplied taxon is relatedTo.
191
	 * 
192
	 * @param taxon The taxon that is relatedTo
193
	 * @param type The type of TaxonRelationship (can be null)
194
	 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
195
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
196
	 * @return a List of TaxonRelationship instances
197
	 */
198
	public List<TaxonRelationship> getRelatedTaxa(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber);
199
	
200
	/**
201
	 * Returns a count of the SynonymRelationships (of where relationship.type == type,
202
	 *  if this arguement is supplied) where the supplied taxon is relatedTo.
203
	 * 
204
	 * @param taxon The taxon that is relatedTo
205
	 * @param type The type of SynonymRelationship (can be null)
206
	 * @return the number of SynonymRelationship instances
207
	 */
208
	public int countSynonyms(Taxon taxon, SynonymRelationshipType type);
209
	
210
	/**
211
	 * Returns the SynonymRelationships (of where relationship.type == type, if this arguement is supplied) 
212
	 * where the supplied taxon is relatedTo.
213
	 * 
214
	 * @param taxon The taxon that is relatedTo
215
	 * @param type The type of SynonymRelationship (can be null)
216
	 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
217
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
218
	 * @return a List of SynonymRelationship instances
219
	 */
220
	public List<SynonymRelationship> getSynonyms(Taxon taxon, SynonymRelationshipType type, Integer pageSize, Integer pageNumber);
221
	
222
	/**
223
	 * Returns a count of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false) where the 
224
	 * taxonBase.name.nameCache property matches the String queryString (as interpreted by the Lucene QueryParser)
225
	 * 
226
	 * @param queryString
227
	 * @param accepted
228
	 * @return a count of the matching taxa
229
	 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
230
	 */
231
	public int countTaxa(String queryString, Boolean accepted);
232
	
233
	/**
234
	 * Returns a List of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false) where the 
235
	 * taxonBase.name.nameCache property matches the String queryString (as interpreted by the Lucene QueryParser)
236
	 * 
237
	 * @param queryString
238
	 * @param accepted
239
	 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
240
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
241
	 * @return a List Taxon instances
242
	 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
243
	 */
244
	public List<TaxonBase> searchTaxa(String queryString, Boolean accepted, Integer pageSize, Integer pageNumber);
245
	
246
	/**
247
	 * Returns a count of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false) where the
248
	 * taxon.name properties match the parameters passed.
249
	 * 
250
	 * @param accepted
251
	 * @param uninomial
252
	 * @param infragenericEpithet
253
	 * @param specificEpithet
254
	 * @param infraspecificEpithet
255
	 * @param rank
256
	 * @return a count of TaxonBase instances
257
	 */
258
	public int countTaxaByName(Boolean accepted, String uninomial, String infragenericEpithet,String specificEpithet, String infraspecificEpithet, Rank rank);
259
	
260
	/**
261
	 * Returns a list of TaxonBase instances (or Taxon instances, if accepted == true, or Synonym instance, if accepted == false) where the
262
	 * taxon.name properties match the parameters passed.
263
	 * 
264
	 * @param accepted Whether the taxon is accepted (true) a synonym (false), or either (null)
265
	 * @param uninomial 
266
	 * @param infragenericEpithet
267
	 * @param specificEpithet
268
	 * @param infraspecificEpithet
269
	 * @param rank
270
	 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
271
	 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
272
	 * @return a list of TaxonBase instances
273
	 */
274
	public List<TaxonBase> findTaxaByName(Boolean accepted, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, Rank rank, Integer pageSize, Integer pageNumber);
275

    
276
	/**
277
	 * Suggest a query that will return hits based upon an existing lucene query string (that is presumably misspelt and returns no hits)
278
	 * Used to implement "did you mean?"-type functionality using the lucene spellchecker.
279
	 * 
280
	 * @param string Query string to check
281
	 * @return a suggested query string that will return hits or null if no such alternative spelling can be found.
282
	 */
283
	public String suggestQuery(String string);
284
	
285
	/**
286
	 * Removes all TaxonBase entities from the index
287
	 */
288
	public void purgeIndex();
289

    
290
	/**
291
	 * Index all TaxonBase entities currenly in the database (useful in concert with purgeIndex() to (re-)create
292
	 * indexes or in the  case of corrupt indexes / mismatch between 
293
	 * the database and the free-text indices) 
294
	 */
295
	public void rebuildIndex();
296
	
297
	/**
298
	 * Calls optimize on the relevant index (useful periodically to increase response times on the free-text search)
299
	 */
300
	public void optimizeIndex();
301
}
    (1-1/1)