1 package fr.ifremer.reefdb.dao.referential.monitoringLocation;
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 fr.ifremer.reefdb.dto.CoordinateDTO;
27 import fr.ifremer.reefdb.dto.referential.HarbourDTO;
28 import fr.ifremer.reefdb.dto.referential.LocationDTO;
29 import org.springframework.cache.annotation.CacheEvict;
30 import org.springframework.cache.annotation.Cacheable;
31
32 import java.util.List;
33 import java.util.Map;
34
35
36
37
38 public interface ReefDbMonitoringLocationDao {
39
40 String ALL_LOCATIONS_CACHE = "all_locations";
41 String LOCATION_BY_ID_CACHE = "location_by_id";
42 String LOCATIONS_BY_IDS_CACHE = "locations_by_ids";
43 String LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE = "locations_by_campaign_and_program";
44 String ALL_HARBOURS_CACHE = "all_harbours";
45 String ALL_COORDINATES_CACHE = "all_coordinates";
46 String COORDINATE_BY_LOCATION_ID_CACHE = "coordinate_by_location_id";
47
48
49
50
51
52
53
54 @Cacheable(value = ALL_LOCATIONS_CACHE)
55 List<LocationDTO> getAllLocations(List<String> statusCodes);
56
57
58
59
60
61
62
63 @Cacheable(value = LOCATION_BY_ID_CACHE)
64 LocationDTO getLocationById(int locationId);
65
66
67
68
69
70
71
72 @Cacheable(value = LOCATIONS_BY_IDS_CACHE)
73 List<LocationDTO> getLocationsByIds(List<Integer> locationIds);
74
75
76
77
78
79
80
81
82 @Cacheable(value = LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE)
83 List<LocationDTO> getLocationsByCampaignAndProgram(Integer campaignId, String programCode);
84
85
86
87
88
89
90
91
92
93
94
95
96
97 List<LocationDTO> findLocations(List<String> statusCodes, String orderItemTypeCode, Integer orderItemId, String programCode, String label, String name, boolean isStrictName);
98
99
100
101
102
103
104 @CacheEvict(value = {
105 ALL_LOCATIONS_CACHE,
106 LOCATIONS_BY_IDS_CACHE,
107 LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE
108 }, allEntries = true)
109 void saveLocations(List<? extends LocationDTO> locations);
110
111
112
113
114
115
116 @CacheEvict(value = {
117 ALL_LOCATIONS_CACHE,
118 LOCATIONS_BY_IDS_CACHE,
119 LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE
120 }, allEntries = true)
121 void deleteLocations(List<Integer> locationIds);
122
123
124
125
126
127
128
129
130 @CacheEvict(value = {
131 ALL_LOCATIONS_CACHE,
132 LOCATIONS_BY_IDS_CACHE,
133 LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE
134 }, allEntries = true)
135 void replaceTemporaryLocation(Integer sourceId, Integer targetId, boolean delete);
136
137
138
139
140
141
142
143 boolean isLocationUsedInProgram(int locationId);
144
145
146
147
148
149
150
151 boolean isLocationUsedInData(int locationId);
152
153
154
155
156
157
158
159 boolean isLocationUsedInValidatedData(int locationId);
160
161
162
163
164
165
166
167 @Cacheable(value = ALL_HARBOURS_CACHE)
168 List<HarbourDTO> getAllHarbours(List<String> statusCodes);
169
170
171
172
173
174
175
176 @Cacheable(value = ALL_COORDINATES_CACHE)
177 Map<Integer, CoordinateDTO> getAllCoordinates();
178
179
180
181
182
183
184
185 @Cacheable(value = COORDINATE_BY_LOCATION_ID_CACHE)
186 CoordinateDTO getCoordinateByLocationId(int locationId);
187 }