1 package fr.ifremer.reefdb.dao.referential;
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.UnitDTO;
27 import org.springframework.cache.annotation.CacheEvict;
28 import org.springframework.cache.annotation.Cacheable;
29
30 import java.util.List;
31
32 /**
33 * Created by Ludovic on 28/07/2015.
34 */
35 public interface ReefDbUnitDao {
36
37 String ALL_UNITS_CACHE = "all_units";
38 String UNIT_BY_ID_CACHE = "unit_by_id";
39
40 /**
41 * <p>getAllUnits.</p>
42 *
43 * @param statusCodes a {@link java.util.List} object.
44 * @return a {@link java.util.List} object.
45 */
46 @Cacheable(value = ALL_UNITS_CACHE)
47 List<UnitDTO> getAllUnits(List<String> statusCodes);
48
49 /**
50 * <p>getUnitById.</p>
51 *
52 * @param unitId a int.
53 * @return a {@link fr.ifremer.reefdb.dto.referential.UnitDTO} object.
54 */
55 @Cacheable(value = UNIT_BY_ID_CACHE)
56 UnitDTO getUnitById(int unitId);
57
58 /**
59 * <p>findUnits.</p>
60 *
61 * @param unitId a {@link java.lang.Integer} object.
62 * @param statusCodes a {@link java.util.List} object.
63 * @return a {@link java.util.List} object.
64 */
65 List<UnitDTO> findUnits(Integer unitId, List<String> statusCodes);
66
67 /**
68 * <p>saveUnits.</p>
69 *
70 * @param units a {@link java.util.List} object.
71 */
72 @CacheEvict(value = {
73 ALL_UNITS_CACHE,
74 UNIT_BY_ID_CACHE
75 }, allEntries = true)
76 void saveUnits(List<? extends UnitDTO> units);
77
78 /**
79 * <p>deleteUnits.</p>
80 *
81 * @param unitIds a {@link java.util.List} object.
82 */
83 @CacheEvict(value = {
84 ALL_UNITS_CACHE,
85 UNIT_BY_ID_CACHE
86 }, allEntries = true)
87 void deleteUnits(List<Integer> unitIds);
88
89 /**
90 * <p>replaceTemporaryUnit.</p>
91 *
92 * @param sourceId a {@link java.lang.Integer} object.
93 * @param targetId a {@link java.lang.Integer} object.
94 * @param delete a boolean.
95 */
96 @CacheEvict(value = {
97 ALL_UNITS_CACHE,
98 UNIT_BY_ID_CACHE
99 }, allEntries = true)
100 void replaceTemporaryUnit(Integer sourceId, Integer targetId, boolean delete);
101
102 /**
103 * <p>isUnitUsedInReferential.</p>
104 *
105 * @param unitId a int.
106 * @return a boolean.
107 */
108 boolean isUnitUsedInReferential(int unitId);
109
110 /**
111 * <p>isUnitUsedInData.</p>
112 *
113 * @param unitId a int.
114 * @return a boolean.
115 */
116 boolean isUnitUsedInData(int unitId);
117
118 /**
119 * <p>isUnitUsedInValidatedData.</p>
120 *
121 * @param unitId a int.
122 * @return a boolean.
123 */
124 boolean isUnitUsedInValidatedData(int unitId);
125 }