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
.Reference
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationship
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
31 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
32 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
33 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
34 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
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.
48 * FIXME could substitute with list(Synonym.class, limit, start)
50 public List
<Synonym
> getAllSynonyms(int limit
, int start
);
53 * Computes all taxon bases.
58 * 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 classification
68 public List
<Taxon
> getRootTaxa(Reference 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 classification
79 public List
<Taxon
> getRootTaxa(Reference 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 classification
90 public List
<Taxon
> getRootTaxa(Reference 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 classification
107 public List
<Taxon
> getRootTaxa(Rank rank
, Reference sec
, boolean onlyWithChildren
, boolean withMisapplications
, List
<String
> propertyPaths
);
110 * Computes all relationships.
114 * FIXME candidate for harmonization - rename to listRelationships
116 public List
<RelationshipBase
> getAllRelationships(int limit
, int start
);
119 * Returns TaxonRelationshipType vocabulary
121 * @deprecated use TermService#getVocabulary(VocabularyType) instead
123 public OrderedTermVocabulary
<TaxonRelationshipType
> getTaxonRelationshipTypeVocabulary();
126 * Returns a list of taxa that matches the name string and the sec reference
127 * @param name the name string to search for
128 * @param sec the taxons sec reference
129 * @return a list of taxa matching the name and the sec reference
131 public List
<TaxonBase
> searchTaxaByName(String name
, Reference sec
);
134 * Changes an accepted taxon to a synonym of another taxon.
136 * @param oldTaxonNode
137 * the <code>TaxonNode</code> of the accepted taxon that will be changed into a synonym
138 * @param newAcceptedTaxonNode
139 * the <code>TaxonNode</code> of the accepted taxon, the old taxon will become a synonym of
141 * <code>SynonymRelationshipType</code> to indicate whether hetero or homotypic
143 * the reference for this assumption
144 * @param citationMicroReference
147 * the newly created synonym
149 public Synonym
changeAcceptedTaxonToSynonym (TaxonNode oldTaxonNode
, TaxonNode newAcceptedTaxonNode
, SynonymRelationshipType synonymType
, Reference citation
, String citationMicroReference
);
152 * Swaps given synonym and accepted taxon.
155 * <li>A new accepted taxon with the synonyms name is created</li>
156 * <li>The synonym is deleted from the old accepted taxons synonym list</li>
157 * <li>A new synonym with the name of the old accepted taxon is created</li>
158 * <li>The newly created synonym get related to the newly created accepted taxon</li>
162 * @param acceptedTaxon
163 * @param synonymRelationshipType the relationship type the newly created synonym will have. Defaults to SYNONYM_OF
165 public void swapSynonymAndAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
);
168 * Change a synonym into an accepted taxon and removes
169 * the synonym relationship to the given accepted taxon.
172 * the synonym to change into an accepted taxon
173 * @param acceptedTaxon
174 * an accepted taxon, the synonym had a relationship to
176 * the newly created accepted taxon
178 public Taxon
changeSynonymToAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
);
181 * Change a synonym into a related concept
184 * the synonym to change into the concept taxon
186 * the taxon the newly created concept should be related to
187 * @param taxonRelationshipType
188 * the type of relationship
190 * @param microcitation
192 * the newly created concept
194 public Taxon
changeSynonymToRelatedTaxon(Synonym synonym
, Taxon toTaxon
, TaxonRelationshipType taxonRelationshipType
, Reference citation
, String microcitation
);
198 * Move a synonym to another taxon, effectively removing the old synonym relationship
200 * @param synonymRelation
203 * @param referenceDetail
206 public Taxon
moveSynonymToAnotherTaxon(SynonymRelationship synonymRelation
, Taxon toTaxon
, SynonymRelationshipType synonymRelationshipType
, Reference reference
, String referenceDetail
);
209 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
210 * where the supplied taxon is relatedTo.
212 * @param taxon The taxon that is relatedTo
213 * @param type The type of TaxonRelationship (can be null)
214 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
215 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
216 * @param orderHints Properties to order by
217 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
218 * @return a List of TaxonRelationship instances
220 public List
<TaxonRelationship
> listToTaxonRelationships(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 arguement is supplied)
226 * where the supplied taxon is relatedTo.
228 * @param taxon The taxon that is relatedTo
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 Pager of TaxonRelationship instances
236 public Pager
<TaxonRelationship
> pageToTaxonRelationships(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 List of TaxonRelationship instances
250 public List
<TaxonRelationship
> listFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
254 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
255 * where the supplied taxon is relatedFrom.
257 * @param taxon The taxon that is relatedFrom
258 * @param type The type of TaxonRelationship (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 TaxonRelationship instances
265 public Pager
<TaxonRelationship
> pageFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType 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 synonym is relatedFrom.
271 * @param taxon The synonym that is relatedFrom
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(Synonym synonym
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
282 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
283 * where the supplied taxon is relatedTo.
285 * @param taxon The taxon that is relatedTo
286 * @param type The type of SynonymRelationship (can be null)
287 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
288 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
289 * * @param orderHints Properties to order by
290 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
291 * @return a Pager of SynonymRelationship instances
293 public Pager
<SynonymRelationship
> getSynonyms(Taxon taxon
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
295 public List
<Synonym
> getHomotypicSynonymsByHomotypicGroup(Taxon taxon
, List
<String
> propertyPaths
);
297 public List
<List
<Synonym
>> getHeterotypicSynonymyGroups(Taxon taxon
, List
<String
> propertyPaths
);
300 * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
302 * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
304 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
305 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
307 * Supports path like <code>orderHints.propertyNames</code> which
308 * include *-to-one properties like createdBy.username or
309 * authorTeam.persistentTitleCache
310 * @param propertyPaths properties to be initialized
311 * @return a Pager Taxon instances
312 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
314 public Pager
<TaxonBase
> search(Class
<?
extends TaxonBase
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
317 * Returns a list of TaxonBase instances where the
318 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
319 * <i>null</i> will search for those taxa with a value of null in that field
321 * @param clazz optionally filter by class (can be null to return all taxa)
323 * @param infragenericEpithet
324 * @param specificEpithet
325 * @param infraspecificEpithet
327 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
328 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
329 * @return a list of TaxonBase instances
331 public Pager
<TaxonBase
> findTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
334 * Returns a list of TaxonBase instances where the
335 * taxon.name properties match the parameters passed. In order to search for any string value, pass '*', passing the string value of
336 * <i>null</i> will search for those taxa with a value of null in that field
338 * @param clazz optionally filter by class
340 * @param infragenericEpithet
341 * @param specificEpithet
342 * @param infraspecificEpithet
344 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
345 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
346 * @return a List of TaxonBase instances
348 public List
<TaxonBase
> listTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
351 * Returns a list of IdentifiableEntity instances (in particular, TaxonNameBase and TaxonBase instances)
352 * that match the properties specified in the configurator.
353 * @param configurator
356 public Pager
<IdentifiableEntity
> findTaxaAndNames(ITaxonServiceConfigurator configurator
);
363 * @param widthOrDuration
367 * FIXME candidate for harmonization - rename to listMedia()
369 public List
<MediaRepresentation
> getAllMedia(Taxon taxon
, int size
, int height
, int widthOrDuration
, String
[] mimeTypes
);
371 public List
<TaxonBase
> findTaxaByID(Set
<Integer
> listOfIDs
);
373 * returns a list of inferred synonyms concerning the taxon with synonymrelationshiptype type
379 public List
<Synonym
> createInferredSynonyms(Classification tree
, Taxon taxon
, SynonymRelationshipType type
);
381 * returns a list of all inferred synonyms (inferred epithet, inferred genus and potential combination) concerning the taxon
386 public List
<Synonym
> createAllInferredSynonyms(Classification tree
, Taxon taxon
);
388 public int countAllRelationships();
390 public List
<TaxonNameBase
> findIdenticalTaxonNames(List
<String
> propertyPath
);
391 public List
<TaxonNameBase
> findIdenticalTaxonNameIds(List
<String
> propertyPath
);
392 public String
getPhylumName(TaxonNameBase name
);
394 public long deleteSynonymRelationships(Synonym syn
);
396 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
397 * depending on direction, where the supplied taxon is relatedTo or the supplied synonym is relatedFrom.
399 * @param taxonBase The taxon or synonym that is relatedTo or relatedFrom
400 * @param type The type of SynonymRelationship (can be null)
401 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
402 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
403 * @param orderHints Properties to order by
404 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
405 * @param direction The direction of the relationship
406 * @return a List of SynonymRelationship instances
408 public List
<SynonymRelationship
> listSynonymRelationships(
409 TaxonBase taxonBase
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
,
410 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
, Direction direction
);
416 public Taxon
findBestMatchingTaxon(String taxonName
);
418 public Synonym
findBestMatchingSynonym(String taxonName
);