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