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
;
15 import java
.util
.UUID
;
17 import eu
.etaxonomy
.cdm
.api
.service
.config
.ITaxonServiceConfigurator
;
18 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
19 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
20 import eu
.etaxonomy
.cdm
.model
.common
.OrderedTermVocabulary
;
21 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
;
22 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
.Direction
;
23 import eu
.etaxonomy
.cdm
.model
.media
.MediaRepresentation
;
24 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
25 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
26 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
27 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationship
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
31 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
32 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
33 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
34 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
35 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
36 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonomicTree
;
37 import eu
.etaxonomy
.cdm
.persistence
.dao
.BeanInitializer
;
38 import eu
.etaxonomy
.cdm
.persistence
.fetch
.CdmFetch
;
39 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
42 public interface ITaxonService
extends IIdentifiableEntityService
<TaxonBase
>{
45 * Computes all taxon bases.
46 * FIXME could substitute with list(Synonym.class, limit, start)
51 public List
<Synonym
> getAllSynonyms(int limit
, int start
);
54 * Computes all taxon bases.
55 * FIXME could substitute with list(Taxon.class, limit,start)
60 public List
<Taxon
> getAllTaxa(int limit
, int start
);
63 * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
64 * @param sec The concept reference that the taxon belongs to
65 * @return The List<Taxon> of root taxa.
66 * @deprecated obsolete when using taxonomicTree
68 public List
<Taxon
> getRootTaxa(ReferenceBase sec
);
72 * Computes all Taxon instances that do not have a taxonomic parent.
73 * @param sec The concept reference that the taxon belongs to
75 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
76 * @return The List<Taxon> of root taxa.
77 * @deprecated obsolete when using taxonomicTree
79 public List
<Taxon
> getRootTaxa(ReferenceBase sec
, CdmFetch cdmFetch
, boolean onlyWithChildren
);
82 * Computes all Taxon instances that do not have a taxonomic parent.
83 * @param sec The concept reference that the taxon belongs to
84 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
85 * @param withMisapplications if false taxa that have at least one misapplied name relationship in which they are
86 * the misapplied name are not returned.<Br>Default: true.
87 * @return The List<Taxon> of root taxa.
88 * @deprecated obsolete when using taxonomicTree
90 public List
<Taxon
> getRootTaxa(ReferenceBase sec
, boolean onlyWithChildren
, boolean withMisapplications
);
93 * Computes all Taxon instances which name is of a certain Rank.
94 * @param rank The rank of the taxon name
95 * @param sec The concept reference that the taxon belongs to
96 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
97 * @param withMisapplications if false taxa that have at least one misapplied name relationship in which they are
98 * the misapplied name are not returned.<Br>Default: true.
99 * @param propertyPaths
100 * properties to be initialized, For detailed description and
101 * examples <b>please refer to:</b>
102 * {@link BeanInitializer#initialize(Object, List)}. <Br>
104 * @return The List<Taxon> of root taxa.
105 * @deprecated obsolete when using taxonomicTree
107 public List
<Taxon
> getRootTaxa(Rank rank
, ReferenceBase sec
, boolean onlyWithChildren
, boolean withMisapplications
, List
<String
> propertyPaths
);
110 * Computes all relationships.
115 public List
<RelationshipBase
> getAllRelationships(int limit
, int start
);
118 * Returns TaxonRelationshipType vocabulary
120 * @deprecated use TermService#getVocabulary(VocabularyType) instead
122 public OrderedTermVocabulary
<TaxonRelationshipType
> getTaxonRelationshipTypeVocabulary();
125 * Returns a list of taxa that matches the name string and the sec reference
126 * @param name the name string to search for
127 * @param sec the taxons sec reference
128 * @return a list of taxa matching the name and the sec reference
130 public List
<TaxonBase
> searchTaxaByName(String name
, ReferenceBase sec
);
133 * Changes an accepted taxon to a synonym of another taxon.
135 * @param oldTaxonNode
136 * the <code>TaxonNode</code> of the accepted taxon that will be changed into a synonym
137 * @param newAcceptedTaxonNode
138 * the <code>TaxonNode</code> of the accepted taxon, the old taxon will become a synonym of
140 * <code>SynonymRelationshipType</code> to indicate whether hetero or homotypic
142 * the reference for this assumption
143 * @param citationMicroReference
146 * the newly created synonym
148 public Synonym
changeAcceptedTaxonToSynonym (TaxonNode oldTaxonNode
, TaxonNode newAcceptedTaxonNode
, SynonymRelationshipType synonymType
, ReferenceBase citation
, String citationMicroReference
);
151 * Swaps given synonym and accepted taxon.
154 * <li>A new accepted taxon with the synonyms name is created</li>
155 * <li>The synonym is deleted from the old accepted taxons synonym list</li>
156 * <li>A new synonym with the name of the old accepted taxon is created</li>
157 * <li>The newly created synonym get related to the newly created accepted taxon</li>
161 * @param acceptedTaxon
162 * @param synonymRelationshipType the relationship type the newly created synonym will have. Defaults to SYNONYM_OF
164 public void swapSynonymAndAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
);
167 * Change a synonym into an accepted taxon and removes
168 * the synonym relationship to the given accepted taxon.
171 * the synonym to change into an accepted taxon
172 * @param acceptedTaxon
173 * an accepted taxon, the synonym had a relationship to
175 * the newly created accepted taxon
177 public Taxon
changeSynonymToAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
);
180 * Change a synonym into a related concept
183 * the synonym to change into the concept taxon
185 * the taxon the newly created concept should be related to
186 * @param taxonRelationshipType
187 * the type of relationship
189 * @param microcitation
191 * the newly created concept
193 public Taxon
changeSynonymToRelatedTaxon(Synonym synonym
, Taxon toTaxon
, TaxonRelationshipType taxonRelationshipType
, ReferenceBase citation
, String microcitation
);
196 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
197 * where the supplied taxon is relatedTo.
199 * @param taxon The taxon that is relatedTo
200 * @param type The type of TaxonRelationship (can be null)
201 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
202 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
203 * @param orderHints Properties to order by
204 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
205 * @return a List of TaxonRelationship instances
207 public List
<TaxonRelationship
> listToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
212 * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
213 * where the supplied taxon is relatedTo.
215 * @param taxon The taxon that is relatedTo
216 * @param type The type of TaxonRelationship (can be null)
217 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
218 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
219 * @param orderHints Properties to order by
220 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
221 * @return a Pager of TaxonRelationship instances
223 public Pager
<TaxonRelationship
> pageToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
226 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
227 * where the supplied taxon is relatedFrom.
229 * @param taxon The taxon that is relatedFrom
230 * @param type The type of TaxonRelationship (can be null)
231 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
232 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
233 * @param orderHints Properties to order by
234 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
235 * @return a List of TaxonRelationship instances
237 public List
<TaxonRelationship
> listFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
241 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
242 * where the supplied taxon is relatedFrom.
244 * @param taxon The taxon that is relatedFrom
245 * @param type The type of TaxonRelationship (can be null)
246 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
247 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
248 * @param orderHints Properties to order by
249 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
250 * @return a Pager of TaxonRelationship instances
252 public Pager
<TaxonRelationship
> pageFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
255 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
256 * where the supplied synonym is relatedFrom.
258 * @param taxon The synonym that is relatedFrom
259 * @param type The type of SynonymRelationship (can be null)
260 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
261 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
262 * * @param orderHints Properties to order by
263 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
264 * @return a Pager of SynonymRelationship instances
266 public Pager
<SynonymRelationship
> getSynonyms(Synonym synonym
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
269 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
270 * where the supplied taxon is relatedTo.
272 * @param taxon The taxon that is relatedTo
273 * @param type The type of SynonymRelationship (can be null)
274 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
275 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
276 * * @param orderHints Properties to order by
277 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
278 * @return a Pager of SynonymRelationship instances
280 public Pager
<SynonymRelationship
> getSynonyms(Taxon taxon
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
282 public List
<Synonym
> getHomotypicSynonymsByHomotypicGroup(Taxon taxon
, List
<String
> propertyPaths
);
284 public List
<List
<Synonym
>> getHeterotypicSynonymyGroups(Taxon taxon
, List
<String
> propertyPaths
);
287 * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
289 * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
291 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
292 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
294 * Supports path like <code>orderHints.propertyNames</code> which
295 * include *-to-one properties like createdBy.username or
296 * authorTeam.persistentTitleCache
297 * @param propertyPaths properties to be initialized
298 * @return a Pager Taxon instances
299 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
301 public Pager
<TaxonBase
> search(Class
<?
extends TaxonBase
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
304 * Returns a list of TaxonBase instances where the
305 * taxon.name properties match the parameters passed.
307 * @param clazz optionally filter by class
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 Pager 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 IdentifiableEntity instances (in particular, TaxonNameBase and TaxonBase instances)
321 * that match the properties specified in the configurator.
322 * @param configurator
325 public Pager
<IdentifiableEntity
> findTaxaAndNames(ITaxonServiceConfigurator configurator
);
332 * @param widthOrDuration
336 public List
<MediaRepresentation
> getAllMedia(Taxon taxon
, int size
, int height
, int widthOrDuration
, String
[] mimeTypes
);
338 public List
<TaxonBase
> findTaxaByID(Set
<Integer
> listOfIDs
);
340 * returns a list of inferred synonyms concerning the taxon with synonymrelationshiptype type
346 public List
<Synonym
> createInferredSynonyms(TaxonomicTree tree
, Taxon taxon
, SynonymRelationshipType type
);
348 * returns a list of all inferred synonyms (inferred epithet, inferred genus and potential combination) concerning the taxon
353 public List
<Synonym
> createAllInferredSynonyms(TaxonomicTree tree
, Taxon taxon
);
355 public int countAllRelationships();
357 public List
<TaxonNameBase
> findIdenticalTaxonNames(List
<String
> propertyPath
);
358 public List
<TaxonNameBase
> findIdenticalTaxonNameIds(List
<String
> propertyPath
);
359 public String
getPhylumName(TaxonNameBase name
);
361 public long deleteSynonymRelationships(Synonym syn
);
363 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
364 * depending on direction, where the supplied taxon is relatedTo or the supplied synonym is relatedFrom.
366 * @param taxonBase The taxon or synonym that is relatedTo or relatedFrom
367 * @param type The type of SynonymRelationship (can be null)
368 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
369 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
370 * @param orderHints Properties to order by
371 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
372 * @param direction The direction of the relationship
373 * @return a List of SynonymRelationship instances
375 public List
<SynonymRelationship
> listSynonymRelationships(
376 TaxonBase taxonBase
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
,
377 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
, Direction direction
);