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