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