Copied header text from dao operation to service operation for listTaxaByName()
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / ITaxonService.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.cdm.api.service;
12
13 import java.util.List;
14 import java.util.Set;
15
16 import eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator;
17 import eu.etaxonomy.cdm.api.service.pager.Pager;
18 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
19 import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
20 import eu.etaxonomy.cdm.model.common.RelationshipBase;
21 import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;
22 import eu.etaxonomy.cdm.model.media.MediaRepresentation;
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.fetch.CdmFetch;
37 import eu.etaxonomy.cdm.persistence.query.OrderHint;
38
39
40 public interface ITaxonService extends IIdentifiableEntityService<TaxonBase>{
41
42 /**
43 * Computes all taxon bases.
44 * FIXME could substitute with list(Synonym.class, limit, start)
45 * @param limit
46 * @param start
47 * @return
48 */
49 public List<Synonym> getAllSynonyms(int limit, int start);
50
51 /**
52 * Computes all taxon bases.
53 * FIXME could substitute with list(Taxon.class, limit,start)
54 * @param limit
55 * @param start
56 * @return
57 */
58 public List<Taxon> getAllTaxa(int limit, int start);
59
60 /**
61 * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
62 * @param sec The concept reference that the taxon belongs to
63 * @return The List<Taxon> of root taxa.
64 * @deprecated obsolete when using taxonomicTree
65 */
66 public List<Taxon> getRootTaxa(ReferenceBase sec);
67
68
69 /**
70 * Computes all Taxon instances that do not have a taxonomic parent.
71 * @param sec The concept reference that the taxon belongs to
72 *
73 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
74 * @return The List<Taxon> of root taxa.
75 * @deprecated obsolete when using taxonomicTree
76 */
77 public List<Taxon> getRootTaxa(ReferenceBase sec, CdmFetch cdmFetch, boolean onlyWithChildren);
78
79 /**
80 * Computes all Taxon instances that do not have a taxonomic parent.
81 * @param sec The concept reference that the taxon belongs to
82 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
83 * @param withMisapplications if false taxa that have at least one misapplied name relationship in which they are
84 * the misapplied name are not returned.<Br>Default: true.
85 * @return The List<Taxon> of root taxa.
86 * @deprecated obsolete when using taxonomicTree
87 */
88 public List<Taxon> getRootTaxa(ReferenceBase sec, boolean onlyWithChildren, boolean withMisapplications);
89
90 /**
91 * Computes all Taxon instances which name is of a certain Rank.
92 * @param rank The rank of the taxon name
93 * @param sec The concept reference that the taxon belongs to
94 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
95 * @param withMisapplications if false taxa that have at least one misapplied name relationship in which they are
96 * the misapplied name are not returned.<Br>Default: true.
97 * @param propertyPaths
98 * properties to be initialized, For detailed description and
99 * examples <b>please refer to:</b>
100 * {@link BeanInitializer#initialize(Object, List)}. <Br>
101 * Default: true.
102 * @return The List<Taxon> of root taxa.
103 * @deprecated obsolete when using taxonomicTree
104 */
105 public List<Taxon> getRootTaxa(Rank rank, ReferenceBase sec, boolean onlyWithChildren, boolean withMisapplications, List<String> propertyPaths);
106
107 /**
108 * Computes all relationships.
109 * @param limit
110 * @param start
111 * @return
112 */
113 public List<RelationshipBase> getAllRelationships(int limit, int start);
114
115 /**
116 * Returns TaxonRelationshipType vocabulary
117 * @return
118 * @deprecated use TermService#getVocabulary(VocabularyType) instead
119 */
120 public OrderedTermVocabulary<TaxonRelationshipType> getTaxonRelationshipTypeVocabulary();
121
122 /**
123 * Returns a list of taxa that matches the name string and the sec reference
124 * @param name the name string to search for
125 * @param sec the taxons sec reference
126 * @return a list of taxa matching the name and the sec reference
127 */
128 public List<TaxonBase> searchTaxaByName(String name, ReferenceBase sec);
129
130 /**
131 * Changes an accepted taxon to a synonym of another taxon.
132 *
133 * @param oldTaxonNode
134 * the <code>TaxonNode</code> of the accepted taxon that will be changed into a synonym
135 * @param newAcceptedTaxonNode
136 * the <code>TaxonNode</code> of the accepted taxon, the old taxon will become a synonym of
137 * @param synonymType
138 * <code>SynonymRelationshipType</code> to indicate whether hetero or homotypic
139 * @param citation
140 * the reference for this assumption
141 * @param citationMicroReference
142 * the micro citation
143 * @return
144 * the newly created synonym
145 */
146 public Synonym changeAcceptedTaxonToSynonym (TaxonNode oldTaxonNode, TaxonNode newAcceptedTaxonNode, SynonymRelationshipType synonymType, ReferenceBase citation, String citationMicroReference);
147
148 /**
149 * Swaps given synonym and accepted taxon.
150 * In particular:
151 * <ul>
152 * <li>A new accepted taxon with the synonyms name is created</li>
153 * <li>The synonym is deleted from the old accepted taxons synonym list</li>
154 * <li>A new synonym with the name of the old accepted taxon is created</li>
155 * <li>The newly created synonym get related to the newly created accepted taxon</li>
156 * </ul>
157 *
158 * @param synonym
159 * @param acceptedTaxon
160 * @param synonymRelationshipType the relationship type the newly created synonym will have. Defaults to SYNONYM_OF
161 */
162 public void swapSynonymAndAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon);
163
164 /**
165 * Change a synonym into an accepted taxon and removes
166 * the synonym relationship to the given accepted taxon.
167 *
168 * @param synonym
169 * the synonym to change into an accepted taxon
170 * @param acceptedTaxon
171 * an accepted taxon, the synonym had a relationship to
172 * @return
173 * the newly created accepted taxon
174 */
175 public Taxon changeSynonymToAcceptedTaxon(Synonym synonym, Taxon acceptedTaxon);
176
177 /**
178 * Change a synonym into a related concept
179 *
180 * @param synonym
181 * the synonym to change into the concept taxon
182 * @param toTaxon
183 * the taxon the newly created concept should be related to
184 * @param taxonRelationshipType
185 * the type of relationship
186 * @param citation
187 * @param microcitation
188 * @return
189 * the newly created concept
190 */
191 public Taxon changeSynonymToRelatedTaxon(Synonym synonym, Taxon toTaxon, TaxonRelationshipType taxonRelationshipType, ReferenceBase citation, String microcitation);
192
193 /**
194 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
195 * where the supplied taxon is relatedTo.
196 *
197 * @param taxon The taxon that is relatedTo
198 * @param type The type of TaxonRelationship (can be null)
199 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
200 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
201 * @param orderHints Properties to order by
202 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
203 * @return a List of TaxonRelationship instances
204 */
205 public List<TaxonRelationship> listToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
206
207
208
209 /**
210 * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
211 * where the supplied taxon is relatedTo.
212 *
213 * @param taxon The taxon that is relatedTo
214 * @param type The type of TaxonRelationship (can be null)
215 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
216 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
217 * @param orderHints Properties to order by
218 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
219 * @return a Pager of TaxonRelationship instances
220 */
221 public Pager<TaxonRelationship> pageToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
222
223 /**
224 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
225 * where the supplied taxon is relatedFrom.
226 *
227 * @param taxon The taxon that is relatedFrom
228 * @param type The type of TaxonRelationship (can be null)
229 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
230 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
231 * @param orderHints Properties to order by
232 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
233 * @return a List of TaxonRelationship instances
234 */
235 public List<TaxonRelationship> listFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
236
237
238 /**
239 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
240 * where the supplied taxon is relatedFrom.
241 *
242 * @param taxon The taxon that is relatedFrom
243 * @param type The type of TaxonRelationship (can be null)
244 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
245 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
246 * @param orderHints Properties to order by
247 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
248 * @return a Pager of TaxonRelationship instances
249 */
250 public Pager<TaxonRelationship> pageFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
251
252 /**
253 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
254 * where the supplied synonym is relatedFrom.
255 *
256 * @param taxon The synonym that is relatedFrom
257 * @param type The type of SynonymRelationship (can be null)
258 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
259 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
260 * * @param orderHints Properties to order by
261 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
262 * @return a Pager of SynonymRelationship instances
263 */
264 public Pager<SynonymRelationship> getSynonyms(Synonym synonym, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
265
266 /**
267 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
268 * where the supplied taxon is relatedTo.
269 *
270 * @param taxon The taxon that is relatedTo
271 * @param type The type of SynonymRelationship (can be null)
272 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
273 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
274 * * @param orderHints Properties to order by
275 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
276 * @return a Pager of SynonymRelationship instances
277 */
278 public Pager<SynonymRelationship> getSynonyms(Taxon taxon, SynonymRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
279
280 public List<Synonym> getHomotypicSynonymsByHomotypicGroup(Taxon taxon, List<String> propertyPaths);
281
282 public List<List<Synonym>> getHeterotypicSynonymyGroups(Taxon taxon, List<String> propertyPaths);
283
284 /**
285 * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
286 *
287 * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
288 * @param queryString
289 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
290 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
291 * @param orderHints
292 * Supports path like <code>orderHints.propertyNames</code> which
293 * include *-to-one properties like createdBy.username or
294 * authorTeam.persistentTitleCache
295 * @param propertyPaths properties to be initialized
296 * @return a Pager Taxon instances
297 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
298 */
299 public Pager<TaxonBase> search(Class<? extends TaxonBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths);
300
301 /**
302 * Returns a list of TaxonBase instances where the
303 * taxon.name properties match the parameters passed.
304 *
305 * @param clazz optionally filter by class
306 * @param uninomial
307 * @param infragenericEpithet
308 * @param specificEpithet
309 * @param infraspecificEpithet
310 * @param rank
311 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
312 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
313 * @return a Pager of TaxonBase instances
314 */
315 public Pager<TaxonBase> findTaxaByName(Class<? extends TaxonBase> clazz, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, Rank rank, Integer pageSize, Integer pageNumber);
316
317 /**
318 * Returns a list of TaxonBase instances where the
319 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
320 * <i>null</i> will search for those taxa with a value of null in that field
321 *
322 * @param clazz optionally filter by class
323 * @param uninomial
324 * @param infragenericEpithet
325 * @param specificEpithet
326 * @param infraspecificEpithet
327 * @param rank
328 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
329 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
330 * @return a List of TaxonBase instances
331 */
332 public List<TaxonBase> listTaxaByName(Class<? extends TaxonBase> clazz, String uninomial, String infragenericEpithet, String specificEpithet, String infraspecificEpithet, Rank rank, Integer pageSize, Integer pageNumber);
333
334 /**
335 * Returns a list of IdentifiableEntity instances (in particular, TaxonNameBase and TaxonBase instances)
336 * that match the properties specified in the configurator.
337 * @param configurator
338 * @return
339 */
340 public Pager<IdentifiableEntity> findTaxaAndNames(ITaxonServiceConfigurator configurator);
341
342 /**
343 *
344 * @param taxon
345 * @param size
346 * @param height
347 * @param widthOrDuration
348 * @param mimeTypes
349 * @return
350 */
351 public List<MediaRepresentation> getAllMedia(Taxon taxon, int size, int height, int widthOrDuration, String[] mimeTypes);
352
353 public List<TaxonBase> findTaxaByID(Set<Integer> listOfIDs);
354 /**
355 * returns a list of inferred synonyms concerning the taxon with synonymrelationshiptype type
356 * @param tree
357 * @param taxon
358 * @param type
359 * @return
360 */
361 public List<Synonym> createInferredSynonyms(TaxonomicTree tree, Taxon taxon, SynonymRelationshipType type);
362 /**
363 * returns a list of all inferred synonyms (inferred epithet, inferred genus and potential combination) concerning the taxon
364 * @param tree
365 * @param taxon
366 * @return
367 */
368 public List<Synonym> createAllInferredSynonyms(TaxonomicTree tree, Taxon taxon);
369
370 public int countAllRelationships();
371
372 public List<TaxonNameBase> findIdenticalTaxonNames(List<String> propertyPath);
373 public List<TaxonNameBase> findIdenticalTaxonNameIds(List<String> propertyPath);
374 public String getPhylumName(TaxonNameBase name);
375
376 public long deleteSynonymRelationships(Synonym syn);
377 /**
378 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
379 * depending on direction, where the supplied taxon is relatedTo or the supplied synonym is relatedFrom.
380 *
381 * @param taxonBase The taxon or synonym that is relatedTo or relatedFrom
382 * @param type The type of SynonymRelationship (can be null)
383 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
384 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
385 * @param orderHints Properties to order by
386 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
387 * @param direction The direction of the relationship
388 * @return a List of SynonymRelationship instances
389 */
390 public List<SynonymRelationship> listSynonymRelationships(
391 TaxonBase taxonBase, SynonymRelationshipType type, Integer pageSize, Integer pageNumber,
392 List<OrderHint> orderHints, List<String> propertyPaths, Direction direction);
393 }