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