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