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