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
.OrderHint
;
40 public interface ITaxonService
extends IIdentifiableEntityService
<TaxonBase
>{
43 * Computes all taxon bases.
44 * FIXME could substitute with list(Synonym.class, limit, start)
49 public List
<Synonym
> getAllSynonyms(int limit
, int start
);
52 * Computes all taxon bases.
53 * FIXME could substitute with list(Taxon.class, limit,start)
58 public List
<Taxon
> getAllTaxa(int limit
, int start
);
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
66 public List
<Taxon
> getRootTaxa(ReferenceBase sec
);
70 * Computes all Taxon instances that do not have a taxonomic parent.
71 * @param sec The concept reference that the taxon belongs to
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
77 public List
<Taxon
> getRootTaxa(ReferenceBase sec
, CdmFetch cdmFetch
, boolean onlyWithChildren
);
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
88 public List
<Taxon
> getRootTaxa(ReferenceBase sec
, boolean onlyWithChildren
, boolean withMisapplications
);
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>
102 * @return The List<Taxon> of root taxa.
103 * @deprecated obsolete when using taxonomicTree
105 public List
<Taxon
> getRootTaxa(Rank rank
, ReferenceBase sec
, boolean onlyWithChildren
, boolean withMisapplications
, List
<String
> propertyPaths
);
108 * Computes all relationships.
113 public List
<RelationshipBase
> getAllRelationships(int limit
, int start
);
116 * Returns TaxonRelationshipType vocabulary
118 * @deprecated use TermService#getVocabulary(VocabularyType) instead
120 public OrderedTermVocabulary
<TaxonRelationshipType
> getTaxonRelationshipTypeVocabulary();
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
128 public List
<TaxonBase
> searchTaxaByName(String name
, ReferenceBase sec
);
131 * Changes an accepted taxon to a synonym of another taxon.
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
138 * <code>SynonymRelationshipType</code> to indicate whether hetero or homotypic
140 * the reference for this assumption
141 * @param citationMicroReference
144 * the newly created synonym
146 public Synonym
changeAcceptedTaxonToSynonym (TaxonNode oldTaxonNode
, TaxonNode newAcceptedTaxonNode
, SynonymRelationshipType synonymType
, ReferenceBase citation
, String citationMicroReference
);
149 * Swaps given synonym and accepted taxon.
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>
159 * @param acceptedTaxon
160 * @param synonymRelationshipType the relationship type the newly created synonym will have. Defaults to SYNONYM_OF
162 public void swapSynonymAndAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
);
165 * Change a synonym into an accepted taxon and removes
166 * the synonym relationship to the given accepted taxon.
169 * the synonym to change into an accepted taxon
170 * @param acceptedTaxon
171 * an accepted taxon, the synonym had a relationship to
173 * the newly created accepted taxon
175 public Taxon
changeSynonymToAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
);
178 * Change a synonym into a related concept
181 * the synonym to change into the concept taxon
183 * the taxon the newly created concept should be related to
184 * @param taxonRelationshipType
185 * the type of relationship
187 * @param microcitation
189 * the newly created concept
191 public Taxon
changeSynonymToRelatedTaxon(Synonym synonym
, Taxon toTaxon
, TaxonRelationshipType taxonRelationshipType
, ReferenceBase citation
, String microcitation
);
194 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
195 * where the supplied taxon is relatedTo.
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
205 public List
<TaxonRelationship
> listToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
210 * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
211 * where the supplied taxon is relatedTo.
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
221 public Pager
<TaxonRelationship
> pageToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
224 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
225 * where the supplied taxon is relatedFrom.
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
235 public List
<TaxonRelationship
> listFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
239 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
240 * where the supplied taxon is relatedFrom.
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
250 public Pager
<TaxonRelationship
> pageFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
253 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
254 * where the supplied synonym is relatedFrom.
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
264 public Pager
<SynonymRelationship
> getSynonyms(Synonym synonym
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
267 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
268 * where the supplied taxon is relatedTo.
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
278 public Pager
<SynonymRelationship
> getSynonyms(Taxon taxon
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
280 public List
<Synonym
> getHomotypicSynonymsByHomotypicGroup(Taxon taxon
, List
<String
> propertyPaths
);
282 public List
<List
<Synonym
>> getHeterotypicSynonymyGroups(Taxon taxon
, List
<String
> propertyPaths
);
285 * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
287 * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
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)
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>
299 public Pager
<TaxonBase
> search(Class
<?
extends TaxonBase
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
302 * Returns a list of TaxonBase instances where the
303 * taxon.name properties match the parameters passed.
305 * @param clazz optionally filter by class
307 * @param infragenericEpithet
308 * @param specificEpithet
309 * @param infraspecificEpithet
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
315 public Pager
<TaxonBase
> findTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
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
322 * @param clazz optionally filter by class
324 * @param infragenericEpithet
325 * @param specificEpithet
326 * @param infraspecificEpithet
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
332 public List
<TaxonBase
> listTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
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
340 public Pager
<IdentifiableEntity
> findTaxaAndNames(ITaxonServiceConfigurator configurator
);
347 * @param widthOrDuration
351 public List
<MediaRepresentation
> getAllMedia(Taxon taxon
, int size
, int height
, int widthOrDuration
, String
[] mimeTypes
);
353 public List
<TaxonBase
> findTaxaByID(Set
<Integer
> listOfIDs
);
355 * returns a list of inferred synonyms concerning the taxon with synonymrelationshiptype type
361 public List
<Synonym
> createInferredSynonyms(TaxonomicTree tree
, Taxon taxon
, SynonymRelationshipType type
);
363 * returns a list of all inferred synonyms (inferred epithet, inferred genus and potential combination) concerning the taxon
368 public List
<Synonym
> createAllInferredSynonyms(TaxonomicTree tree
, Taxon taxon
);
370 public int countAllRelationships();
372 public List
<TaxonNameBase
> findIdenticalTaxonNames(List
<String
> propertyPath
);
373 public List
<TaxonNameBase
> findIdenticalTaxonNameIds(List
<String
> propertyPath
);
374 public String
getPhylumName(TaxonNameBase name
);
376 public long deleteSynonymRelationships(Synonym syn
);
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.
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
390 public List
<SynonymRelationship
> listSynonymRelationships(
391 TaxonBase taxonBase
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
,
392 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
, Direction direction
);