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.dali.service.administration.context;
8   
9   /*
10   * #%L
11   * Dali :: 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.dali.dto.configuration.context.ContextDTO;
33  import fr.ifremer.dali.dto.configuration.filter.FilterDTO;
34  import fr.ifremer.dali.dto.configuration.programStrategy.ProgramDTO;
35  import fr.ifremer.dali.dto.data.survey.CampaignDTO;
36  import fr.ifremer.dali.dto.referential.*;
37  import fr.ifremer.dali.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  	String EXPORT_FILE_FORMAT = "dali-contexts-%s.dat";
54  
55  	/**
56  	 * renvoit un contexte local en fonction d'un Id
57  	 *
58  	 * @param contextId a {@link java.lang.Integer} object.
59  	 * @return un contexte local
60  	 */
61  	ContextDTO getContext(Integer contextId);
62      
63  	/**
64  	 * Recupere la liste des contextes locaux
65  	 *
66  	 * @return une liste de contextes locaux
67  	 */
68  	List<ContextDTO> getAllContexts();
69  
70      /**
71       * <p>saveContexts.</p>
72       *
73       * @param contexts a {@link java.util.List} object.
74       */
75      @Transactional()
76      @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
77      void saveContexts(List<? extends ContextDTO> contexts);
78      
79      /**
80       * <p>deleteContexts.</p>
81       *
82       * @param contexts a {@link java.util.List} object.
83       */
84      @Transactional()
85      @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
86      void deleteContexts(List<? extends ContextDTO> contexts);
87  
88      /**
89       * <p>importContexts.</p>
90       *
91       * @param sourceContextFile a {@link java.io.File} object.
92       * @return a {@link java.util.List} object.
93       */
94      @Transactional()
95      @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
96      List<ContextDTO> importContexts(File sourceContextFile);
97      
98      /**
99       * <p>exportContexts.</p>
100      *
101      * @param contexts a {@link Collection} object.
102      * @param targetContextFile a {@link File} object.
103 	 */
104     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
105 	void exportContexts(Collection<ContextDTO> contexts, File targetContextFile);
106     
107     /**
108      * Get all filters by type
109      *
110      * @param filterTypeId a int.
111      * @return a {@link java.util.List} object.
112      */
113     List<FilterDTO> getFiltersByType(int filterTypeId);
114 
115     /**
116      * <p>getFilter.</p>
117      *
118      * @param filterId a {@link java.lang.Integer} object.
119      * @return a {@link fr.ifremer.dali.dto.configuration.filter.FilterDTO} object.
120      */
121     FilterDTO getFilter(Integer filterId);
122 
123     /**
124      * Load all filtered elements in filter
125      *
126      * @param filter a {@link fr.ifremer.dali.dto.configuration.filter.FilterDTO} object.
127      */
128     void loadFilteredElements(FilterDTO filter);
129 
130     /**
131      * CAUTION. Returns filters only, without filtered elements
132      *
133      * @return a {@link java.util.List} object.
134      */
135     List<FilterDTO> getAllDepartmentFilters();
136 
137 	/**
138 	 * All departments for context
139 	 *
140 	 * @param contextId context identifier
141 	 * @return Departments
142 	 */
143 	List<DepartmentDTO> getFilteredDepartments(Integer contextId);
144 	
145 
146     /**
147      * CAUTION. Returns filters only, without filtered elements
148      *
149      * @return Filters
150      */
151     List<FilterDTO> getAllSamplingEquipmentFilters();
152 
153 
154 	/**
155 	 * All sampling equipment for context
156 	 *
157 	 * @param contextId context identifier
158 	 * @return Sampling equipment
159 	 */
160 	List<SamplingEquipmentDTO> getFilteredSamplingEquipments(Integer contextId);
161 	
162     /**
163      * CAUTION. Returns filters only, without filtered elements
164      *
165      * @return Filters
166      */
167     List<FilterDTO> getAllAnalysisInstrumentFilters();
168 
169 	/**
170 	 * All analysis instrument for context
171 	 *
172 	 * @param contextId context identifier
173 	 * @return Analysis instrument
174 	 */
175 	List<AnalysisInstrumentDTO> getFilteredAnalysisInstruments(Integer contextId);
176 	
177     /**
178      * <p>Save generic filter</p>
179      * <p>The filter type id must be set before calling this method</p>
180      *
181      * @param filter a {@link fr.ifremer.dali.dto.configuration.filter.FilterDTO} object.
182      */
183     @Transactional()
184     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
185     void saveFilter(FilterDTO filter);
186     
187     /**
188      * <p>Save generic filters</p>
189      * <p>The filter type id must be set on each filter before calling this method</p>
190      *
191      * @param filters a {@link java.util.List} object.
192      */
193     @Transactional()
194     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
195     void saveFilters(List<? extends FilterDTO> filters);
196 
197     /**
198      * CAUTION. Returns filters only, without filtered elements
199      *
200      * @return Filters
201      */
202     List<FilterDTO> getAllPmfmFilters();
203 
204 	/**
205 	 * All pmfm for context
206 	 *
207 	 * @param contextId context identifier
208 	 * @return Pmfm list
209 	 */
210 	List<PmfmDTO> getFilteredPmfms(Integer contextId);
211     
212     /**
213      * CAUTION. Returns filters only, without filtered elements
214      *
215      * @return filters
216      */
217     List<FilterDTO> getAllTaxonFilters();
218 
219 	/**
220 	 * All taxon for context
221 	 *
222 	 * @param contextId context identifier
223 	 * @return Taxon
224 	 */
225 	List<TaxonDTO> getFilteredTaxons(Integer contextId);
226 	
227     /**
228      * CAUTION. Returns filters only, without filtered elements
229      *
230      * @return filters
231      */
232     List<FilterDTO> getAllTaxonGroupFilters();
233 
234 	/**
235 	 *
236 	 * All taxon group for context
237 	 *
238 	 * @param contextId context identifier
239 	 * @return Taxon group
240 	 */
241 	List<TaxonGroupDTO> getFilteredTaxonGroups(Integer contextId);
242     
243     /**
244      * CAUTION. Returns filters only, without filtered elements
245      *
246      * @return filters
247      */
248     List<FilterDTO> getAllLocationFilter();
249 
250 	/**
251 	 * All locations for context
252 	 *
253 	 * @param contextId context identifier
254 	 * @return Locations
255 	 */
256 	List<LocationDTO> getFilteredLocations(Integer contextId);
257 	
258     /**
259      * CAUTION. Returns filters only, without filtered elements
260      *
261      * @return filters
262      */
263     List<FilterDTO> getAllUserFilter();
264 
265 	/**
266 	 * All users for context
267 	 *
268 	 * @param contextId context identifier
269 	 * @return Locations
270 	 */
271 	List<PersonDTO> getFilteredUsers(Integer contextId);
272 
273     /**
274      * CAUTION. Returns filters only, without filtered elements
275      *
276      * @return filters
277      */
278     List<FilterDTO> getAllProgramFilter();
279 
280 	/**
281 	 * All programs for context
282 	 *
283 	 * @param contextId context identifier
284 	 * @return Programs
285 	 */
286 	List<ProgramDTO> getFilteredPrograms(Integer contextId);
287 
288     /**
289      * CAUTION. Returns filters only, without filtered elements
290      *
291      * @return filters
292      */
293     List<FilterDTO> getAllCampaignFilter();
294 
295 	/**
296 	 * All campaigns for context
297 	 *
298 	 * @param contextId context identifier
299 	 * @return Campaigns
300 	 */
301 	List<CampaignDTO> getFilteredCampaigns(Integer contextId);
302 
303     /**
304      * Check if the filters are not used in any context
305      *
306      * @param filters the filter list to check
307      * @return true if all filters in the list are free ^^, false if at least one filter is used
308      */
309     boolean checkFiltersNotUsedInContext(List<? extends FilterDTO> filters);
310 
311     /**
312      * <p>deleteFilters.</p>
313      *
314      * @param filters a {@link java.util.List} object.
315      */
316     @Transactional()
317     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
318     void deleteFilters(List<? extends FilterDTO> filters);
319     
320     /**
321      * <p>importFilter.</p>
322      *
323      * @param sourceFilterFile a {@link java.io.File} object.
324      * @param filterTypeId a int.
325      * @return a {@link java.util.List} object.
326      */
327     @Transactional()
328     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
329     List<FilterDTO> importFilter(File sourceFilterFile, int filterTypeId);
330     
331     /**
332      * <p>exportFilter.</p>
333      *
334      * @param filters a {@link Collection} object.
335      * @param targetFilterFile a {@link File} object.
336 	 */
337     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
338 	void exportFilter(Collection<FilterDTO> filters, File targetFilterFile);
339 
340     /**
341      * <p>duplicateContext.</p>
342      *
343      * @param context a {@link fr.ifremer.dali.dto.configuration.context.ContextDTO} object.
344      * @return a {@link fr.ifremer.dali.dto.configuration.context.ContextDTO} object.
345      */
346     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
347     ContextDTO duplicateContext(ContextDTO context);
348     
349     /**
350      * <p>duplicateFilter.</p>
351      *
352      * @param filter a {@link fr.ifremer.dali.dto.configuration.filter.FilterDTO} object.
353      * @return a {@link fr.ifremer.dali.dto.configuration.filter.FilterDTO} object.
354      */
355     @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
356     FilterDTO duplicateFilter(final FilterDTO filter);
357 
358 }