View Javadoc
1   package fr.ifremer.reefdb.dao.referential.monitoringLocation;
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.CoordinateDTO;
27  import fr.ifremer.reefdb.dto.referential.HarbourDTO;
28  import fr.ifremer.reefdb.dto.referential.LocationDTO;
29  import org.springframework.cache.annotation.CacheEvict;
30  import org.springframework.cache.annotation.Cacheable;
31  
32  import java.util.List;
33  import java.util.Map;
34  
35  /**
36   * <p>ReefDbMonitoringLocationDao interface.</p>
37   */
38  public interface ReefDbMonitoringLocationDao {
39  
40      String ALL_LOCATIONS_CACHE = "all_locations";
41      String LOCATION_BY_ID_CACHE = "location_by_id";
42      String LOCATIONS_BY_IDS_CACHE = "locations_by_ids";
43      String LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE = "locations_by_campaign_and_program";
44      String ALL_HARBOURS_CACHE = "all_harbours";
45      String ALL_COORDINATES_CACHE = "all_coordinates";
46      String COORDINATE_BY_LOCATION_ID_CACHE = "coordinate_by_location_id";
47  
48      /**
49       * <p>getAllLocations.</p>
50       *
51       * @param statusCodes a {@link java.util.List} object.
52       * @return a {@link java.util.List} object.
53       */
54      @Cacheable(value = ALL_LOCATIONS_CACHE)
55      List<LocationDTO> getAllLocations(List<String> statusCodes);
56  
57      /**
58       * <p>getLocationById.</p>
59       *
60       * @param locationId a int.
61       * @return a {@link fr.ifremer.reefdb.dto.referential.LocationDTO} object.
62       */
63      @Cacheable(value = LOCATION_BY_ID_CACHE)
64      LocationDTO getLocationById(int locationId);
65  
66      /**
67       * <p>getLocationsByIds.</p>
68       *
69       * @param locationIds a {@link java.util.List} object.
70       * @return a {@link java.util.List} object.
71       */
72      @Cacheable(value = LOCATIONS_BY_IDS_CACHE)
73      List<LocationDTO> getLocationsByIds(List<Integer> locationIds);
74  
75      /**
76       * <p>getLocationsByCampaignAndProgram.</p>
77       *
78       * @param campaignId  a {@link java.lang.Integer} object.
79       * @param programCode a {@link java.lang.String} object.
80       * @return a {@link java.util.List} object.
81       */
82      @Cacheable(value = LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE)
83      List<LocationDTO> getLocationsByCampaignAndProgram(Integer campaignId, String programCode);
84  
85      /**
86       * <p>findLocations.</p>
87       *
88       * @param statusCodes       a {@link java.util.List} object.
89       * @param orderItemTypeCode a {@link java.lang.String} object.
90       * @param orderItemId       a {@link java.lang.Integer} object.
91       * @param programCode       a {@link java.lang.String} object.
92       * @param label             a {@link java.lang.String} object.
93       * @param name              a {@link java.lang.String} object.
94       * @param isStrictName      a boolean.
95       * @return a {@link java.util.List} object.
96       */
97      List<LocationDTO> findLocations(List<String> statusCodes, String orderItemTypeCode, Integer orderItemId, String programCode, String label, String name, boolean isStrictName);
98  
99      /**
100      * <p>saveLocations.</p>
101      *
102      * @param locations a {@link java.util.List} object.
103      */
104     @CacheEvict(value = {
105             ALL_LOCATIONS_CACHE,
106             LOCATIONS_BY_IDS_CACHE,
107             LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE
108     }, allEntries = true)
109     void saveLocations(List<? extends LocationDTO> locations);
110 
111     /**
112      * <p>deleteLocations.</p>
113      *
114      * @param locationIds a {@link java.util.List} object.
115      */
116     @CacheEvict(value = {
117             ALL_LOCATIONS_CACHE,
118             LOCATIONS_BY_IDS_CACHE,
119             LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE
120     }, allEntries = true)
121     void deleteLocations(List<Integer> locationIds);
122 
123     /**
124      * <p>replaceTemporaryLocation.</p>
125      *
126      * @param sourceId a {@link java.lang.Integer} object.
127      * @param targetId a {@link java.lang.Integer} object.
128      * @param delete   a boolean.
129      */
130     @CacheEvict(value = {
131             ALL_LOCATIONS_CACHE,
132             LOCATIONS_BY_IDS_CACHE,
133             LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE
134     }, allEntries = true)
135     void replaceTemporaryLocation(Integer sourceId, Integer targetId, boolean delete);
136 
137     /**
138      * <p>isLocationUsedInProgram.</p>
139      *
140      * @param locationId a int.
141      * @return a boolean.
142      */
143     boolean isLocationUsedInProgram(int locationId);
144 
145     /**
146      * <p>isLocationUsedInData.</p>
147      *
148      * @param locationId a int.
149      * @return a boolean.
150      */
151     boolean isLocationUsedInData(int locationId);
152 
153     /**
154      * <p>isLocationUsedInValidatedData.</p>
155      *
156      * @param locationId a int.
157      * @return a boolean.
158      */
159     boolean isLocationUsedInValidatedData(int locationId);
160 
161     /**
162      * <p>getAllHarbours.</p>
163      *
164      * @param statusCodes a {@link java.util.List} object.
165      * @return a {@link java.util.List} object.
166      */
167     @Cacheable(value = ALL_HARBOURS_CACHE)
168     List<HarbourDTO> getAllHarbours(List<String> statusCodes);
169 
170     /**
171      * Populate all geometry coordinates of all monitoring locations
172      * Used to fill COORDINATE_BY_LOCATION_ID_CACHE
173      *
174      * @return the map of all coordinates by monitoring location id
175      */
176     @Cacheable(value = ALL_COORDINATES_CACHE)
177     Map<Integer, CoordinateDTO> getAllCoordinates();
178 
179     /**
180      * Get the position (geometry) of the monitoring location
181      *
182      * @param locationId monitoring location id
183      * @return the position
184      */
185     @Cacheable(value = COORDINATE_BY_LOCATION_ID_CACHE)
186     CoordinateDTO getCoordinateByLocationId(int locationId);
187 }