Merge branch 'release/5.11.0'
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / persistence / dao / taxon / ITaxonNodeDao.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.persistence.dao.taxon;
11
12 import java.util.Collection;
13 import java.util.List;
14 import java.util.Map;
15 import java.util.Set;
16 import java.util.UUID;
17
18 import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
19 import eu.etaxonomy.cdm.model.common.TreeIndex;
20 import eu.etaxonomy.cdm.model.name.Rank;
21 import eu.etaxonomy.cdm.model.name.TaxonName;
22 import eu.etaxonomy.cdm.model.reference.Reference;
23 import eu.etaxonomy.cdm.model.taxon.Classification;
24 import eu.etaxonomy.cdm.model.taxon.Taxon;
25 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
26 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
27 import eu.etaxonomy.cdm.model.taxon.TaxonNodeAgentRelation;
28 import eu.etaxonomy.cdm.persistence.dao.common.IAnnotatableDao;
29 import eu.etaxonomy.cdm.persistence.dao.common.Restriction;
30 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
31 import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
32 import eu.etaxonomy.cdm.persistence.query.OrderHint;
33
34 /**
35 * @author a.mueller
36 *
37 */
38 public interface ITaxonNodeDao extends IAnnotatableDao<TaxonNode> {
39
40 public UUID delete(TaxonNode persistentObject, boolean deleteChildren);
41
42 /**
43 *
44 * @return
45 */
46 public List<TaxonNode> getTaxonOfAcceptedTaxaByClassification(Classification classification, Integer start, Integer end);
47
48 /**
49 * @param classification
50 * @return
51 */
52 public int countTaxonOfAcceptedTaxaByClassification(Classification classification);
53
54 /**
55 * Lists all direct child nodes of the given {@link UuidAndTitleCache} which
56 * represents the parent {@link TaxonNode}
57 * @param parent a UuidAndTitleCache object which represents a parent {@link TaxonNode}
58 * @return a list of UuidAndTitleCache objects that represent children of the
59 * parent
60 */
61 public List<UuidAndTitleCache<TaxonNode>> listChildNodesAsUuidAndTitleCache(UuidAndTitleCache<TaxonNode> parent);
62
63 /**
64 * Retrieves the parent node of the {@link TaxonNode} represented by the given {@link UuidAndTitleCache}.
65 * @param child the child for which the parent should be retrieved
66 * @return an UuidAndTitleCache object representing the parent node
67 */
68 public UuidAndTitleCache<TaxonNode> getParentUuidAndTitleCache(UuidAndTitleCache<TaxonNode> child);
69
70 /**
71 * Retrieves a list of {@link UuidAndTitleCache} objects that have a matching titleCache
72 * @param limit the maximum results
73 * @param pattern the titleCache that is searched for
74 * @param classificationUuid if specified only nodes of this classification are retrieved
75 * @return a list of matches
76 */
77 public List<UuidAndTitleCache<TaxonNode>> getUuidAndTitleCache(Integer limit, String pattern, UUID classificationUuid);
78
79 public List<TaxonNode> listChildrenOf(TaxonNode node, Integer pageSize, Integer pageIndex,
80 boolean recursive, boolean includeUnpublished, List<String> propertyPaths);
81
82 public abstract Long countChildrenOf(TaxonNode node, Classification classification, boolean recursive, boolean includeUnpublished);
83
84 /**
85 * Returns the of TaxonNodeAgentRelation entities which are associated with the TaxonNode for the
86 * given TaxonUuid in the specified Classification.
87 *
88 * @param taxonUuid
89 * @param agentUuid TODO
90 * @param relTypeUuid TODO
91 * @param start
92 * @param limit
93 * @param propertyPaths
94 * @param rankId TODO
95 * @param classification
96 * @return
97 */
98 List<TaxonNodeAgentRelation> listTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid,
99 UUID agentUuid, UUID rankUuid, UUID relTypeUuid, Integer start, Integer limit, List<String> propertyPaths);
100
101 /**
102 * Returns the number of TaxonNodeAgentRelation entities which are associated with the TaxonNode for the
103 * given TaxonUuid in the specified Classification.
104 *
105 * @param taxonUuid
106 * @param agentUuid TODO
107 * @param relTypeUuid TODO
108 * @param rankId TODO
109 * @param classification
110 * @return
111 */
112 long countTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid, UUID agentUuid, UUID rankUuid, UUID relTypeUuid);
113
114 /**
115 * Computes a map treeIndex->rank(sortIndex) for each given taxon node treeIndex. Required by #5957.
116 * If the taxon represented by the treeindex is not in the given rank range no record is returned for the given
117 * treeindex.
118 *
119 * @param treeIndex the list of treeIndexes
120 * @param minRankOrderIndex min rank
121 * @param maxRankOrderIndex max rank
122 * @return
123 */
124 Map<TreeIndex, Integer> rankOrderIndexForTreeIndex(List<TreeIndex> treeIndex, Integer minRankOrderIndex,
125 Integer maxRankOrderIndex);
126
127 /**
128 * For a given set of taxon node tree indexes the uuid and title cache of the taxon represented
129 * by this treeindex is returned.
130 * @param treeIndexSet set of taxon node tree indexes
131 * @return map with treeindex and uuidAndTitleCache of the represented taxon
132 */
133 public Map<TreeIndex, UuidAndTitleCache<?>> taxonUuidsForTreeIndexes(Collection<TreeIndex> treeIndexSet);
134
135
136
137 /**
138 * @param subTreeIndex
139 * @param newSec
140 * @param overwriteExistingAccepted
141 * @param includeSharedTaxa
142 * @param emptySecundumDetail
143 * @return
144 */
145 public int countSecundumForSubtreeAcceptedTaxa(TreeIndex subTreeIndex, Reference newSec,
146 boolean overwriteExistingAccepted, boolean includeSharedTaxa, boolean emptySecundumDetail);
147
148 /**
149 * @param subTreeIndex
150 * @param newSec
151 * @param overwriteExistingSynonyms
152 * @param includeSharedTaxa
153 * @param emptySecundumDetail
154 * @return
155 */
156 public int countSecundumForSubtreeSynonyms(TreeIndex subTreeIndex, Reference newSec,
157 boolean overwriteExistingSynonyms, boolean includeSharedTaxa, boolean emptySecundumDetail);
158
159 /**
160 * @param subTreeIndex
161 * @param newSec
162 * @param overwriteExisting
163 * @param includeSharedTaxa
164 * @param emptyDetail
165 * @param monitor
166 * @return
167 */
168 public Set<TaxonBase> setSecundumForSubtreeAcceptedTaxa(TreeIndex subTreeIndex, Reference newSec, boolean overwriteExisting, boolean includeSharedTaxa, boolean emptyDetail, IProgressMonitor monitor);
169
170 public Set<TaxonBase> setSecundumForSubtreeSynonyms(TreeIndex subTreeIndex, Reference newSec, boolean overwriteExisting, boolean includeSharedTaxa, boolean emptyDetail, IProgressMonitor monitor);
171
172
173 /**
174 * @param subTreeIndex
175 * @param includeSharedTaxa
176 * @param includeSharedTaxa2
177 * @return
178 */
179 public int countPublishForSubtreeAcceptedTaxa(TreeIndex subTreeIndex, boolean publish,
180 boolean includeSharedTaxa, boolean includeHybrids);
181 public Set<TaxonBase> setPublishForSubtreeAcceptedTaxa(TreeIndex subTreeIndex, boolean publish,
182 boolean includeSharedTaxa, boolean includeHybrids, IProgressMonitor monitor);
183
184 /**
185 * @param subTreeIndex
186 * @param includeSharedTaxa
187 * @return
188 */
189 public int countPublishForSubtreeSynonyms(TreeIndex subTreeIndex, boolean publish,
190 boolean includeSharedTaxa, boolean includeHybrids);
191 public Set<TaxonBase> setPublishForSubtreeSynonyms(TreeIndex subTreeIndex, boolean publish,
192 boolean includeSharedTaxa, boolean includeHybrids, IProgressMonitor monitor);
193
194 public int countPublishForSubtreeRelatedTaxa(TreeIndex subTreeIndex, boolean publish,
195 boolean includeSharedTaxa, boolean includeHybrids);
196 public Set<TaxonBase> setPublishForSubtreeRelatedTaxa(TreeIndex subTreeIndex, boolean publish,
197 Set<UUID> relationTypes, boolean includeSharedTaxa, boolean includeHybrids,
198 IProgressMonitor monitor);
199
200 /**
201 * @param parent
202 * @return
203 */
204 public List<TaxonNodeDto> listChildNodesAsTaxonNodeDto(UuidAndTitleCache<TaxonNode> parent);
205
206 /**
207 * @param classification
208 * @param limit
209 * @param pattern
210 * @return
211 */
212 List<UuidAndTitleCache<TaxonNode>> getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(
213 Classification classification, Integer limit, String pattern, boolean searchForClassifications);
214
215 /**
216 * @param type
217 * @param restrictions
218 * @param limit
219 * @param start
220 * @param orderHints
221 * @param propertyPaths
222 * @param includePublished
223 * @return
224 */
225 public <S extends TaxonNode> List<S> list(Class<S> type, List<Restriction<?>> restrictions, Integer limit, Integer start,
226 List<OrderHint> orderHints, List<String> propertyPaths, boolean includePublished);
227
228 /**
229 * @param type
230 * @param restrictions
231 * @param includePublished
232 * @return
233 */
234 long count(Class<? extends TaxonNode> type, List<Restriction<?>> restrictions, boolean includePublished);
235 /**
236 * get taxonNodeDto of parent with given rank
237 * @param classification
238 * @param rank
239 * @return
240 */
241 public TaxonNodeDto getParentTaxonNodeDtoForRank( Classification classification, Rank rank, TaxonName name);
242
243 }