ref #7745 add subtree filter to missing methods (childNodesOf is still missing implem...
[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, TaxonNode subtree, Rank baseRank, boolean includeUnpublished,
175 List<String> propertyPaths) throws UnpublishedException;
176 public List<TaxonNode> loadTreeBranch(TaxonNode taxonNode, Rank baseRank, boolean includeUnpublished,
177 List<String> propertyPaths) throws UnpublishedException;
178
179 /**
180 * Although this method seems to be a redundant alternative to {@link #loadChildNodesOfTaxonNode(TaxonNode, List)} it is an important
181 * alternative from which web services benefit. Without this method the web service controller method, which operates outside of the
182 * transaction, would have to initialize the full taxon tree with all nodes of the taxon.
183 * This would be rather slow compared to using this method.
184 * @param taxon
185 * @param classification
186 * the classification to be used
187 * @param baseRank
188 * specifies the root level of the classification, may be null.
189 * Nodes of this rank or in case this rank does not exist in the
190 * current branch the next lower rank is taken as as root node for
191 * this rank henceforth called the <b>base node</b>.
192 * @param includeUnpublished
193 * if <code>true</code> no {@link UnpublishedException}
194 * is thrown if any of the taxa in the branch are unpublished
195 * @param propertyPaths
196 * the initialization strategy for the returned TaxonNode
197 * instances.
198 * @return the path of nodes from the <b>base node</b> to the node of the specified
199 * taxon.
200 * @throws UnpublishedException
201 * if any of the taxa in the path is unpublished an {@link UnpublishedException} is thrown
202 */
203 public List<TaxonNode> loadTreeBranchToTaxon(Taxon taxon, Classification classification,
204 TaxonNode subtree, Rank baseRank,
205 boolean includeUnpublished, List<String> propertyPaths) throws UnpublishedException;
206 public List<TaxonNode> loadTreeBranchToTaxon(Taxon taxon, Classification classification,
207 Rank baseRank,
208 boolean includeUnpublished, List<String> propertyPaths) throws UnpublishedException;
209
210 public List<TaxonNode> listChildNodesOfTaxon(UUID taxonUuid, UUID classificationUuid, boolean includeUnpublished,
211 Integer pageSize, Integer pageIndex, List<String> propertyPaths);
212 public List<TaxonNode> listChildNodesOfTaxon(UUID taxonUuid, UUID classificationUuid, UUID subtreeUuid, boolean includeUnpublished,
213 Integer pageSize, Integer pageIndex, List<String> propertyPaths);
214
215
216 /**
217 * @param taxonNode
218 * @param propertyPaths
219 * @deprecated move to TaxonNodeService
220 * @return
221 */
222 @Deprecated
223 public List<TaxonNode> loadChildNodesOfTaxonNode(TaxonNode taxonNode, List<String> propertyPaths);
224
225 /**
226 *
227 * @param classification
228 * @return
229 */
230 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(Classification classification);
231
232 public Map<UUID, List<MediaRepresentation>> getAllMediaForChildNodes(TaxonNode taxonNode, List<String> propertyPaths, int size, int height, int widthOrDuration, String[] mimeTypes);
233
234 /**
235 *
236 * @param taxonNode
237 * @return
238 * @deprecated use TaxonNodeService instead
239 */
240 @Deprecated
241 public UUID removeTaxonNode(TaxonNode taxonNode);
242
243 /**
244 *
245 * @param taxonNode
246 * @return
247 * @deprecated use TaxonNodeService instead
248 */
249 @Deprecated
250 public UUID saveTaxonNode(TaxonNode taxonNode);
251
252 /**
253 *
254 * @param taxonNodeCollection
255 * @return
256 * @deprecated use TaxonNodeService instead
257 */
258 @Deprecated
259 public Map<UUID, TaxonNode> saveTaxonNodeAll(Collection<TaxonNode> taxonNodeCollection);
260
261 public UUID removeTreeNode(ITaxonTreeNode treeNode);
262
263 public UUID saveTreeNode(ITaxonTreeNode treeNode);
264
265 public List<TaxonNode> getAllNodes();
266
267 public UpdateResult createHierarchyInClassification(Classification classification, CreateHierarchyForClassificationConfigurator configurator);
268
269 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(UUID classificationUuid);
270
271 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
272 UUID classificationUuid, Integer limit, String pattern);
273
274 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
275 Classification classification, Integer limit, String pattern);
276
277 public List<TaxonNode> listSiblingsOfTaxon(UUID taxonUuid, UUID classificationUuid, boolean includeUnpublished,
278 Integer pageSize, Integer pageIndex, List<String> propertyPaths);
279
280 public Pager<TaxonNode> pageSiblingsOfTaxon(UUID taxonUuid, UUID classificationUuid, boolean includeUnpublished, Integer pageSize, Integer pageIndex,
281 List<String> propertyPaths);
282
283 public ClassificationLookupDTO classificationLookup(Classification classification);
284
285 public DeleteResult delete(UUID classificationUuid, TaxonDeletionConfigurator config);
286
287 /**
288 * Returns the higher taxon id for each taxon in taxonUuids.
289 * The highter taxon is defined by rank where the lowest rank equal or above minRank
290 * is taken. If maxRank <> null and no taxon exists with minRank <= rank <= maxRank
291 * no higher taxon is returned for this taxon.
292 *
293 * @param taxonUuids
294 * @param minRank
295 * @param maxRank
296 * @return
297 */
298 public List<GroupedTaxonDTO> groupTaxaByHigherTaxon(List<UUID> taxonUuids, UUID classificationUuid, Rank minRank, Rank maxRank);
299
300 /**
301 * @param taxonUuids
302 * @param classificationUuid
303 * @param markerType
304 * @param value
305 * @return
306 */
307 public List<GroupedTaxonDTO> groupTaxaByMarkedParents(List<UUID> taxonUuids, UUID classificationUuid,
308 MarkerType markerType, Boolean value);
309
310
311 /**
312 * Returns the most relevant data of a taxon/taxon node, including children, synonyms
313 * and certain ancestors if required.
314 * @param classificationUuid
315 * @param taxonUuid
316 * @param doSynonyms
317 * @param includeUnpublished
318 * @param ancestorMarkers
319 * @return
320 */
321 public TaxonInContextDTO getTaxonInContext(UUID classificationUuid, UUID taxonUuid,
322 Boolean doChildren, Boolean doSynonyms, boolean includeUnpublished, List<UUID> ancestorMarkers,
323 NodeSortMode sortMode);
324
325 /**
326 * @param classification
327 * @return
328 */
329 public UUID saveClassification(Classification classification);
330
331 /**
332 * @param classificationUuid
333 * @param limit
334 * @param pattern
335 * @param searchForClassifications
336 * @return
337 */
338 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
339 UUID classificationUuid, Integer limit, String pattern, boolean searchForClassifications);
340
341 /**
342 * @param classification
343 * @param limit
344 * @param pattern
345 * @param searchForClassifications
346 * @return
347 */
348 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
349 Classification classification, Integer limit, String pattern, boolean searchForClassifications);
350
351 /**
352 * @param classificationUuid
353 * @param searchForClassifications
354 * @return
355 */
356 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
357 UUID classificationUuid, boolean searchForClassifications);
358
359 /**
360 * @param classification
361 * @param searchForClassifications
362 * @return
363 */
364 public List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
365 Classification classification, boolean searchForClassifications);
366
367 }