1 package fr.ifremer.reefdb.dao.referential.taxon;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 import com.google.common.collect.Multimap;
27 import fr.ifremer.reefdb.dto.referential.TaxonDTO;
28 import fr.ifremer.reefdb.dto.referential.TaxonomicLevelDTO;
29 import org.springframework.cache.annotation.CacheEvict;
30 import org.springframework.cache.annotation.Cacheable;
31
32 import javax.annotation.Nonnull;
33 import java.time.LocalDate;
34 import java.util.List;
35 import java.util.Map;
36
37
38
39
40
41 public interface ReefDbTaxonNameDao {
42
43 String TAXON_NAME_BY_ID_CACHE = "taxon_name_by_id";
44 String TAXON_NAMES_BY_IDS_CACHE = "taxon_names_by_ids";
45 String TAXON_NAME_BY_REFERENCE_ID_CACHE = "taxon_name_by_reference_id";
46 String ALL_TAXON_NAMES_CACHE = "all_taxon_names";
47 String TAXON_NAME_BY_TAXON_GROUP_ID_CACHE = "taxon_name_by_taxon_group_id";
48 String COMPOSITE_TAXON_NAMES_BY_TAXON_NAME_ID_CACHE = "composite_taxon_names_by_taxon_name_id";
49 String TAX_REF_BY_TAXON_NAME_ID_CACHE = "tax_ref_by_taxon_name_id";
50 String WORMS_BY_TAXON_NAME_ID_CACHE = "worms_by_taxon_name_id";
51
52
53
54
55
56
57 @Cacheable(value = ALL_TAXON_NAMES_CACHE)
58 List<TaxonDTO> getAllTaxonNames();
59
60
61
62
63
64
65
66 @Cacheable(value = TAXON_NAME_BY_ID_CACHE)
67 TaxonDTO getTaxonNameById(int taxonId);
68
69
70
71
72
73
74
75 @Cacheable(value = TAXON_NAMES_BY_IDS_CACHE)
76 List<TaxonDTO> getTaxonNamesByIds(List<Integer> taxonIds);
77
78
79
80
81
82
83
84 @Cacheable(value = TAXON_NAME_BY_REFERENCE_ID_CACHE)
85 TaxonDTO getTaxonNameByReferenceId(int referenceTaxonId);
86
87
88
89
90
91
92
93
94 @Cacheable(value = TAXON_NAME_BY_TAXON_GROUP_ID_CACHE)
95 Multimap<Integer, TaxonDTO> getAllTaxonNamesMapByTaxonGroupId(@Nonnull LocalDate date);
96
97
98
99
100
101
102
103
104
105
106 List<TaxonDTO> findTaxonNamesByCriteria(String levelCode, String name, boolean isStrictName, Boolean isLocal);
107
108
109
110
111
112
113
114
115
116
117 List<TaxonDTO> findFullTaxonNamesByCriteria(String levelCode, String name, boolean isStrictName, Boolean isLocal);
118
119
120
121
122
123
124 void fillTaxonsProperties(List<TaxonDTO> taxons);
125
126
127
128
129
130
131 void fillParentAndReferent(TaxonDTO taxon);
132
133
134
135
136
137
138 void fillReferents(List<TaxonDTO> taxons);
139
140
141
142
143
144
145 @Cacheable(value = "all_taxonomic_levels")
146 List<TaxonomicLevelDTO> getAllTaxonomicLevels();
147
148
149
150
151
152
153
154 @Cacheable(value = COMPOSITE_TAXON_NAMES_BY_TAXON_NAME_ID_CACHE)
155 List<TaxonDTO> getCompositeTaxonNames(Integer taxonNameId);
156
157
158
159
160
161
162 @Cacheable(value = TAX_REF_BY_TAXON_NAME_ID_CACHE)
163 Map<Integer, String> getTaxRefByTaxonNameId();
164
165
166
167
168
169
170 @Cacheable(value = WORMS_BY_TAXON_NAME_ID_CACHE)
171 Map<Integer, String> getWormsByTaxonNameId();
172
173
174
175
176
177
178 @CacheEvict(value = {
179 TAXON_NAME_BY_ID_CACHE,
180 TAXON_NAMES_BY_IDS_CACHE,
181 TAXON_NAME_BY_REFERENCE_ID_CACHE,
182 ALL_TAXON_NAMES_CACHE,
183 TAXON_NAME_BY_TAXON_GROUP_ID_CACHE,
184 COMPOSITE_TAXON_NAMES_BY_TAXON_NAME_ID_CACHE
185 }, allEntries = true)
186 void saveTaxons(List<? extends TaxonDTO> taxons);
187
188
189
190
191
192
193 @CacheEvict(value = {
194 TAXON_NAME_BY_ID_CACHE,
195 TAXON_NAMES_BY_IDS_CACHE,
196 TAXON_NAME_BY_REFERENCE_ID_CACHE,
197 ALL_TAXON_NAMES_CACHE,
198 TAXON_NAME_BY_TAXON_GROUP_ID_CACHE,
199 COMPOSITE_TAXON_NAMES_BY_TAXON_NAME_ID_CACHE
200 }, allEntries = true)
201 void deleteTaxons(List<Integer> taxonIds);
202
203
204
205
206
207
208
209
210
211
212 @CacheEvict(value = {
213 TAXON_NAME_BY_ID_CACHE,
214 TAXON_NAMES_BY_IDS_CACHE,
215 TAXON_NAME_BY_REFERENCE_ID_CACHE,
216 ALL_TAXON_NAMES_CACHE,
217 TAXON_NAME_BY_TAXON_GROUP_ID_CACHE,
218 COMPOSITE_TAXON_NAMES_BY_TAXON_NAME_ID_CACHE
219 }, allEntries = true)
220 void replaceTemporaryTaxon(Integer sourceId, Integer sourceReferenceId, Integer targetId, Integer targetReferenceId, boolean delete);
221
222
223
224
225
226
227
228 boolean isTaxonNameUsedInReferential(int taxonId);
229
230
231
232
233
234
235
236
237 boolean isReferenceTaxonUsedInReferential(int refTaxonId, int excludedTaxonNameId);
238
239
240
241
242
243
244
245 boolean isReferenceTaxonUsedInData(int refTaxonId);
246
247
248
249
250
251
252
253 boolean isReferenceTaxonUsedInValidatedData(int refTaxonId);
254 }