View Javadoc
1   package fr.ifremer.reefdb.dao.referential;
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.reefdb.dto.referential.SamplingEquipmentDTO;
27  import org.springframework.cache.annotation.CacheEvict;
28  import org.springframework.cache.annotation.Cacheable;
29  
30  import java.util.List;
31  
32  /**
33   * Created by Ludovic on 17/07/2015.
34   */
35  public interface ReefDbSamplingEquipmentDao {
36  
37      String SAMPLING_EQUIPMENT_BY_ID_CACHE = "sampling_equipment_by_id";
38      String ALL_SAMPLING_EQUIPMENTS_CACHE = "all_sampling_equipments";
39      String SAMPLING_EQUIPMENTS_BY_IDS_CACHE = "sampling_equipments_by_ids";
40  
41      /**
42       * <p>getAllSamplingEquipments.</p>
43       *
44       * @param statusCodes a {@link java.util.List} object.
45       * @return a {@link java.util.List} object.
46       */
47      @Cacheable(value = ALL_SAMPLING_EQUIPMENTS_CACHE)
48      List<SamplingEquipmentDTO> getAllSamplingEquipments(List<String> statusCodes);
49  
50      /**
51       * <p>getSamplingEquipmentById.</p>
52       *
53       * @param samplingEquipmentId a int.
54       * @return a {@link fr.ifremer.reefdb.dto.referential.SamplingEquipmentDTO} object.
55       */
56      @Cacheable(value = SAMPLING_EQUIPMENT_BY_ID_CACHE)
57      SamplingEquipmentDTO getSamplingEquipmentById(int samplingEquipmentId);
58  
59      /**
60       * <p>getSamplingEquipmentsByIds.</p>
61       *
62       * @param samplingEquipmentIds a {@link java.util.List} object.
63       * @return a {@link java.util.List} object.
64       */
65      @Cacheable(value = SAMPLING_EQUIPMENTS_BY_IDS_CACHE)
66      List<SamplingEquipmentDTO> getSamplingEquipmentsByIds(List<Integer> samplingEquipmentIds);
67  
68      /**
69       * <p>findSamplingEquipments.</p>
70       *
71       * @param statusCodes a {@link java.util.List} object.
72       * @param samplingEquipmentId a {@link java.lang.Integer} object.
73       * @param unitId a {@link java.lang.Integer} object.
74       * @return a {@link java.util.List} object.
75       */
76      List<SamplingEquipmentDTO> findSamplingEquipments(List<String> statusCodes, Integer samplingEquipmentId, Integer unitId);
77  
78      /**
79       * <p>findSamplingEquipmentsByName.</p>
80       *
81       * @param statusCodes a {@link java.util.List} object.
82       * @param samplingEquipmentName a {@link java.lang.String} object.
83       * @return a {@link java.util.List} object.
84       */
85      List<SamplingEquipmentDTO> findSamplingEquipmentsByName(List<String> statusCodes, String samplingEquipmentName);
86  
87      /**
88       * <p>saveSamplingEquipments.</p>
89       *
90       * @param samplingEquipments a {@link java.util.List} object.
91       */
92      @CacheEvict(value = {
93              ALL_SAMPLING_EQUIPMENTS_CACHE,
94              SAMPLING_EQUIPMENT_BY_ID_CACHE,
95              SAMPLING_EQUIPMENTS_BY_IDS_CACHE
96      }, allEntries = true)
97      void saveSamplingEquipments(List<? extends SamplingEquipmentDTO> samplingEquipments);
98  
99      /**
100      * <p>deleteSamplingEquipments.</p>
101      *
102      * @param samplingEquipmentIds a {@link java.util.List} object.
103      */
104     @CacheEvict(value = {
105             ALL_SAMPLING_EQUIPMENTS_CACHE,
106             SAMPLING_EQUIPMENT_BY_ID_CACHE,
107             SAMPLING_EQUIPMENTS_BY_IDS_CACHE
108     }, allEntries = true)
109     void deleteSamplingEquipments(List<Integer> samplingEquipmentIds);
110 
111     /**
112      * <p>replaceTemporarySamplingEquipment.</p>
113      *
114      * @param sourceId a {@link java.lang.Integer} object.
115      * @param targetId a {@link java.lang.Integer} object.
116      * @param delete a boolean.
117      */
118     @CacheEvict(value = {
119             ALL_SAMPLING_EQUIPMENTS_CACHE,
120             SAMPLING_EQUIPMENT_BY_ID_CACHE,
121             SAMPLING_EQUIPMENTS_BY_IDS_CACHE
122     }, allEntries = true)
123     void replaceTemporarySamplingEquipment(Integer sourceId, Integer targetId, boolean delete);
124 
125     /**
126      * Check if this sampling equipment is used in data
127      * SAMPLING_OPERATION
128      *
129      * @param samplingEquipmentId a int.
130      * @return a boolean.
131      */
132     boolean isSamplingEquipmentUsedInData(int samplingEquipmentId);
133 
134     /**
135      * <p>isSamplingEquipmentUsedInValidatedData.</p>
136      *
137      * @param samplingEquipmentId a int.
138      * @return a boolean.
139      */
140     boolean isSamplingEquipmentUsedInValidatedData(int samplingEquipmentId);
141 }