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.MethodDTO;
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 ReefDbMethodDao {
37
38 String ALL_METHODS_CACHE = "all_methods";
39 String METHOD_BY_ID_CACHE = "method_by_id";
40
41 /**
42 * <p>getAllMethods.</p>
43 *
44 * @param statusCodes a {@link java.util.List} object.
45 * @return a {@link java.util.List} object.
46 */
47 @Cacheable(value = ALL_METHODS_CACHE)
48 List<MethodDTO> getAllMethods(List<String> statusCodes);
49
50 /**
51 * <p>getMethodById.</p>
52 *
53 * @param methodId a int.
54 * @return a {@link fr.ifremer.reefdb.dto.referential.pmfm.MethodDTO} object.
55 */
56 @Cacheable(value = METHOD_BY_ID_CACHE)
57 MethodDTO getMethodById(int methodId);
58
59 /**
60 * <p>findMethods.</p>
61 *
62 * @param methodId a {@link java.lang.Integer} object.
63 * @param statusCodes a {@link java.util.List} object.
64 * @return a {@link java.util.List} object.
65 */
66 List<MethodDTO> findMethods(Integer methodId, List<String> statusCodes);
67
68 /**
69 * <p>saveMethods.</p>
70 *
71 * @param methods a {@link java.util.List} object.
72 */
73 @CacheEvict(value = {
74 ALL_METHODS_CACHE,
75 METHOD_BY_ID_CACHE
76 }, allEntries = true)
77 void saveMethods(List<? extends MethodDTO> methods);
78
79 /**
80 * <p>deleteMethods.</p>
81 *
82 * @param methodIds a {@link java.util.List} object.
83 */
84 @CacheEvict(value = {
85 ALL_METHODS_CACHE,
86 METHOD_BY_ID_CACHE
87 }, allEntries = true)
88 void deleteMethods(List<Integer> methodIds);
89
90 /**
91 * <p>replaceTemporaryMethod.</p>
92 *
93 * @param sourceId a {@link java.lang.Integer} object.
94 * @param targetId a {@link java.lang.Integer} object.
95 * @param delete a boolean.
96 */
97 @CacheEvict(value = {
98 ALL_METHODS_CACHE,
99 METHOD_BY_ID_CACHE
100 }, allEntries = true)
101 void replaceTemporaryMethod(Integer sourceId, Integer targetId, boolean delete);
102
103 /**
104 * <p>isMethodUsedInProgram.</p>
105 *
106 * @param methodId a int.
107 * @return a boolean.
108 */
109 boolean isMethodUsedInProgram(int methodId);
110
111 /**
112 * <p>isMethodUsedInRules.</p>
113 *
114 * @param methodId a int.
115 * @return a boolean.
116 */
117 boolean isMethodUsedInRules(int methodId);
118
119 /**
120 * <p>isMethodUsedInReferential.</p>
121 *
122 * @param methodId a int.
123 * @return a boolean.
124 */
125 boolean isMethodUsedInReferential(int methodId);
126
127 }