2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.api
.service
;
12 import java
.util
.Collection
;
13 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import org
.springframework
.security
.core
.Authentication
;
19 import eu
.etaxonomy
.cdm
.api
.service
.config
.PublishForSubtreeConfigurator
;
20 import eu
.etaxonomy
.cdm
.api
.service
.config
.SecundumForSubtreeConfigurator
;
21 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonDeletionConfigurator
;
22 import eu
.etaxonomy
.cdm
.api
.service
.dto
.TaxonDistributionDTO
;
23 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
24 import eu
.etaxonomy
.cdm
.common
.monitor
.IProgressMonitor
;
25 import eu
.etaxonomy
.cdm
.filter
.TaxonNodeFilter
;
26 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
27 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
28 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
31 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymType
;
32 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
33 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
34 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNodeAgentRelation
;
35 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTerm
;
36 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.Restriction
;
37 import eu
.etaxonomy
.cdm
.persistence
.dto
.TaxonNodeDto
;
38 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
39 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
45 public interface ITaxonNodeService
extends IAnnotatableService
<TaxonNode
>{
48 * returns the childnodes of the taxonNode, if recursive is true it returns all descendants, if sort is true the nodes are sorted
51 * @param propertyPaths
53 * @return List<TaxonNode>
55 public List
<TaxonNode
> loadChildNodesOfTaxonNode(TaxonNode taxonNode
, List
<String
> propertyPaths
, boolean recursive
, boolean includeUnpublished
, NodeSortMode sortMode
);
58 * Lists all direct child nodes of the given {@link UuidAndTitleCache} which
59 * represents the parent {@link TaxonNode}
60 * @param parent a UuidAndTitleCache object which represents a parent {@link TaxonNode}
61 * @return a list of UuidAndTitleCache objects that represent children of the
64 // public List<UuidAndTitleCache<TaxonNode>> listChildNodesAsUuidAndTitleCache(UuidAndTitleCache<TaxonNode> parent);
66 public List
<TaxonNode
> listChildrenOf(TaxonNode node
, Integer pageSize
, Integer pageIndex
,
67 boolean recursive
, boolean includeUnpublished
, List
<String
> propertyPaths
);
70 * Retrieves a list of {@link UuidAndTitleCache} objects that have a matchin titleCache
72 * @param limit the maximum results
73 * @param pattern the titleCache that is searched for
74 * @param classificationUuid if specified only nodes of this classification are retrieved
75 * @return a list of matches
77 public List
<TaxonNodeDto
> getTaxonNodeDto(Integer limit
, String pattern
, UUID classificationUuid
);
80 * Retrieves the parent node of the child {@link TaxonNode}
81 * @param child the child for which the parent should be retrieved
82 * @return the parent taxon node
84 public TaxonNodeDto
getParentUuidAndTitleCache(ITaxonTreeNode child
);
87 * Retrieves the parent node of the {@link TaxonNode} represented by the given {@link UuidAndTitleCache}.
88 * @param child the child for which the parent should be retrieved
89 * @return an UuidAndTitleCache object representing the parent node
91 public TaxonNodeDto
getParentUuidAndTitleCache(TaxonNodeDto child
);
94 // * Lists all direct child nodes of the given {@link ITaxonTreeNode}
95 // * @param parent the parent ITaxonTreeNode
96 // * @return a list of UuidAndTitleCache objects that represent children of the
99 // public List<UuidAndTitleCache<TaxonNode>> listChildNodesAsUuidAndTitleCache(ITaxonTreeNode parent);
102 *Returns the childnodes of the taxonNode, if recursive is true it returns all descendants, if sort is true the nodes are sorted
106 * @param doSynonyms if true also synonyms are returned as children
111 * @return List<TaxonNodeDto>
113 public Pager
<TaxonNodeDto
> pageChildNodesDTOs(UUID taxonNodeUuid
, boolean recursive
, boolean includeUnpublished
,
114 boolean doSynonyms
, NodeSortMode sortMode
,
115 Integer pageSize
, Integer pageIndex
);
117 public TaxonNodeDto
parentDto(UUID taxonNodeUuid
);
120 * Changes the taxon associated with the given taxon node into a synonym of the new accepted taxon node.
121 * All data associated with the former taxon are moved to the newly accepted taxon.
123 public DeleteResult
makeTaxonNodeASynonymOfAnotherTaxonNode(TaxonNode oldTaxonNode
, TaxonNode newAcceptedTaxonNode
, SynonymType synonymType
, Reference citation
, String citationMicroReference
, boolean setNameInSource
) ;
126 * Changes the taxa associated with the given taxon nodes into synonyms of the new accepted taxon node.
127 * All data associated with the former taxa are moved to the newly accepted taxon.
129 public UpdateResult
makeTaxonNodeSynonymsOfAnotherTaxonNode(Set
<UUID
> oldTaxonNodeUuids
, UUID newAcceptedTaxonNodeUUIDs
,
130 SynonymType synonymType
, Reference citation
, String citationMicroReference
, boolean setNameInSource
);
132 public UpdateResult
makeTaxonNodeASynonymOfAnotherTaxonNode(UUID oldTaxonNodeUuid
,
133 UUID newAcceptedTaxonNodeUUID
,
134 SynonymType synonymType
,
136 String citationMicroReference
,
137 boolean setNameInSource
) ;
139 public DeleteResult
deleteTaxonNodes(Collection
<UUID
> nodeUuids
, TaxonDeletionConfigurator config
);
142 * deletes the given taxon node the configurator defines whether the children will be deleted too or not
144 public DeleteResult
deleteTaxonNode(TaxonNode node
, TaxonDeletionConfigurator config
);
147 * Returns a List of all TaxonNodes of a given Classification.
149 * @param classification - according to the given classification the TaxonNodes are filtered.
150 * @param start - beginning of wanted row set, i.e. 0 if one want to start from the beginning.
151 * @param end - limit of how many rows are to be pulled from the database, i.e. 1000 rows.
152 * @return filtered List of TaxonNode according to the classification provided
160 public DeleteResult
deleteTaxonNode(UUID nodeUuid
, TaxonDeletionConfigurator config
);
162 public List
<TaxonNode
> listAllNodesForClassification(Classification classification
, Integer start
, Integer end
);
165 * Counts all TaxonNodes for a given Classification
167 * @param classification - according to the given classification the TaxonNodes are filtered.
168 * @return the count result
170 public int countAllNodesForClassification(Classification classification
);
172 public UpdateResult
moveTaxonNode(UUID taxonNodeUuid
, UUID newParentTaxonNodeUuid
, int movingType
);
174 public UpdateResult
moveTaxonNode(TaxonNode taxonNode
, TaxonNode newParent
, int movingType
);
177 * deletes the given taxon nodes
179 public DeleteResult
deleteTaxonNodes(List
<TaxonNode
> list
, TaxonDeletionConfigurator config
);
182 * Returns the of TaxonNodeAgentRelation entities which are associated with the TaxonNode for the
183 * given TaxonUuid in the specified Classification.
186 * @param agentUuid TODO
187 * @param rankUuid TODO
188 * @param relTypeUuid TODO
189 * @param classification
192 public Pager
<TaxonNodeAgentRelation
> pageTaxonNodeAgentRelations(UUID taxonUuid
, UUID classificationUuid
,
193 UUID agentUuid
, UUID rankUuid
, UUID relTypeUuid
, Integer pageSize
, Integer pageIndex
, List
<String
> propertyPaths
);
195 public UpdateResult
createNewTaxonNode(UUID parentNodeUuid
, Taxon newTaxon
, Reference ref
, String microref
);
197 public UpdateResult
addTaxonNodeAgentRelation(UUID taxonNodeUUID
, UUID agentUUID
, DefinedTerm relationshipType
);
200 * @param parentNodeUuid
206 public UpdateResult
createNewTaxonNode(UUID parentNodeUuid
, UUID taxonUuid
, Reference ref
, String microref
);
209 * Sets the secundum reference for all taxa of the given subtree.
210 * Depending on the configuration, also synonym secundum will be set.
211 * See {@link SetSecundumForSubtreeConfigurator} for further configuration
213 * @return UpdateResult
215 public UpdateResult
setSecundumForSubtree(SecundumForSubtreeConfigurator config
);
219 * Sets the publish flag for all taxa and/or synonyms of the subtree.
221 public UpdateResult
setPublishForSubtree(PublishForSubtreeConfigurator configurator
);
224 * Returns a list of taxon node {@link UUID uuids} according to the given filter.
226 public long count(TaxonNodeFilter filter
);
229 * Returns a list of taxon node {@link UUID uuids} according to the given filter.
231 public List
<UUID
> uuidList(TaxonNodeFilter filter
);
234 * Returns a list of taxon node IDs according to the given filter.
236 public List
<Integer
> idList(TaxonNodeFilter filter
);
238 List
<TaxonNodeDto
> listChildNodesAsTaxonNodeDto(TaxonNodeDto parent
);
241 List
<TaxonNodeDto
> listChildNodesAsTaxonNodeDto(ITaxonTreeNode parent
);
244 * @param taxonNodeUuids
245 * @param newParentNodeUuid
250 UpdateResult
moveTaxonNodes(Set
<UUID
> taxonNodeUuids
, UUID newParentNodeUuid
, int movingType
,
251 IProgressMonitor monitor
);
254 * Retrieves the first taxon node that is direct or indirect parent
255 * to all nodes of the given list of nodes. This can also return
256 * the root node of a classification<br>
257 * If no common parent node could be found <code>null</code> is returned.
258 * @param nodes the direct/indirect child taxon nodes for which the common
259 * parent should be retrieved
260 * @return the common direct/indirect parent of all nodes
262 public TaxonNodeDto
findCommonParentDto(Collection
<TaxonNodeDto
> nodes
);
264 public TaxonNodeDto
dto(UUID taxonNodeUuid
);
266 public List
<TaxonDistributionDTO
> getTaxonDistributionDTOForSubtree(UUID parentNodeUuid
, List
<String
> propertyPaths
, Authentication authentication
);
268 public List
<TaxonDistributionDTO
> getTaxonDistributionDTOForSubtree(UUID parentNodeUuid
, List
<String
> propertyPaths
);
270 public UpdateResult
saveNewTaxonNode(TaxonNode newTaxonNode
);
272 public <S
extends TaxonNode
> Pager
<S
> page(Class
<S
> clazz
, List
<Restriction
<?
>> restrictions
, Integer pageSize
, Integer pageIndex
,
273 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
, boolean includeUnpublished
);
275 public TaxonNodeDto
taxonNodeDtoParentRank(Classification classification
, Rank rank
, TaxonName name
);
278 * Lists all direct child nodes of the given {@link ITaxonTreeNode}
279 * @param parent the parent ITaxonTreeNode
280 * @return a list of UuidAndTitleCache objects that represent children of the
283 public List
<UuidAndTitleCache
<TaxonNode
>> listChildNodesAsUuidAndTitleCache(ITaxonTreeNode parent
);
284 public List
<UuidAndTitleCache
> getUuidAndTitleCache(Integer limit
, String pattern
, UUID classificationUuid
);
285 public List
<UuidAndTitleCache
<TaxonNode
>> listChildNodesAsUuidAndTitleCache(UuidAndTitleCache
<TaxonNode
> parent
);