ref #7745 implement subtree filter for ClassificationController.rankSpecificRootNotes...
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / service / IClassificationService.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.cdm.api.service;
11
12 import java.util.Collection;
13 import java.util.List;
14 import java.util.Map;
15 import java.util.UUID;
16
17 import eu.etaxonomy.cdm.api.service.config.CreateHierarchyForClassificationConfigurator;
18 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
19 import eu.etaxonomy.cdm.api.service.dto.GroupedTaxonDTO;
20 import eu.etaxonomy.cdm.api.service.dto.TaxonInContextDTO;
21 import eu.etaxonomy.cdm.api.service.pager.Pager;
22 import eu.etaxonomy.cdm.exception.UnpublishedException;
23 import eu.etaxonomy.cdm.model.common.MarkerType;
24 import eu.etaxonomy.cdm.model.media.MediaRepresentation;
25 import eu.etaxonomy.cdm.model.name.Rank;
26 import eu.etaxonomy.cdm.model.reference.Reference;
27 import eu.etaxonomy.cdm.model.taxon.Classification;
28 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
29 import eu.etaxonomy.cdm.model.taxon.Taxon;
30 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
31 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
32 import eu.etaxonomy.cdm.persistence.dto.ClassificationLookupDTO;
33 import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
34 import eu.etaxonomy.cdm.persistence.query.OrderHint;
35
36
37 /**
38 * @author n.hoffmann
39 * @since Sep 21, 2009
40 */
41 public interface IClassificationService extends IIdentifiableEntityService<Classification> {
42
43 /**
44 *
45 * @param uuid
46 * @return
47 */
48 public ITaxonTreeNode getTreeNodeByUuid(UUID uuid);
49
50 /**
51 *
52 * Returns the root node of the the given classification (specified by its UUID)
53 * @param classificationUuid the uuid of the classification
54 * @return the root node of the classification
55 */
56 public TaxonNode getRootNode(UUID classificationUuid);
57
58 public UUID getTaxonNodeUuidByTaxonUuid(UUID classificationUuid, UUID taxonUuid);
59
60 /**
61 * Clones an existing classification including all taxa and taxon nodes.
62 * @param name
63 * @param sec
64 * @param relationshipType
65 * @return
66 */
67 public UpdateResult cloneClassification(UUID classificationUuid, String name, Reference sec, TaxonRelationshipType relationshipType);
68
69 /**
70 *
71 * @param limit
72 * @param start
73 * @param orderHints
74 * @param propertyPaths
75 * @return
76 */
77 public List<Classification> listClassifications(Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths);
78
79 /**
80 *
81 * @param taxon
82 * @param classificationUuid
83 * @param propertyPaths
84 * @return
85 * @deprecated use loadTaxonNode(TaxonNode taxonNode, ...) instead
86 * if you have a classification and a taxon that is in it, you should also have the according taxonNode
87 */
88 @Deprecated
89 public TaxonNode loadTaxonNodeByTaxon(Taxon taxon, UUID classificationUuid, List<String> propertyPaths);
90
91 /**
92 * Loads all TaxonNodes of the specified classification for a given Rank or lower.
93 * If a branch of the classification tree is not containing a TaxonNode with a Taxon at the given
94 * Rank the according node associated with the next lower Rank is taken as root node in this case.
95 * So the nodes returned may reference Taxa with different Ranks.
96 *
97 * If the <code>rank</code> is null the absolute root nodes will be returned.
98
99 * @param classification may be null for all classifications
100 * @param subtree filter on a taxonomic subtree
101 * @param rank the set to null for to get the root nodes of classifications
102 * @param includeUnpublished if <code>true</code> unpublished taxa are also exported
103 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
104 * @param pageIndex The offset (in pageSize chunks) from the start of the result set (0 - based)
105 * @param propertyPaths
106 * @return
107 * @see #pageRankSpecificRootNodes(Classification, TaxonNode, Rank, boolean, Integer, Integer, List)
108 *
109 */
110 public List<TaxonNode> listRankSpecificRootNodes(Classification classification, TaxonNode subtree,
111 Rank rank, boolean includeUnpublished, Integer pageSize, Integer pageIndex,
112 List<String> propertyPaths);
113
114
115 /**
116 * @see #listRankSpecificRootNodes(Classification, TaxonNode, Rank, boolean, Integer, Integer, List)
117 * @deprecated keep this for compatibility to older versions, might be removed in versions >5.3
118 */
119 @Deprecated
120 public List<TaxonNode> listRankSpecificRootNodes(Classification classification,
121 Rank rank, boolean includeUnpublished, Integer pageSize, Integer pageIndex,
122 List<String> propertyPaths);
123
124
125 /**
126 * Loads all TaxonNodes of the specified classification for a given Rank or lower.
127 * If a branch of the classification tree is not containing a TaxonNode with a Taxon at the given
128 * Rank the according node associated with the next lower Rank is taken as root node in this case.
129 * So the nodes returned may reference Taxa with different Ranks.
130 *
131 * If the <code>rank</code> is null the absolute root nodes will be returned.
132 *
133 * @param classification may be null for all classifications
134 * @param subtree the taxonomic subtree filter
135 * @param rank the set to null for to get the root nodes of classifications
136 * @param includeUnpublished if <code>true</code> unpublished taxa are also exported
137 * @param pageSize The maximum number of relationships returned (can be null for all relationships)
138 * @param pageIndex The offset (in pageSize chunks) from the start of the result set (0 - based)
139 * @param propertyPaths
140 * @return
141 *
142 * @see #listRankSpecificRootNodes(Classification, TaxonNode, Rank, boolean, Integer, Integer, List)
143 */
144 public Pager<TaxonNode> pageRankSpecificRootNodes(Classification classification, TaxonNode subtree,
145 Rank rank, boolean includeUnpublished, Integer pageSize, Integer pageIndex,
146 List<String> propertyPaths);
147 /**
148 * @see #pageRankSpecificRootNodes(Classification, TaxonNode, Rank, boolean, Integer, Integer, List)
149 * @deprecated keep this for compatibility to older versions, might be removed in versions >5.3
150 */
151 @Deprecated
152 public Pager<TaxonNode> pageRankSpecificRootNodes(Classification classification,
153 Rank rank, boolean includeUnpublished, Integer pageSize, Integer pageIndex,
154 List<String> propertyPaths);
155
156 /**
157 * @param taxonNode
158 * @param baseRank
159 * specifies the root level of the classification, may be null.
160 * Nodes of this rank or in case this rank does not exist in the
161 * current branch the next lower rank is taken as root node for
162 * this rank henceforth called the <b>base node</b>.
163 * @param propertyPaths
164 * the initialization strategy for the returned TaxonNode
165 * instances.
166 * @param includeUnpublished
167 * if <code>true</code> no {@link UnpublishedException}
168 * is thrown if any of the taxa in the branch are unpublished
169 * @return the path of nodes from the <b>base node</b> to the node of the
170 * specified taxon.
171 * @throws UnpublishedException
172 * if any of the taxa in the path is unpublished an {@link UnpublishedException} is thrown.
173 */
174 public List<TaxonNode> loadTreeBranch(TaxonNode taxonNode, Rank baseRank, boolean includeUnpublished,
175 List<String> propertyPaths) throws UnpublishedException;
176
177 /**
178 * Although this method seems to be a redundant alternative to {@link #loadChildNodesOfTaxonNode(TaxonNode, List)} it is an important
179 * alternative from which web services benefit. Without this method the web service controller method, which operates outside of the
180 * transaction, would have to initialize the full taxon tree with all nodes of the taxon.
181 * This would be rather slow compared to using this method.
182 * @param taxon
183 * @param classification
184 * the classification to be used
185 * @param baseRank
186 * specifies the root level of the classification, may be null.
187 * Nodes of this rank or in case this rank does not exist in the
188 * current branch the next lower rank is taken as as root node for
189 * this rank henceforth called the <b>base node</b>.
190 * @param includeUnpublished
191 * if <code>true</code> no {@link UnpublishedException}
192 * is thrown if any of the taxa in the branch are unpublished
193 * @param propertyPaths
194 * the initialization strategy for the returned TaxonNode
195 * instances.
196 * @return the path of nodes from the <b>base node</b> to the node of the specified
197 * taxon.
198 * @throws UnpublishedException
199 * if any of the taxa in the path is unpublished an {@link UnpublishedException} is thrown
200 */
201 public List<TaxonNode> loadTreeBranchToTaxon(Taxon taxon, Classification classification, Rank baseRank,
202 boolean includeUnpublished, List<String> propertyPaths) throws UnpublishedException;
203
204 public List<TaxonNode> listChildNodesOfTaxon(UUID taxonUuid, UUID classificationUuid, boolean includeUnpublished,
205 Integer pageSize, Integer pageIndex, List<String> propertyPaths);
206
207 /**
208 * @param taxonNode
209 * @param propertyPaths
210 * @deprecated move to TaxonNodeService
211 * @return
212 */
213 @Deprecated
214 public List<TaxonNode> loadChildNodesOfTaxonNode(TaxonNode taxonNode, List<String> propertyPaths);
215
216 /**
217 *
218 * @param classification
219 * @return
220 */
221 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(Classification classification);
222
223 public Map<UUID, List<MediaRepresentation>> getAllMediaForChildNodes(TaxonNode taxonNode, List<String> propertyPaths, int size, int height, int widthOrDuration, String[] mimeTypes);
224
225 /**
226 *
227 * @param taxonNode
228 * @return
229 * @deprecated use TaxonNodeService instead
230 */
231 @Deprecated
232 public UUID removeTaxonNode(TaxonNode taxonNode);
233
234 /**
235 *
236 * @param taxonNode
237 * @return
238 * @deprecated use TaxonNodeService instead
239 */
240 @Deprecated
241 public UUID saveTaxonNode(TaxonNode taxonNode);
242
243 /**
244 *
245 * @param taxonNodeCollection
246 * @return
247 * @deprecated use TaxonNodeService instead
248 */
249 @Deprecated
250 public Map<UUID, TaxonNode> saveTaxonNodeAll(Collection<TaxonNode> taxonNodeCollection);
251
252 public UUID removeTreeNode(ITaxonTreeNode treeNode);
253
254 public UUID saveTreeNode(ITaxonTreeNode treeNode);
255
256 public List<TaxonNode> getAllNodes();
257
258 public UpdateResult createHierarchyInClassification(Classification classification, CreateHierarchyForClassificationConfigurator configurator);
259
260 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(UUID classificationUuid);
261
262 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
263 UUID classificationUuid, Integer limit, String pattern);
264
265 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
266 Classification classification, Integer limit, String pattern);
267
268 public List<TaxonNode> listSiblingsOfTaxon(UUID taxonUuid, UUID classificationUuid, boolean includeUnpublished,
269 Integer pageSize, Integer pageIndex, List<String> propertyPaths);
270
271 public Pager<TaxonNode> pageSiblingsOfTaxon(UUID taxonUuid, UUID classificationUuid, boolean includeUnpublished, Integer pageSize, Integer pageIndex,
272 List<String> propertyPaths);
273
274 public ClassificationLookupDTO classificationLookup(Classification classification);
275
276 public DeleteResult delete(UUID classificationUuid, TaxonDeletionConfigurator config);
277
278 /**
279 * Returns the higher taxon id for each taxon in taxonUuids.
280 * The highter taxon is defined by rank where the lowest rank equal or above minRank
281 * is taken. If maxRank <> null and no taxon exists with minRank <= rank <= maxRank
282 * no higher taxon is returned for this taxon.
283 *
284 * @param taxonUuids
285 * @param minRank
286 * @param maxRank
287 * @return
288 */
289 public List<GroupedTaxonDTO> groupTaxaByHigherTaxon(List<UUID> taxonUuids, UUID classificationUuid, Rank minRank, Rank maxRank);
290
291 /**
292 * @param taxonUuids
293 * @param classificationUuid
294 * @param markerType
295 * @param value
296 * @return
297 */
298 public List<GroupedTaxonDTO> groupTaxaByMarkedParents(List<UUID> taxonUuids, UUID classificationUuid,
299 MarkerType markerType, Boolean value);
300
301
302 /**
303 * Returns the most relevant data of a taxon/taxon node, including children, synonyms
304 * and certain ancestors if required.
305 * @param classificationUuid
306 * @param taxonUuid
307 * @param doSynonyms
308 * @param includeUnpublished
309 * @param ancestorMarkers
310 * @return
311 */
312 public TaxonInContextDTO getTaxonInContext(UUID classificationUuid, UUID taxonUuid,
313 Boolean doChildren, Boolean doSynonyms, boolean includeUnpublished, List<UUID> ancestorMarkers,
314 NodeSortMode sortMode);
315
316 /**
317 * @param classification
318 * @return
319 */
320 public UUID saveClassification(Classification classification);
321
322 /**
323 * @param classificationUuid
324 * @param limit
325 * @param pattern
326 * @param searchForClassifications
327 * @return
328 */
329 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
330 UUID classificationUuid, Integer limit, String pattern, boolean searchForClassifications);
331
332 /**
333 * @param classification
334 * @param limit
335 * @param pattern
336 * @param searchForClassifications
337 * @return
338 */
339 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
340 Classification classification, Integer limit, String pattern, boolean searchForClassifications);
341
342 /**
343 * @param classificationUuid
344 * @param searchForClassifications
345 * @return
346 */
347 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
348 UUID classificationUuid, boolean searchForClassifications);
349
350 /**
351 * @param classification
352 * @param searchForClassifications
353 * @return
354 */
355 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
356 Classification classification, boolean searchForClassifications);
357
358 }