1 package fr.ifremer.reefdb.dao.referential.pmfm;
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
27 import fr.ifremer.reefdb.dto.referential.pmfm.FractionDTO;
28 import org.springframework.cache.annotation.CacheEvict;
29 import org.springframework.cache.annotation.Cacheable;
30
31 import java.util.List;
32
33 /**
34 * Created by Ludovic on 29/07/2015.
35 */
36 public interface ReefDbFractionDao {
37
38 String FRACTION_BY_ID_CACHE = "fraction_by_id";
39 String FRACTIONS_BY_MATRIX_ID_CACHE = "fractions_by_matrix_id";
40 String ALL_FRACTIONS_CACHE = "all_fractions";
41
42 /**
43 * <p>getAllFractions.</p>
44 *
45 * @param statusCodes a {@link java.util.List} object.
46 * @return a {@link java.util.List} object.
47 */
48 @Cacheable(value = ALL_FRACTIONS_CACHE)
49 List<FractionDTO> getAllFractions(List<String> statusCodes);
50
51 /**
52 * <p>getFractionById.</p>
53 *
54 * @param fractionId a int.
55 * @return a {@link fr.ifremer.reefdb.dto.referential.pmfm.FractionDTO} object.
56 */
57 @Cacheable(value = FRACTION_BY_ID_CACHE)
58 FractionDTO getFractionById(int fractionId);
59
60 /**
61 * <p>getFractionsByMatrixId.</p>
62 *
63 * @param matrixId a {@link java.lang.Integer} object.
64 * @return a {@link java.util.List} object.
65 */
66 @Cacheable(value = FRACTIONS_BY_MATRIX_ID_CACHE)
67 List<FractionDTO> getFractionsByMatrixId(Integer matrixId);
68
69 /**
70 * <p>findFractions.</p>
71 *
72 * @param fractionId a {@link java.lang.Integer} object.
73 * @param statusCodes a {@link java.util.List} object.
74 * @return a {@link java.util.List} object.
75 */
76 List<FractionDTO> findFractions(Integer fractionId, List<String> statusCodes);
77
78 /**
79 * <p>saveFractions.</p>
80 *
81 * @param fractions a {@link java.util.List} object.
82 */
83 @CacheEvict(value = {
84 FRACTION_BY_ID_CACHE,
85 FRACTIONS_BY_MATRIX_ID_CACHE,
86 ALL_FRACTIONS_CACHE
87 }, allEntries = true)
88 void saveFractions(List<? extends FractionDTO> fractions);
89
90 /**
91 * <p>deleteFractions.</p>
92 *
93 * @param fractionIds a {@link java.util.List} object.
94 */
95 @CacheEvict(value = {
96 FRACTION_BY_ID_CACHE,
97 FRACTIONS_BY_MATRIX_ID_CACHE,
98 ALL_FRACTIONS_CACHE
99 }, allEntries = true)
100 void deleteFractions(List<Integer> fractionIds);
101
102 /**
103 * <p>replaceTemporaryFraction.</p>
104 *
105 * @param sourceId a {@link java.lang.Integer} object.
106 * @param targetId a {@link java.lang.Integer} object.
107 * @param delete a boolean.
108 */
109 @CacheEvict(value = {
110 FRACTION_BY_ID_CACHE,
111 FRACTIONS_BY_MATRIX_ID_CACHE,
112 ALL_FRACTIONS_CACHE
113 }, allEntries = true)
114 void replaceTemporaryFraction(Integer sourceId, Integer targetId, boolean delete);
115
116 /**
117 * <p>isFractionUsedInProgram.</p>
118 *
119 * @param fractionId a int.
120 * @return a boolean.
121 */
122 boolean isFractionUsedInProgram(int fractionId);
123
124 /**
125 * <p>isFractionUsedInRules.</p>
126 *
127 * @param fractionId a int.
128 * @return a boolean.
129 */
130 boolean isFractionUsedInRules(int fractionId);
131
132 /**
133 * <p>isFractionUsedInReferential.</p>
134 *
135 * @param fractionId a int.
136 * @return a boolean.
137 */
138 boolean isFractionUsedInReferential(int fractionId);
139
140 }