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