View Javadoc
1   package fr.ifremer.reefdb.dao.administration.program;
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.quadrige3.core.dao.administration.program.ProgramDao;
27  import fr.ifremer.reefdb.dao.administration.strategy.ReefDbStrategyDao;
28  import fr.ifremer.reefdb.dao.referential.monitoringLocation.ReefDbMonitoringLocationDao;
29  import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO;
30  import org.springframework.cache.annotation.CacheEvict;
31  import org.springframework.cache.annotation.Cacheable;
32  import org.springframework.cache.annotation.Caching;
33  
34  import java.util.Collection;
35  import java.util.Date;
36  import java.util.List;
37  
38  
39  /**
40   * <p>ReefDbProgramDao interface.</p>
41   *
42   */
43  public interface ReefDbProgramDao extends ProgramDao {
44  
45      String PROGRAM_BY_CODE_CACHE = "program_by_code";
46      String ALL_PROGRAMS_CACHE = "all_programs";
47      String PROGRAMS_BY_CAMPAIGN_ID_CACHE = "programs_by_campaign_id";
48      String PROGRAMS_BY_CODES_CACHE = "programs_by_codes";
49  
50      /**
51       * <p>getAllPrograms.</p>
52       *
53       * @return a {@link java.util.List} object.
54       */
55      @Cacheable(value = ALL_PROGRAMS_CACHE)
56      List<ProgramDTO> getAllPrograms();
57  
58      /**
59       * <p>getProgramByCode.</p>
60       *
61       * @param programCode a {@link java.lang.String} object.
62       * @return a {@link fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO} object.
63       */
64      @Cacheable(value = PROGRAM_BY_CODE_CACHE)
65      ProgramDTO getProgramByCode(String programCode);
66  
67      /**
68       * <p>getProgramsByCampaignId.</p>
69       *
70       * @param campaignId a {@link java.lang.Integer} object.
71       * @return a {@link java.util.List} object.
72       */
73      @Cacheable(value = PROGRAMS_BY_CAMPAIGN_ID_CACHE)
74      List<ProgramDTO> getProgramsByCampaignId(Integer campaignId);
75  
76      /**
77       * <p>getProgramsByCodes.</p>
78       *
79       * @param programCodes a {@link java.util.List} object.
80       * @return a {@link java.util.List} object.
81       */
82      @Cacheable(value = PROGRAMS_BY_CODES_CACHE)
83      List<ProgramDTO> getProgramsByCodes(List<String> programCodes);
84  
85      /**
86       * <p>saveProgram.</p>
87       *
88       * @param program a {@link fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO} object.
89       */
90      @Caching(evict = {
91              @CacheEvict(value = ALL_PROGRAMS_CACHE, allEntries = true),
92              @CacheEvict(value = PROGRAMS_BY_CAMPAIGN_ID_CACHE, allEntries = true),
93              @CacheEvict(value = PROGRAMS_BY_CODES_CACHE, allEntries = true),
94              @CacheEvict(value = PROGRAM_BY_CODE_CACHE, key = "#program.code"),
95              @CacheEvict(value = ReefDbStrategyDao.PMFM_STRATEGIES_BY_PROG_LOC_DATE_CACHE, allEntries = true),
96              @CacheEvict(value = ReefDbMonitoringLocationDao.LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE, allEntries = true)
97      })
98      void saveProgram(ProgramDTO program);
99  
100     /**
101      * <p>remove.</p>
102      *
103      * @param programCode a {@link java.lang.String} object.
104      */
105     @Caching(evict = {
106             @CacheEvict(value = ALL_PROGRAMS_CACHE, allEntries = true),
107             @CacheEvict(value = PROGRAMS_BY_CAMPAIGN_ID_CACHE, allEntries = true),
108             @CacheEvict(value = PROGRAMS_BY_CODES_CACHE, allEntries = true),
109             @CacheEvict(value = PROGRAM_BY_CODE_CACHE, key = "#programCode"),
110             @CacheEvict(value = ReefDbStrategyDao.PMFM_STRATEGIES_BY_PROG_LOC_DATE_CACHE, allEntries = true),
111             @CacheEvict(value = ReefDbMonitoringLocationDao.LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE, allEntries = true)
112     })
113     void remove(String programCode);
114 
115     /**
116      * <p>deleteProgramLocations.</p>
117      *
118      * @param programCode a {@link java.lang.String} object.
119      * @param monitoringLocationIds a {@link java.util.Collection} object.
120      */
121     @Caching(evict = {
122             @CacheEvict(value = ALL_PROGRAMS_CACHE, allEntries = true),
123             @CacheEvict(value = PROGRAMS_BY_CAMPAIGN_ID_CACHE, allEntries = true),
124             @CacheEvict(value = PROGRAMS_BY_CODES_CACHE, allEntries = true),
125             @CacheEvict(value = PROGRAM_BY_CODE_CACHE, key = "#programCode"),
126             @CacheEvict(value = ReefDbStrategyDao.PMFM_STRATEGIES_BY_PROG_LOC_DATE_CACHE, allEntries = true),
127             @CacheEvict(value = ReefDbMonitoringLocationDao.LOCATIONS_BY_CAMPAIGN_AND_PROGRAM_CACHE, allEntries = true)
128     })
129     void deleteProgramLocations(String programCode, Collection<Integer> monitoringLocationIds);
130 
131 
132     /**
133      * <p>findProgramsByCodeAndName.</p>
134      *
135      * @param statusCodes a {@link java.util.List} object.
136      * @param code a {@link java.lang.String} object.
137      * @param name a {@link java.lang.String} object.
138      * @return a {@link java.util.List} object.
139      */
140     List<ProgramDTO> findProgramsByCodeAndName(List<String> statusCodes, String code, String name);
141 
142     /**
143      * <p>findProgramsByLocationAndDate.</p>
144      *
145      * @param statusCodes a {@link java.util.List} object.
146      * @param locationId a int.
147      * @param date a {@link java.util.Date} object.
148      * @return a {@link java.util.List} object.
149      */
150     List<ProgramDTO> findProgramsByLocationAndDate(List<String> statusCodes, int locationId, Date date);
151 
152     /**
153      * <p>isProgramUsedByRuleList.</p>
154      *
155      * @param programCode a {@link java.lang.String} object.
156      * @return a boolean.
157      */
158     boolean isProgramUsedByRuleList(String programCode);
159 
160 }