1 package fr.ifremer.reefdb.dao.referential.taxon;
2
3 /*
4 * #%L
5 * Reef DB :: Core
6 * $Id:$
7 * $HeadURL:$
8 * %%
9 * Copyright (C) 2014 - 2015 Ifremer
10 * %%
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Affero General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU Affero General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * #L%
24 */
25
26 import fr.ifremer.reefdb.dto.referential.TaxonGroupDTO;
27 import org.springframework.cache.annotation.CacheEvict;
28 import org.springframework.cache.annotation.Cacheable;
29
30 import java.util.Collection;
31 import java.util.List;
32
33 /**
34 * <p>ReefDbTaxonGroupDao interface.</p>
35 *
36 */
37 public interface ReefDbTaxonGroupDao {
38
39 String ALL_TAXON_GROUPS_CACHE = "all_taxon_groups";
40 String TAXON_GROUP_BY_ID_CACHE = "taxon_group_by_id";
41 String TAXON_GROUPS_BY_IDS_CACHE = "taxon_groups_by_ids";
42
43 /**
44 * <p>getAllTaxonGroups.</p>
45 *
46 * @return a {@link java.util.List} object.
47 */
48 @Cacheable(value = ALL_TAXON_GROUPS_CACHE)
49 List<TaxonGroupDTO> getAllTaxonGroups();
50
51 /**
52 * <p>getTaxonGroupById.</p>
53 *
54 * @param taxonGroupId a int.
55 * @return a {@link fr.ifremer.reefdb.dto.referential.TaxonGroupDTO} object.
56 */
57 @Cacheable(value = TAXON_GROUP_BY_ID_CACHE)
58 TaxonGroupDTO getTaxonGroupById(int taxonGroupId);
59
60 /**
61 * <p>getTaxonGroupsByIds.</p>
62 *
63 * @param taxonGroupIds a {@link List} object.
64 * @return a {@link java.util.List} object.
65 */
66 @Cacheable(value = TAXON_GROUPS_BY_IDS_CACHE)
67 List<TaxonGroupDTO> getTaxonGroupsByIds(Collection<Integer> taxonGroupIds);
68
69 /**
70 * <p>findTaxonGroups.</p>
71 *
72 * @param parentTaxonGroupId a {@link java.lang.Integer} object.
73 * @param label a {@link java.lang.String} object.
74 * @param name a {@link java.lang.String} object.
75 * @param isStrictName a boolean.
76 * @param statusCodes a {@link java.util.List} object.
77 * @return a {@link java.util.List} object.
78 */
79 List<TaxonGroupDTO> findTaxonGroups(Integer parentTaxonGroupId, String label, String name, boolean isStrictName, List<String> statusCodes);
80
81 /**
82 * <p>saveTaxonGroups.</p>
83 *
84 * @param taxonGroups a {@link java.util.List} object.
85 */
86 @CacheEvict(value = {
87 ALL_TAXON_GROUPS_CACHE,
88 TAXON_GROUP_BY_ID_CACHE,
89 TAXON_GROUPS_BY_IDS_CACHE
90 }, allEntries = true)
91 void saveTaxonGroups(List<? extends TaxonGroupDTO> taxonGroups);
92
93 /**
94 * <p>deleteTaxonGroups.</p>
95 *
96 * @param taxonGroupIds a {@link java.util.List} object.
97 */
98 @CacheEvict(value = {
99 ALL_TAXON_GROUPS_CACHE,
100 TAXON_GROUP_BY_ID_CACHE,
101 TAXON_GROUPS_BY_IDS_CACHE
102 }, allEntries = true)
103 void deleteTaxonGroups(List<Integer> taxonGroupIds);
104
105 /**
106 * <p>replaceTemporaryTaxonGroup.</p>
107 *
108 * @param sourceId a {@link java.lang.Integer} object.
109 * @param targetId a {@link java.lang.Integer} object.
110 * @param delete a boolean.
111 */
112 @CacheEvict(value = {
113 ALL_TAXON_GROUPS_CACHE,
114 TAXON_GROUP_BY_ID_CACHE,
115 TAXON_GROUPS_BY_IDS_CACHE
116 }, allEntries = true)
117 void replaceTemporaryTaxonGroup(Integer sourceId, Integer targetId, boolean delete);
118
119 /**
120 * <p>isTaxonGroupUsedInReferential.</p>
121 *
122 * @param taxonGroupId a int.
123 * @return a boolean.
124 */
125 boolean isTaxonGroupUsedInReferential(int taxonGroupId);
126
127 /**
128 * <p>isTaxonGroupUsedInData.</p>
129 *
130 * @param taxonGroupId a int.
131 * @return a boolean.
132 */
133 boolean isTaxonGroupUsedInData(int taxonGroupId);
134
135 /**
136 * <p>isTaxonGroupUsedInValidatedData.</p>
137 *
138 * @param taxonGroupId a int.
139 * @return a boolean.
140 */
141 boolean isTaxonGroupUsedInValidatedData(int taxonGroupId);
142 }