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 eu
.etaxonomy
.cdm
.api
.service
.config
.PublishForSubtreeConfigurator
;
18 import eu
.etaxonomy
.cdm
.api
.service
.config
.SecundumForSubtreeConfigurator
;
19 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonDeletionConfigurator
;
20 import eu
.etaxonomy
.cdm
.api
.service
.dto
.TaxonDistributionDTO
;
21 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
22 import eu
.etaxonomy
.cdm
.common
.monitor
.IProgressMonitor
;
23 import eu
.etaxonomy
.cdm
.filter
.TaxonNodeFilter
;
24 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymType
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNodeAgentRelation
;
31 import eu
.etaxonomy
.cdm
.model
.term
.DefinedTerm
;
32 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.Restriction
;
33 import eu
.etaxonomy
.cdm
.persistence
.dto
.TaxonNodeDto
;
34 import eu
.etaxonomy
.cdm
.persistence
.dto
.UuidAndTitleCache
;
35 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
42 public interface ITaxonNodeService
extends IAnnotatableService
<TaxonNode
>{
45 * returns the childnodes of the taxonNode, if recursive is true it returns all descendants, if sort is true the nodes are sorted
48 * @param propertyPaths
50 * @return List<TaxonNode>
52 public List
<TaxonNode
> loadChildNodesOfTaxonNode(TaxonNode taxonNode
, List
<String
> propertyPaths
, boolean recursive
, boolean includeUnpublished
, NodeSortMode sortMode
);
55 * Lists all direct child nodes of the given {@link UuidAndTitleCache} which
56 * represents the parent {@link TaxonNode}
57 * @param parent a UuidAndTitleCache object which represents a parent {@link TaxonNode}
58 * @return a list of UuidAndTitleCache objects that represent children of the
61 public List
<UuidAndTitleCache
<TaxonNode
>> listChildNodesAsUuidAndTitleCache(UuidAndTitleCache
<TaxonNode
> parent
);
63 public List
<TaxonNode
> listChildrenOf(TaxonNode node
, Integer pageSize
, Integer pageIndex
,
64 boolean recursive
, boolean includeUnpublished
, List
<String
> propertyPaths
);
67 * Retrieves a list of {@link UuidAndTitleCache} objects that have a matchin titleCache
68 * @param limit the maximum results
69 * @param pattern the titleCache that is searched for
70 * @param classificationUuid if specified only nodes of this classification are retrieved
71 * @return a list of matches
73 public List
<UuidAndTitleCache
<TaxonNode
>> getUuidAndTitleCache(Integer limit
, String pattern
, UUID classificationUuid
);
76 * Retrieves the parent node of the child {@link TaxonNode}
77 * @param child the child for which the parent should be retrieved
78 * @return the parent taxon node
80 public UuidAndTitleCache
<TaxonNode
> getParentUuidAndTitleCache(ITaxonTreeNode child
);
83 * Retrieves the parent node of the {@link TaxonNode} represented by the given {@link UuidAndTitleCache}.
84 * @param child the child for which the parent should be retrieved
85 * @return an UuidAndTitleCache object representing the parent node
87 public UuidAndTitleCache
<TaxonNode
> getParentUuidAndTitleCache(UuidAndTitleCache
<TaxonNode
> child
);
90 * Lists all direct child nodes of the given {@link ITaxonTreeNode}
91 * @param parent the parent ITaxonTreeNode
92 * @return a list of UuidAndTitleCache objects that represent children of the
95 public List
<UuidAndTitleCache
<TaxonNode
>> listChildNodesAsUuidAndTitleCache(ITaxonTreeNode parent
);
98 *returns the childnodes of the taxonNode, if recursive is true it returns all descendants, if sort is true the nodes are sorted
102 * @param doSynonyms if true also synonyms are returned as children
107 * @return List<TaxonNodeDto>
109 public Pager
<TaxonNodeDto
> pageChildNodesDTOs(UUID taxonNodeUuid
, boolean recursive
, boolean includeUnpublished
,
110 boolean doSynonyms
, NodeSortMode sortMode
,
111 Integer pageSize
, Integer pageIndex
);
113 public TaxonNodeDto
parentDto(UUID taxonNodeUuid
);
116 * Changes the taxon associated with the given taxon node into a synonym of the new accepted taxon node.
117 * All data associated with the former taxon are moved to the newly accepted taxon.
119 * @param oldTaxonNode
120 * @param newAcceptedTaxonNode
123 * @param citationMicroReference
124 * @param setNameInSource
128 public DeleteResult
makeTaxonNodeASynonymOfAnotherTaxonNode(TaxonNode oldTaxonNode
, TaxonNode newAcceptedTaxonNode
, SynonymType synonymType
, Reference citation
, String citationMicroReference
, boolean setNameInSource
) ;
131 * Changes the taxa associated with the given taxon nodes into synonyms of the new accepted taxon node.
132 * All data associated with the former taxa are moved to the newly accepted taxon.
134 * @param oldTaxonNodes
135 * @param newAcceptedTaxonNode
138 * @param citationMicroReference
139 * @param setNameInSource
143 UpdateResult
makeTaxonNodeSynonymsOfAnotherTaxonNode(Set
<UUID
> oldTaxonNodeUuids
, UUID newAcceptedTaxonNodeUUIDs
,
144 SynonymType synonymType
, Reference citation
, String citationMicroReference
, boolean setNameInSource
);
147 public UpdateResult
makeTaxonNodeASynonymOfAnotherTaxonNode(UUID oldTaxonNodeUuid
,
148 UUID newAcceptedTaxonNodeUUID
,
149 SynonymType synonymType
,
151 String citationMicroReference
,
152 boolean setNameInSource
) ;
160 public DeleteResult
deleteTaxonNodes(Collection
<UUID
> nodeUuids
, TaxonDeletionConfigurator config
);
163 * deletes the given taxon node the configurator defines whether the children will be deleted too or not
170 public DeleteResult
deleteTaxonNode(TaxonNode node
, TaxonDeletionConfigurator config
);
172 * Returns a List of all TaxonNodes of a given Classification.
174 * @param classification - according to the given classification the TaxonNodes are filtered.
175 * @param start - beginning of wanted row set, i.e. 0 if one want to start from the beginning.
176 * @param end - limit of how many rows are to be pulled from the database, i.e. 1000 rows.
177 * @return filtered List of TaxonNode according to the classification provided
185 public DeleteResult
deleteTaxonNode(UUID nodeUuid
, TaxonDeletionConfigurator config
);
187 public List
<TaxonNode
> listAllNodesForClassification(Classification classification
, Integer start
, Integer end
);
190 * Counts all TaxonNodes for a given Classification
192 * @param classification - according to the given classification the TaxonNodes are filtered.
195 public int countAllNodesForClassification(Classification classification
);
199 * @param taxonNodeUuid
200 * @param newParentTaxonNodeUuid
203 public UpdateResult
moveTaxonNode(UUID taxonNodeUuid
, UUID newParentTaxonNodeUuid
, int movingType
);
215 UpdateResult
moveTaxonNode(TaxonNode taxonNode
, TaxonNode newParent
, int movingType
);
218 * deletes the given taxon nodes
225 public DeleteResult
deleteTaxonNodes(List
<TaxonNode
> list
, TaxonDeletionConfigurator config
);
228 * Returns the of TaxonNodeAgentRelation entities which are associated with the TaxonNode for the
229 * given TaxonUuid in the specified Classification.
232 * @param agentUuid TODO
233 * @param rankUuid TODO
234 * @param relTypeUuid TODO
235 * @param classification
238 public Pager
<TaxonNodeAgentRelation
> pageTaxonNodeAgentRelations(UUID taxonUuid
, UUID classificationUuid
,
239 UUID agentUuid
, UUID rankUuid
, UUID relTypeUuid
, Integer pageSize
, Integer pageIndex
, List
<String
> propertyPaths
);
242 * @param parentNodeUuid
248 public UpdateResult
createNewTaxonNode(UUID parentNodeUuid
, Taxon newTaxon
, Reference ref
, String microref
);
251 * @param taxonNodeUUID
253 * @param relationshipType
256 public UpdateResult
addTaxonNodeAgentRelation(UUID taxonNodeUUID
, UUID agentUUID
, DefinedTerm relationshipType
);
259 * @param parentNodeUuid
265 public UpdateResult
createNewTaxonNode(UUID parentNodeUuid
, UUID taxonUuid
, Reference ref
, String microref
);
268 * Sets the secundum reference for all taxa of the given subtree.
269 * Depending on the configuration, also synonym secundum will be set.
270 * See {@link SetSecundumForSubtreeConfigurator} for further configuration
273 * @param configurator
274 * @return UpdateResult
276 public UpdateResult
setSecundumForSubtree(SecundumForSubtreeConfigurator config
);
280 * Sets the publish flag for all taxa and/or synonyms of the subtree.
281 * @param configurator
284 public UpdateResult
setPublishForSubtree(PublishForSubtreeConfigurator configurator
);
287 * Returns a list of taxon node {@link UUID uuids} according to the given filter.
291 public long count(TaxonNodeFilter filter
);
294 * Returns a list of taxon node {@link UUID uuids} according to the given filter.
298 public List
<UUID
> uuidList(TaxonNodeFilter filter
);
301 * Returns a list of taxon node IDs according to the given filter.
305 public List
<Integer
> idList(TaxonNodeFilter filter
);
308 // * @param configurator
311 // UUID monitSetSecundum(SecundumForSubtreeConfigurator configurator);
318 List
<TaxonNodeDto
> listChildNodesAsTaxonNodeDto(UuidAndTitleCache
<TaxonNode
> parent
);
324 List
<TaxonNodeDto
> listChildNodesAsTaxonNodeDto(ITaxonTreeNode parent
);
327 * @param taxonNodeUuids
328 * @param newParentNodeUuid
333 UpdateResult
moveTaxonNodes(Set
<UUID
> taxonNodeUuids
, UUID newParentNodeUuid
, int movingType
,
334 IProgressMonitor monitor
);
337 * Retrieves the first taxon node that is direct or indirect parent
338 * to all nodes of the given list of nodes. This can also return
339 * the root node of a classification<br>
340 * If no common parent node could be found <code>null</code> is returned.
341 * @param nodes the direct/indirect child taxon nodes for which the common
342 * parent should be retrieved
343 * @return the common direct/indirect parent of all nodes
345 public TaxonNodeDto
findCommonParentDto(Collection
<TaxonNodeDto
> nodes
);
348 * @param taxonNodeUuid
351 TaxonNodeDto
dto(UUID taxonNodeUuid
);
354 * @param parentNodeUuid
358 List
<TaxonDistributionDTO
> getTaxonDistributionDTOForSubtree(UUID parentNodeUuid
, List
<String
> propertyPaths
);
361 * @param parentNodeUuid
362 * @param newTaxonNode
365 UpdateResult
saveNewTaxonNode(TaxonNode newTaxonNode
);
369 * @param restrictions
373 * @param propertyPaths
374 * @param includeUnpublished
377 public <S
extends TaxonNode
> Pager
<S
> page(Class
<S
> clazz
, List
<Restriction
<?
>> restrictions
, Integer pageSize
, Integer pageIndex
,
378 List
<OrderHint
> orderHints
, List
<String
> propertyPaths
, boolean includeUnpublished
);