1 package fr.ifremer.reefdb.service.observation;
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.quadrige3.core.ProgressionCoreModel;
27 import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgStratDTO;
28 import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO;
29 import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO;
30 import fr.ifremer.reefdb.dto.data.survey.CampaignDTO;
31 import fr.ifremer.reefdb.dto.data.survey.SurveyDTO;
32 import fr.ifremer.reefdb.dto.data.survey.SurveyFilterDTO;
33 import fr.ifremer.reefdb.dto.referential.*;
34 import fr.ifremer.reefdb.dto.referential.pmfm.PmfmDTO;
35 import org.springframework.security.access.prepost.PreAuthorize;
36 import org.springframework.transaction.annotation.Propagation;
37 import org.springframework.transaction.annotation.Transactional;
38
39 import java.time.LocalDate;
40 import java.util.Collection;
41 import java.util.List;
42
43 /**
44 * Le sevice pour les donnees de type Survey, SamplingOperation, Measurement
45 */
46 @Transactional(readOnly = true)
47 public interface ObservationService {
48
49 /**
50 * La liste des observations selectionnees suivant la campagne, le programme, le lieu, la date de début, la date de fin
51 *
52 * @param surveyFilter les parametres de recherche selectioné
53 * @return La liste des observations selectionnees
54 */
55 List<SurveyDTO> getSurveys(SurveyFilterDTO surveyFilter);
56
57 /**
58 * Recherche du detail d'une observation pour l'ecran detail via son identifiant.
59 *
60 * @param surveyId l identifiant de l observation
61 * @return Le detail de l'observation
62 */
63 SurveyDTO getSurvey(Integer surveyId);
64
65 /**
66 * <p>getSurveyWithoutPmfmFiltering.</p>
67 *
68 * @param surveyId a {@link java.lang.Integer} object.
69 * @return a {@link fr.ifremer.reefdb.dto.data.survey.SurveyDTO} object.
70 */
71 SurveyDTO getSurveyWithoutPmfmFiltering(Integer surveyId);
72
73 /**
74 * Save home observations.
75 * @param surveys Observations
76 * @param progressionModel progression model
77 */
78 @Transactional()
79 @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
80 void saveSurveys(Collection<? extends SurveyDTO> surveys, ProgressionCoreModel progressionModel);
81
82 /**
83 * Save detail observation.
84 *
85 * @param survey Observation
86 */
87 @Transactional()
88 @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
89 void saveSurvey(SurveyDTO survey);
90
91 /**
92 * Delete observations.
93 *
94 * @param surveyIds Observations to delete
95 */
96 @Transactional()
97 @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
98 void deleteSurveys(List<Integer> surveyIds);
99
100 /**
101 * Load all sampling operations of the survey and fill them inside the survey itself
102 *
103 * @param survey the survey to load
104 * @param withIndividualMeasurements a boolean.
105 */
106 void loadSamplingOperationsFromSurvey(SurveyDTO survey, boolean withIndividualMeasurements);
107
108 /**
109 * <p>newSamplingOperation.</p>
110 *
111 * @param survey a {@link fr.ifremer.reefdb.dto.data.survey.SurveyDTO} object.
112 * @param pmfms a {@link java.util.List} object.
113 * @return a {@link fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO} object.
114 */
115 @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
116 SamplingOperationDTO newSamplingOperation(SurveyDTO survey, List<PmfmDTO> pmfms);
117
118 /**
119 * Duplicate survey.
120 *
121 * @param survey survey to duplicate
122 * @param fullDuplication enable full duplication
123 * @param copyCoordinates enable copy coordinates
124 * @param duplicateSurveyMeasurements enable copy survey ungrouped measurements
125 * @return the duplicated survey
126 */
127 @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
128 SurveyDTO duplicateSurvey(SurveyDTO survey, boolean fullDuplication, boolean copyCoordinates, boolean duplicateSurveyMeasurements);
129
130 /**
131 * <p>getAvailablePrograms.</p>
132 *
133 * @param campaignId a {@link Integer} object.
134 * @param locationId a {@link Integer} object.
135 * @param date a {@link LocalDate} object.
136 * @param forceNoContext a boolean.
137 * @return a {@link java.util.List} object.
138 */
139 List<ProgramDTO> getAvailablePrograms(Integer campaignId, Integer locationId, LocalDate date, boolean forceNoContext);
140
141 List<CampaignDTO> getAvailableCampaigns(LocalDate date, boolean forceNoContext);
142
143 /**
144 * <p>getAvailableAnalysisInstruments.</p>
145 *
146 * @param forceNoContext a boolean.
147 * @return a {@link java.util.List} object.
148 */
149 List<AnalysisInstrumentDTO> getAvailableAnalysisInstruments(boolean forceNoContext);
150
151 /**
152 * <p>getAvailableSamplingEquipments.</p>
153 *
154 * @param forceNoContext a boolean.
155 * @return a {@link java.util.List} object.
156 */
157 List<SamplingEquipmentDTO> getAvailableSamplingEquipments(boolean forceNoContext);
158
159 /**
160 * <p>getAvailableLocations.</p>
161 *
162 * @param forceNoContext a boolean.
163 * @return a {@link java.util.List} object.
164 */
165 List<LocationDTO> getAvailableLocations(boolean forceNoContext);
166
167 /**
168 * <p>getAvailableLocations.</p>
169 *
170 * @param campaignId a {@link java.lang.Integer} object.
171 * @param programCode a {@link java.lang.String} object.
172 * @param forceNoContext a boolean.
173 * @return a {@link java.util.List} object.
174 */
175 List<LocationDTO> getAvailableLocations(Integer campaignId, String programCode, boolean forceNoContext);
176
177 /**
178 * <p>getAvailableTaxonGroups.</p>
179 *
180 * @param taxon a {@link TaxonDTO} object.
181 * @param forceNoContext a boolean.
182 * @return a {@link java.util.List} object.
183 */
184 List<TaxonGroupDTO> getAvailableTaxonGroups(TaxonDTO taxon, boolean forceNoContext);
185
186 /**
187 * <p>getAvailableTaxonGroups.</p>
188 *
189 * @param forceNoContext a boolean.
190 * @return a {@link java.util.List} object.
191 */
192 List<TaxonGroupDTO> getAvailableTaxonGroups(boolean forceNoContext);
193
194 /**
195 * <p>getAvailableTaxons.</p>
196 *
197 * @param taxonGroup a {@link TaxonGroupDTO} object.
198 * @param forceNoContext a boolean.
199 * @return a {@link java.util.List} object.
200 */
201 List<TaxonDTO> getAvailableTaxons(TaxonGroupDTO taxonGroup, boolean forceNoContext);
202
203 /**
204 * <p>getAvailableTaxons.</p>
205 *
206 * @param forceNoContext a boolean.
207 * @return a {@link java.util.List} object.
208 */
209 List<TaxonDTO> getAvailableTaxons(boolean forceNoContext);
210
211 /**
212 * <p>getAvailablePmfms.</p>
213 *
214 * @param forceNoContext a boolean.
215 * @return a {@link java.util.List} object.
216 */
217 List<PmfmDTO> getAvailablePmfms(boolean forceNoContext);
218
219 /**
220 * <p>getAvailableDepartments.</p>
221 *
222 * @param forceNoContext a boolean.
223 * @return a {@link java.util.List} object.
224 */
225 List<DepartmentDTO> getAvailableDepartments(boolean forceNoContext);
226
227 /**
228 * <p>getAvailableUsers.</p>
229 *
230 * @param forceNoFilter a boolean.
231 * @return a {@link java.util.List} object.
232 */
233 List<PersonDTO> getAvailableUsers(boolean forceNoFilter);
234
235 /**
236 * <p>isDataReadyToSynchronize.</p>
237 *
238 * @return a boolean.
239 */
240 boolean isDataReadyToSynchronize();
241
242 /**
243 * <p>validateSurveys.</p>
244 * new method to avoid memory limit reach (see Mantis #38832 &nd #42154)
245 * @param surveys a {@link Collection} object.
246 * @param validationComment a {@link String} object.
247 * @param progressionModel progression model
248 */
249 @Transactional(propagation = Propagation.NEVER)
250 @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).VALIDATOR)")
251 void validateSurveys(Collection<? extends SurveyDTO> surveys, String validationComment, ProgressionCoreModel progressionModel);
252
253 /**
254 * <p>unvalidateSurveys.</p>
255 * @param surveys a {@link Collection} object.
256 * @param unvalidationComment a {@link String} object.
257 * @param progressionModel progression model
258 */
259 @Transactional(propagation = Propagation.NEVER)
260 @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).VALIDATOR)")
261 void unvalidateSurveys(Collection<? extends SurveyDTO> surveys, String unvalidationComment, ProgressionCoreModel progressionModel);
262
263 /**
264 * <p>countSurveysWithProgramAndLocations.</p>
265 *
266 * @param programCode a {@link java.lang.String} object.
267 * @param locationIds a {@link java.util.List} object.
268 * @return a {@link java.lang.Long} object.
269 */
270 Long countSurveysWithProgramAndLocations(String programCode, List<Integer> locationIds);
271
272 Long countSurveysWithProgramLocationAndOutsideDates(String programCode, int appliedStrategyId, int locationId, LocalDate startDate, LocalDate endDate);
273
274 Long countSurveysWithProgramLocationAndInsideDates(String programCode, int appliedStrategyId, int locationId, LocalDate startDate, LocalDate endDate);
275
276 Long countSurveysWithProgramLocationAndOutsideDates(ProgStratDTO progStrat, int locationId);
277
278 Long countSurveysWithCampaign(int campaignId);
279
280 }