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
.Collection
;
14 import java
.util
.List
;
16 import java
.util
.UUID
;
18 import eu
.etaxonomy
.cdm
.api
.service
.config
.ITaxonServiceConfigurator
;
19 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
20 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
21 import eu
.etaxonomy
.cdm
.model
.common
.OrderedTermVocabulary
;
22 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
;
23 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
24 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationship
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymRelationshipType
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
31 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
32 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
33 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonomicTree
;
34 import eu
.etaxonomy
.cdm
.persistence
.dao
.BeanInitializer
;
35 import eu
.etaxonomy
.cdm
.persistence
.fetch
.CdmFetch
;
36 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
39 public interface ITaxonService
extends IIdentifiableEntityService
<TaxonBase
>{
42 * FIXME candidate for harmonization?
44 public abstract TaxonBase
getTaxonByUuid(UUID uuid
);
51 public abstract TaxonNode
getTaxonNodeByUuid(UUID uuid
);
55 * @param taxonomicTree
59 public TaxonNode
loadTaxonNodeByTaxon(Taxon taxon
, UUID taxonomicTreeUuid
, List
<String
> propertyPaths
);
64 * specifies the root level of the taxonomic tree, may be null.
65 * Nodes of this rank or in case this rank does not exist in the
66 * current branch the next lower rank is taken as root node for
67 * this rank henceforth called the <b>base node</b>.
68 * @param propertyPaths
69 * the initialization strategy for the returned TaxonNode
71 * @return the path of nodes from the <b>base node</b> to the node of the
74 public List
<TaxonNode
> loadTreeBranchTo(TaxonNode taxonNode
, Rank baseRank
, List
<String
> propertyPaths
);
78 * @param taxonomicTree
79 * the taxonomic tree to be used
81 * specifies the root level of the taxonomic tree, may be null.
82 * Nodes of this rank or in case this rank does not exist in the
83 * current branch the next lower rank is taken as as root node for
84 * this rank henceforth called the <b>base node</b>.
85 * @param propertyPaths
86 * the initialization strategy for the returned TaxonNode
88 * @return the path of nodes from the <b>base node</b> to the node of the specified
91 public List
<TaxonNode
> loadTreeBranchToTaxon(Taxon taxon
, TaxonomicTree taxonomicTree
, Rank baseRank
,
92 List
<String
> propertyPaths
);
96 * @param taxonomicTree
97 * @param propertyPaths
100 public List
<TaxonNode
> loadChildNodesOfTaxon(Taxon taxon
, TaxonomicTree taxonomicTree
, List
<String
> propertyPaths
);
104 * FIXME candidate for harmonization?
105 * save a taxon and return its UUID
107 public abstract UUID
saveTaxon(TaxonBase taxon
);
114 public abstract UUID
saveTaxonNode(TaxonNode taxonNode
);
117 * FIXME candidate for harmonization?
118 * save a taxon and return its UUID
120 //public abstract UUID saveTaxon(TaxonBase taxon, TransactionStatus txStatus);
123 * FIXME candidate for harmonization?
124 * save a collection of taxa and return its UUID
126 public abstract Map
<UUID
, ?
extends TaxonBase
> saveTaxonAll(Collection
<?
extends TaxonBase
> taxonCollection
);
130 * @param taxonNodeCollection
133 public abstract Map
<UUID
, TaxonNode
> saveTaxonNodeAll(Collection
<TaxonNode
> taxonNodeCollection
);
136 * FIXME candidate for harmonization?
137 * delete a taxon and return its UUID
139 public abstract UUID
removeTaxon(TaxonBase taxon
);
142 * Computes all taxon bases.
143 * FIXME could substitute with list(Synonym.class, limit, start)
148 public abstract List
<Synonym
> getAllSynonyms(int limit
, int start
);
151 * Computes all taxon bases.
152 * FIXME could substitute with list(Taxon.class, limit,start)
157 public abstract List
<Taxon
> getAllTaxa(int limit
, int start
);
160 * Computes all taxon bases.
161 * FIXME could substitute with list(limit,start) from superclass
166 public abstract List
<TaxonBase
> getAllTaxonBases(int limit
, int start
);
170 * Computes all taxonomic trees.
171 * FIXME candidate for harmonization
175 * @deprecated use {#listTaxonomicTrees} instead
178 public List
<TaxonomicTree
> getAllTaxonomicTrees(int limit
, int start
);
184 * @param propertyPaths
187 public List
<TaxonomicTree
> listTaxonomicTrees(Integer limit
, Integer start
, List
<OrderHint
> orderHints
,
188 List
<String
> propertyPaths
);
192 * Loads all TaxonNodes of the specified tree for a given Rank.
193 * If a branch does not contain a TaxonNode with a TaxonName at the given
194 * Rank the node associated with the next lower Rank is taken as root node.
195 * If the <code>rank</code> is null the absolute root nodes will be returned.
197 * @param taxonomicTree
198 * @param rank may be null
199 * @param propertyPaths
202 public List
<TaxonNode
> loadRankSpecificRootNodes(TaxonomicTree taxonomicTree
, Rank rank
, List
<String
> propertyPaths
);
206 * Returns a taxonomic tree by it's uuid.
210 public TaxonomicTree
getTaxonomicTreeByUuid(UUID uuid
);
213 * Returns a taxonomic tree by it's uuid.
217 public UUID
saveTaxonomicTree(TaxonomicTree tree
);
220 * Remove the taxonomic tree from the persitence context
222 * @param taxonomicTree
225 public UUID
removeTaxonomicTree(TaxonomicTree taxonomicTree
);
228 * Computes all Taxon instances that do not have a taxonomic parent and has at least one child.
229 * @param sec The concept reference that the taxon belongs to
230 * @return The List<Taxon> of root taxa.
232 public List
<Taxon
> getRootTaxa(ReferenceBase sec
);
236 * Computes all Taxon instances that do not have a taxonomic parent.
237 * @param sec The concept reference that the taxon belongs to
239 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
240 * @return The List<Taxon> of root taxa.
242 public abstract List
<Taxon
> getRootTaxa(ReferenceBase sec
, CdmFetch cdmFetch
, boolean onlyWithChildren
);
245 * Computes all Taxon instances that do not have a taxonomic parent.
246 * @param sec The concept reference that the taxon belongs to
247 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
248 * @param withMisapplications if false taxa that have at least one misapplied name relationship in which they are
249 * the misapplied name are not returned.<Br>Default: true.
250 * @return The List<Taxon> of root taxa.
252 public abstract List
<Taxon
> getRootTaxa(ReferenceBase sec
, boolean onlyWithChildren
, boolean withMisapplications
);
255 * Computes all Taxon instances which name is of a certain Rank.
256 * @param rank The rank of the taxon name
257 * @param sec The concept reference that the taxon belongs to
258 * @param onlyWithChildren if true only taxa are returned that have taxonomic children. <Br>Default: true.
259 * @param withMisapplications if false taxa that have at least one misapplied name relationship in which they are
260 * the misapplied name are not returned.<Br>Default: true.
261 * @param propertyPaths
262 * properties to be initialized, For detailed description and
263 * examples <b>please refer to:</b>
264 * {@link BeanInitializer#initialize(Object, List)}. <Br>
266 * @return The List<Taxon> of root taxa.
268 public abstract List
<Taxon
> getRootTaxa(Rank rank
, ReferenceBase sec
, boolean onlyWithChildren
, boolean withMisapplications
, List
<String
> propertyPaths
);
271 * Computes all relationships.
276 public abstract List
<RelationshipBase
> getAllRelationships(int limit
, int start
);
279 * Returns TaxonRelationshipType vocabulary
281 * @deprecated use TermService#getVocabulary(VocabularyType) instead
283 public OrderedTermVocabulary
<TaxonRelationshipType
> getTaxonRelationshipTypeVocabulary();
286 public abstract List
<TaxonBase
> searchTaxaByName(String name
, ReferenceBase sec
);
288 public Synonym
makeTaxonSynonym (Taxon oldTaxon
, Taxon newAcceptedTaxon
, SynonymRelationshipType synonymType
, ReferenceBase citation
, String citationMicroReference
);
291 * Sets the synonyms name as the accepted taxons name. Deletes the synonym from the accepted taxon synonym list
292 * and attaches a new synonym created with the former name of the accepted taxon
295 * @param acceptedTaxon
296 * @param synonymRelationshipType the relationship type the newly created synonym will have. Defaults to SYNONYM_OF
298 public void makeSynonymAcceptedTaxon(Synonym synonym
, Taxon acceptedTaxon
, SynonymRelationshipType synonymRelationshipType
);
301 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
302 * where the supplied taxon is relatedTo.
304 * @param taxon The taxon that is relatedTo
305 * @param type The type of TaxonRelationship (can be null)
306 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
307 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
308 * @param orderHints Properties to order by
309 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
310 * @return a List of TaxonRelationship instances
312 public List
<TaxonRelationship
> listToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
315 * Returns the TaxonRelationships (of where relationship.type == type, if this arguement is supplied)
316 * where the supplied taxon is relatedTo.
318 * @param taxon The taxon that is relatedTo
319 * @param type The type of TaxonRelationship (can be null)
320 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
321 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
322 * @param orderHints Properties to order by
323 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
324 * @return a Pager of TaxonRelationship instances
326 public Pager
<TaxonRelationship
> pageToTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
329 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
330 * where the supplied taxon is relatedFrom.
332 * @param taxon The taxon that is relatedFrom
333 * @param type The type of TaxonRelationship (can be null)
334 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
335 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
336 * @param orderHints Properties to order by
337 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
338 * @return a List of TaxonRelationship instances
340 public List
<TaxonRelationship
> listFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
343 * Returns the TaxonRelationships (of where relationship.type == type, if this argument is supplied)
344 * where the supplied taxon is relatedFrom.
346 * @param taxon The taxon that is relatedFrom
347 * @param type The type of TaxonRelationship (can be null)
348 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
349 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
350 * @param orderHints Properties to order by
351 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
352 * @return a Pager of TaxonRelationship instances
354 public Pager
<TaxonRelationship
> pageFromTaxonRelationships(Taxon taxon
, TaxonRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
357 * Returns the SynonymRelationships (of where relationship.type == type, if this argument is supplied)
358 * where the supplied taxon is relatedTo.
360 * @param taxon The taxon that is relatedTo
361 * @param type The type of SynonymRelationship (can be null)
362 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
363 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
364 * * @param orderHints Properties to order by
365 * @param propertyPaths Properties to initialize in the returned entities, following the syntax described in {@link BeanInitializer#initialize(Object, List)}
366 * @return a Pager of SynonymRelationship instances
368 public Pager
<SynonymRelationship
> getSynonyms(Taxon taxon
, SynonymRelationshipType type
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
370 public List
<Synonym
> getHomotypicSynonymsByHomotypicGroup(Taxon taxon
, List
<String
> propertyPaths
);
372 public List
<List
<Synonym
>> getHeterotypicSynonymyGroups(Taxon taxon
, List
<String
> propertyPaths
);
375 * Returns a Paged List of TaxonBase instances where the default field matches the String queryString (as interpreted by the Lucene QueryParser)
377 * @param clazz filter the results by class (or pass null to return all TaxonBase instances)
379 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
380 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
382 * Supports path like <code>orderHints.propertyNames</code> which
383 * include *-to-one properties like createdBy.username or
384 * authorTeam.persistentTitleCache
385 * @param propertyPaths properties to be initialized
386 * @return a Pager Taxon instances
387 * @see <a href="http://lucene.apache.org/java/2_4_0/queryparsersyntax.html">Apache Lucene - Query Parser Syntax</a>
389 public Pager
<TaxonBase
> search(Class
<?
extends TaxonBase
> clazz
, String queryString
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
);
392 * Returns a list of TaxonBase instances where the
393 * taxon.name properties match the parameters passed.
395 * @param clazz optionally filter by class
397 * @param infragenericEpithet
398 * @param specificEpithet
399 * @param infraspecificEpithet
401 * @param pageSize The maximum number of taxa returned (can be null for all matching taxa)
402 * @param pageNumber The offset (in pageSize chunks) from the start of the result set (0 - based)
403 * @return a Pager of TaxonBase instances
405 public Pager
<TaxonBase
> findTaxaByName(Class
<?
extends TaxonBase
> clazz
, String uninomial
, String infragenericEpithet
, String specificEpithet
, String infraspecificEpithet
, Rank rank
, Integer pageSize
, Integer pageNumber
);
408 * Returns a list of IdentifiableEntity instances (in particular, TaxonNameBase and TaxonBase instances)
409 * that match the properties specified in the configurator.
410 * @param configurator
413 public Pager
<IdentifiableEntity
> findTaxaAndNames(ITaxonServiceConfigurator configurator
);