3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.cdm
.api
.service
;
13 import java
.util
.List
;
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
.MatchMode
;
38 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
41 public interface ITaxonService
extends IIdentifiableEntityService
<TaxonBase
>{
44 * Computes all taxon bases.
45 * FIXME could substitute with list(Synonym.class, limit, start)
50 public List
<Synonym
> getAllSynonyms(int limit
, int start
);
53 * Computes all taxon bases.
54 * FIXME could substitute with list(Taxon.class, limit,start)
59 public List
<Taxon
> getAllTaxa(int limit
, int start
);
62 * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
63 * @param sec The concept reference that the taxon belongs to
64 * @return The List<Taxon> of root taxa.
65 * @deprecated obsolete when using taxonomicTree
67 public List
<Taxon
> getRootTaxa(ReferenceBase sec
);
71 * Computes all Taxon instances that do not have a taxonomic parent.
72 * @param sec The concept reference that the taxon belongs to
74 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
75 * @return The List<Taxon> of root taxa.
76 * @deprecated obsolete when using taxonomicTree
78 public List
<Taxon
> getRootTaxa(ReferenceBase sec
, CdmFetch cdmFetch
, boolean onlyWithChildren
);
81 * Computes all Taxon instances that do not have a taxonomic parent.
82 * @param sec The concept reference that the taxon belongs to
83 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
84 * @param withMisapplications if false taxa that have at least one misapplied name relationship in which they are
85 * the misapplied name are not returned.<Br>Default: true.
86 * @return The List<Taxon> of root taxa.
87 * @deprecated obsolete when using taxonomicTree
89 public List
<Taxon
> getRootTaxa(ReferenceBase sec
, boolean onlyWithChildren
, boolean withMisapplications
);
92 * Computes all Taxon instances which name is of a certain Rank.
93 * @param rank The rank of the taxon name
94 * @param sec The concept reference that the taxon belongs to
95 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
96 * @param withMisapplications if false taxa that have at least one misapplied name relationship in which they are
97 * the misapplied name are not returned.<Br>Default: true.
98 * @param propertyPaths
99 * properties to be initialized, For detailed description and
100 * examples <b>please refer to:</b>
101 * {@link BeanInitializer#initialize(Object, List)}. <Br>
103 * @return The List<Taxon> of root taxa.
104 * @deprecated obsolete when using taxonomicTree
106 public List
<Taxon
> getRootTaxa(Rank rank
, ReferenceBase sec
, boolean onlyWithChildren
, boolean withMisapplications
, List
<String
> propertyPaths
);
109 * Computes all relationships.
114 public List
<RelationshipBase
> getAllRelationships(int limit
, int start
);
117 * Returns TaxonRelationshipType vocabulary
119 * @deprecated use TermService#getVocabulary(VocabularyType) instead
121 public OrderedTermVocabulary
<TaxonRelationshipType
> getTaxonRelationshipTypeVocabulary();
124 * Returns a list of taxa that matches the name string and the sec reference
125 * @param name the name string to search for
126 * @param sec the taxons sec reference
127 * @return a list of taxa matching the name and the sec reference
129 public List
<TaxonBase
> searchTaxaByName(String name
, ReferenceBase sec
);
132 * Changes an accepted taxon to a synonym of another taxon.
134 * @param oldTaxonNode
135 * the <code>TaxonNode</code> of the accepted taxon that will be changed into a synonym
136 * @param newAcceptedTaxonNode
137 * the <code>TaxonNode</code> of the accepted taxon, the old taxon will become a synonym of
139 * <code>SynonymRelationshipType</code> to indicate whether hetero or homotypic
141 * the reference for this assumption
142 * @param citationMicroReference
145 * the newly created synonym
147 public Synonym
changeAcceptedTaxonToSynonym (TaxonNode oldTaxonNode
, TaxonNode newAcceptedTaxonNode
, SynonymRelationshipType synonymType
, ReferenceBase citation
, String citationMicroReference
);
150 * Swaps given synonym and accepted taxon.
153 * <li>A new accepted taxon with the synonyms name is created</li>
154 * <li>The synonym is deleted from the old accepted taxons synonym list</li>
155 * <li>A new synonym with the name of the old accepted taxon is created</li>
156 * <li>The newly created synonym get related to the newly created accepted taxon</li>
160 * @param acceptedTaxon
161 * @param synonymRelationshipType the relationship type the newly created synonym will have. Defaults to SYNONYM_OF
163 public void swapSynonymAndAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
);
166 * Change a synonym into an accepted taxon and removes
167 * the synonym relationship to the given accepted taxon.
170 * the synonym to change into an accepted taxon
171 * @param acceptedTaxon
172 * an accepted taxon, the synonym had a relationship to
174 * the newly created accepted taxon
176 public Taxon
changeSynonymToAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
);
179 * Change a synonym into a related concept
182 * the synonym to change into the concept taxon
184 * the taxon the newly created concept should be related to
185 * @param taxonRelationshipType
186 * the type of relationship
188 * @param microcitation
190 * the newly created concept
192 public Taxon
changeSynonymToRelatedTaxon(Synonym synonym
, Taxon toTaxon
, TaxonRelationshipType taxonRelationshipType
, ReferenceBase citation
, String microcitation
);
195 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
196 * where the supplied taxon is relatedTo.
198 * @param taxon The taxon that is relatedTo
199 * @param type The type of TaxonRelationship (can be null)
200 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
201 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
202 * @param orderHints Properties to order by
203 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
204 * @return a List of TaxonRelationship instances
206 public List
<TaxonRelationship
> listToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
211 * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
212 * where the supplied taxon is relatedTo.
214 * @param taxon The taxon that is relatedTo
215 * @param type The type of TaxonRelationship (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 * @param orderHints Properties to order by
219 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
220 * @return a Pager of TaxonRelationship instances
222 public Pager
<TaxonRelationship
> pageToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
225 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
226 * where the supplied taxon is relatedFrom.
228 * @param taxon The taxon that is relatedFrom
229 * @param type The type of TaxonRelationship (can be null)
230 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
231 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
232 * @param orderHints Properties to order by
233 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
234 * @return a List of TaxonRelationship instances
236 public List
<TaxonRelationship
> listFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
240 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
241 * where the supplied taxon is relatedFrom.
243 * @param taxon The taxon that is relatedFrom
244 * @param type The type of TaxonRelationship (can be null)
245 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
246 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
247 * @param orderHints Properties to order by
248 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
249 * @return a Pager of TaxonRelationship instances
251 public Pager
<TaxonRelationship
> pageFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
254 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
255 * where the supplied synonym is relatedFrom.
257 * @param taxon The synonym that is relatedFrom
258 * @param type The type of SynonymRelationship (can be null)
259 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
260 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
261 * * @param orderHints Properties to order by
262 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
263 * @return a Pager of SynonymRelationship instances
265 public Pager
<SynonymRelationship
> getSynonyms(Synonym synonym
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
268 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
269 * where the supplied taxon is relatedTo.
271 * @param taxon The taxon that is relatedTo
272 * @param type The type of SynonymRelationship (can be null)
273 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
274 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
275 * * @param orderHints Properties to order by
276 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
277 * @return a Pager of SynonymRelationship instances
279 public Pager
<SynonymRelationship
> getSynonyms(Taxon taxon
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
281 public List
<Synonym
> getHomotypicSynonymsByHomotypicGroup(Taxon taxon
, List
<String
> propertyPaths
);
283 public List
<List
<Synonym
>> getHeterotypicSynonymyGroups(Taxon taxon
, List
<String
> propertyPaths
);
286 * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
288 * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
290 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
291 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
293 * Supports path like <code>orderHints.propertyNames</code> which
294 * include *-to-one properties like createdBy.username or
295 * authorTeam.persistentTitleCache
296 * @param propertyPaths properties to be initialized
297 * @return a Pager Taxon instances
298 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
300 public Pager
<TaxonBase
> search(Class
<?
extends TaxonBase
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
303 * Returns a list of TaxonBase instances where the
304 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
305 * <i>null</i> will search for those taxa with a value of null in that field
307 * @param clazz optionally filter by class (can be null to return all taxa)
309 * @param infragenericEpithet
310 * @param specificEpithet
311 * @param infraspecificEpithet
313 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
314 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
315 * @return a list of TaxonBase instances
317 public Pager
<TaxonBase
> findTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
320 * Returns a list of TaxonBase instances where the
321 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
322 * <i>null</i> will search for those taxa with a value of null in that field
324 * @param clazz optionally filter by class
326 * @param infragenericEpithet
327 * @param specificEpithet
328 * @param infraspecificEpithet
330 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
331 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
332 * @return a List of TaxonBase instances
334 public List
<TaxonBase
> listTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
337 * Returns a list of IdentifiableEntity instances (in particular, TaxonNameBase and TaxonBase instances)
338 * that match the properties specified in the configurator.
339 * @param configurator
342 public Pager
<IdentifiableEntity
> findTaxaAndNames(ITaxonServiceConfigurator configurator
);
349 * @param widthOrDuration
353 public List
<MediaRepresentation
> getAllMedia(Taxon taxon
, int size
, int height
, int widthOrDuration
, String
[] mimeTypes
);
355 public List
<TaxonBase
> findTaxaByID(Set
<Integer
> listOfIDs
);
357 * returns a list of inferred synonyms concerning the taxon with synonymrelationshiptype type
363 public List
<Synonym
> createInferredSynonyms(TaxonomicTree tree
, Taxon taxon
, SynonymRelationshipType type
);
365 * returns a list of all inferred synonyms (inferred epithet, inferred genus and potential combination) concerning the taxon
370 public List
<Synonym
> createAllInferredSynonyms(TaxonomicTree tree
, Taxon taxon
);
372 public int countAllRelationships();
374 public List
<TaxonNameBase
> findIdenticalTaxonNames(List
<String
> propertyPath
);
375 public List
<TaxonNameBase
> findIdenticalTaxonNameIds(List
<String
> propertyPath
);
376 public String
getPhylumName(TaxonNameBase name
);
378 public long deleteSynonymRelationships(Synonym syn
);
380 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
381 * depending on direction, where the supplied taxon is relatedTo or the supplied synonym is relatedFrom.
383 * @param taxonBase The taxon or synonym that is relatedTo or relatedFrom
384 * @param type The type of SynonymRelationship (can be null)
385 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
386 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
387 * @param orderHints Properties to order by
388 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
389 * @param direction The direction of the relationship
390 * @return a List of SynonymRelationship instances
392 public List
<SynonymRelationship
> listSynonymRelationships(
393 TaxonBase taxonBase
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
,
394 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
, Direction direction
);
400 public Taxon
findBestMatchingTaxon(String taxonName
);
402 public Synonym
findBestMatchingSynonym(String taxonName
);