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