View Javadoc
1   /*
2    * To change this license header, choose License Headers in Project Properties.
3    * To change this template file, choose Tools | Templates
4    * and open the template in the editor.
5    */
6   
7   package fr.ifremer.reefdb.service.administration.context;
8   
9   /*
10   * #%L
11   * Reef DB :: Core
12   * $Id:$
13   * $HeadURL:$
14   * %%
15   * Copyright (C) 2014 - 2015 Ifremer
16   * %%
17   * This program is free software: you can redistribute it and/or modify
18   * it under the terms of the GNU Affero General Public License as published by
19   * the Free Software Foundation, either version 3 of the License, or
20   * (at your option) any later version.
21   * 
22   * This program is distributed in the hope that it will be useful,
23   * but WITHOUT ANY WARRANTY; without even the implied warranty of
24   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25   * GNU General Public License for more details.
26   * 
27   * You should have received a copy of the GNU Affero General Public License
28   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
29   * #L%
30   */
31  
32  import fr.ifremer.reefdb.dto.configuration.context.ContextDTO;
33  import fr.ifremer.reefdb.dto.configuration.filter.FilterDTO;
34  import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO;
35  import fr.ifremer.reefdb.dto.data.survey.CampaignDTO;
36  import fr.ifremer.reefdb.dto.referential.*;
37  import fr.ifremer.reefdb.dto.referential.pmfm.PmfmDTO;
38  import org.springframework.security.access.prepost.PreAuthorize;
39  import org.springframework.transaction.annotation.Transactional;
40  
41  import java.io.File;
42  import java.util.Collection;
43  import java.util.List;
44  
45  /**
46   * <p>ContextService interface.</p>
47   *
48   * @author Lionel Touseau <lionel.touseau@e-is.pro>
49   */
50  @Transactional(readOnly = true)
51  public interface ContextService {
52      
53  	/**
54  	 * renvoit un contexte local en fonction d'un Id
55  	 *
56  	 * @param contextId a {@link java.lang.Integer} object.
57  	 * @return un contexte local
58  	 */
59  	ContextDTO getContext(Integer contextId);
60      
61  	/**
62  	 * Recupere la liste des contextes locaux
63  	 *
64  	 * @return une liste de contextes locaux
65  	 */
66  	List<ContextDTO> getAllContexts();
67  
68      /**
69       * <p>saveContexts.</p>
70       *
71       * @param contexts a {@link java.util.List} object.
72       */
73      @Transactional()
74      @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
75      void saveContexts(List<? extends ContextDTO> contexts);
76      
77      /**
78       * <p>deleteContexts.</p>
79       *
80       * @param contexts a {@link java.util.List} object.
81       */
82      @Transactional()
83      @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
84      void deleteContexts(List<? extends ContextDTO> contexts);
85  
86      /**
87       * <p>importContexts.</p>
88       *
89       * @param sourceContextFile a {@link java.io.File} object.
90       * @return a {@link java.util.List} object.
91       */
92      @Transactional()
93      @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
94      List<ContextDTO> importContexts(File sourceContextFile);
95      
96      /**
97       * <p>exportContexts.</p>
98       *
99       * @param contexts a {@link Collection} object.
100      * @param targetContextFile a {@link File} object.
101 	 */
102     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
103 	void exportContexts(Collection<ContextDTO> contexts, File targetContextFile);
104     
105     /**
106      * Get all filters by type
107      *
108      * @param filterTypeId a int.
109      * @return a {@link java.util.List} object.
110      */
111     List<FilterDTO> getFiltersByType(int filterTypeId);
112 
113     /**
114      * <p>getFilter.</p>
115      *
116      * @param filterId a {@link java.lang.Integer} object.
117      * @return a {@link fr.ifremer.reefdb.dto.configuration.filter.FilterDTO} object.
118      */
119     FilterDTO getFilter(Integer filterId);
120 
121     /**
122      * Load all filtered elements in filter
123      *
124      * @param filter a {@link fr.ifremer.reefdb.dto.configuration.filter.FilterDTO} object.
125      */
126     void loadFilteredElements(FilterDTO filter);
127 
128     /**
129      * CAUTION. Returns filters only, without filtered elements
130      *
131      * @return a {@link java.util.List} object.
132      */
133     List<FilterDTO> getAllDepartmentFilters();
134 
135 	/**
136 	 * All departments for context
137 	 *
138 	 * @param contextId context identifier
139 	 * @return Departments
140 	 */
141 	List<DepartmentDTO> getFilteredDepartments(Integer contextId);
142 	
143 
144     /**
145      * CAUTION. Returns filters only, without filtered elements
146      *
147      * @return Filters
148      */
149     List<FilterDTO> getAllSamplingEquipmentFilters();
150 
151 
152 	/**
153 	 * All sampling equipment for context
154 	 *
155 	 * @param contextId context identifier
156 	 * @return Sampling equipment
157 	 */
158 	List<SamplingEquipmentDTO> getFilteredSamplingEquipments(Integer contextId);
159 	
160     /**
161      * CAUTION. Returns filters only, without filtered elements
162      *
163      * @return Filters
164      */
165     List<FilterDTO> getAllAnalysisInstrumentFilters();
166 
167 	/**
168 	 * All analysis instrument for context
169 	 *
170 	 * @param contextId context identifier
171 	 * @return Analysis instrument
172 	 */
173 	List<AnalysisInstrumentDTO> getFilteredAnalysisInstruments(Integer contextId);
174 	
175     /**
176      * <p>Save generic filter</p>
177      * <p>The filter type id must be set before calling this method</p>
178      *
179      * @param filter a {@link fr.ifremer.reefdb.dto.configuration.filter.FilterDTO} object.
180      */
181     @Transactional()
182     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
183     void saveFilter(FilterDTO filter);
184     
185     /**
186      * <p>Save generic filters</p>
187      * <p>The filter type id must be set on each filter before calling this method</p>
188      *
189      * @param filters a {@link java.util.List} object.
190      */
191     @Transactional()
192     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
193     void saveFilters(List<? extends FilterDTO> filters);
194 
195     /**
196      * CAUTION. Returns filters only, without filtered elements
197      *
198      * @return Filters
199      */
200     List<FilterDTO> getAllPmfmFilters();
201 
202 	/**
203 	 * All pmfm for context
204 	 *
205 	 * @param contextId context identifier
206 	 * @return Pmfm list
207 	 */
208 	List<PmfmDTO> getFilteredPmfms(Integer contextId);
209     
210     /**
211      * CAUTION. Returns filters only, without filtered elements
212      *
213      * @return filters
214      */
215     List<FilterDTO> getAllTaxonFilters();
216 
217 	/**
218 	 * All taxon for context
219 	 *
220 	 * @param contextId context identifier
221 	 * @return Taxon
222 	 */
223 	List<TaxonDTO> getFilteredTaxons(Integer contextId);
224 	
225     /**
226      * CAUTION. Returns filters only, without filtered elements
227      *
228      * @return filters
229      */
230     List<FilterDTO> getAllTaxonGroupFilters();
231 
232 	/**
233 	 *
234 	 * All taxon group for context
235 	 *
236 	 * @param contextId context identifier
237 	 * @return Taxon group
238 	 */
239 	List<TaxonGroupDTO> getFilteredTaxonGroups(Integer contextId);
240     
241     /**
242      * CAUTION. Returns filters only, without filtered elements
243      *
244      * @return filters
245      */
246     List<FilterDTO> getAllLocationFilter();
247 
248 	/**
249 	 * All locations for context
250 	 *
251 	 * @param contextId context identifier
252 	 * @return Locations
253 	 */
254 	List<LocationDTO> getFilteredLocations(Integer contextId);
255 	
256     /**
257      * CAUTION. Returns filters only, without filtered elements
258      *
259      * @return filters
260      */
261     List<FilterDTO> getAllUserFilter();
262 
263 	/**
264 	 * All users for context
265 	 *
266 	 * @param contextId context identifier
267 	 * @return Locations
268 	 */
269 	List<PersonDTO> getFilteredUsers(Integer contextId);
270 
271     /**
272      * CAUTION. Returns filters only, without filtered elements
273      *
274      * @return filters
275      */
276     List<FilterDTO> getAllProgramFilter();
277 
278 	/**
279 	 * All programs for context
280 	 *
281 	 * @param contextId context identifier
282 	 * @return Programs
283 	 */
284 	List<ProgramDTO> getFilteredPrograms(Integer contextId);
285 
286 	/**
287 	 * CAUTION. Returns filters only, without filtered elements
288 	 *
289 	 * @return filters
290 	 */
291 	List<FilterDTO> getAllCampaignFilter();
292 
293 	/**
294 	 * All campaigns for context
295 	 *
296 	 * @param contextId context identifier
297 	 * @return Campaigns
298 	 */
299 	List<CampaignDTO> getFilteredCampaigns(Integer contextId);
300 
301 	/**
302      * Check if the filters are not used in any context
303      *
304      * @param filters the filter list to check
305      * @return true if all filters in the list are free ^^, false if at least one filter is used
306      */
307     boolean checkFiltersNotUsedInContext(List<? extends FilterDTO> filters);
308 
309     /**
310      * <p>deleteFilters.</p>
311      *
312      * @param filters a {@link java.util.List} object.
313      */
314     @Transactional()
315     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
316     void deleteFilters(List<? extends FilterDTO> filters);
317     
318     /**
319      * <p>importFilter.</p>
320      *
321      * @param sourceFilterFile a {@link java.io.File} object.
322      * @param filterTypeId a int.
323      * @return a {@link java.util.List} object.
324      */
325     @Transactional()
326     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
327     List<FilterDTO> importFilter(File sourceFilterFile, int filterTypeId);
328     
329     /**
330      * <p>exportFilter.</p>
331      *
332      * @param filters a {@link Collection} object.
333      * @param targetFilterFile a {@link File} object.
334 	 */
335     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
336 	void exportFilter(Collection<FilterDTO> filters, File targetFilterFile);
337 
338     /**
339      * <p>duplicateContext.</p>
340      *
341      * @param context a {@link fr.ifremer.reefdb.dto.configuration.context.ContextDTO} object.
342      * @return a {@link fr.ifremer.reefdb.dto.configuration.context.ContextDTO} object.
343      */
344     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
345     ContextDTO duplicateContext(ContextDTO context);
346     
347     /**
348      * <p>duplicateFilter.</p>
349      *
350      * @param filter a {@link fr.ifremer.reefdb.dto.configuration.filter.FilterDTO} object.
351      * @return a {@link fr.ifremer.reefdb.dto.configuration.filter.FilterDTO} object.
352      */
353     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
354     FilterDTO duplicateFilter(final FilterDTO filter);
355 
356 }