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