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