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