View Javadoc
1   package fr.ifremer.reefdb.dao.referential.pmfm;
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.pmfm.ParameterDTO;
27  import fr.ifremer.reefdb.dto.referential.pmfm.ParameterGroupDTO;
28  import org.springframework.cache.annotation.CacheEvict;
29  import org.springframework.cache.annotation.Cacheable;
30  
31  import java.util.List;
32  
33  /**
34   * Created by Ludovic on 29/07/2015.
35   */
36  public interface ReefDbParameterDao {
37  
38      String PARAMETER_BY_CODE_CACHE = "parameter_by_code";
39      String ALL_PARAMETERS_CACHE = "all_parameters";
40  
41      String ALL_PARAMETER_GROUPS_CACHE = "all_parameter_groups";
42      String PARAMETER_GROUP_BY_ID_CACHE = "parameter_group_by_id";
43  
44      /**
45       * <p>getAllParameters.</p>
46       *
47       * @param statusCodes a {@link java.util.List} object.
48       * @return a {@link java.util.List} object.
49       */
50      @Cacheable(value = ALL_PARAMETERS_CACHE)
51      List<ParameterDTO> getAllParameters(List<String> statusCodes);
52  
53      /**
54       * <p>getParameterByCode.</p>
55       *
56       * @param parameterCode a {@link java.lang.String} object.
57       * @return a {@link fr.ifremer.reefdb.dto.referential.pmfm.ParameterDTO} object.
58       */
59      @Cacheable(value = PARAMETER_BY_CODE_CACHE)
60      ParameterDTO getParameterByCode(String parameterCode);
61  
62      /**
63       * <p>findParameters.</p>
64       *
65       * @param parameterCode a {@link java.lang.String} object.
66       * @param parameterGroupId a {@link java.lang.Integer} object.
67       * @param statusCodes a {@link java.util.List} object.
68       * @return a {@link java.util.List} object.
69       */
70      List<ParameterDTO> findParameters(String parameterCode, Integer parameterGroupId, List<String> statusCodes);
71  
72      /**
73       * <p>saveParameters.</p>
74       *
75       * @param parameters a {@link java.util.List} object.
76       */
77      @CacheEvict(value = {
78              PARAMETER_BY_CODE_CACHE,
79              ALL_PARAMETERS_CACHE,
80              ReefDbQualitativeValueDao.QUALITATIVE_VALUES_BY_PARAMETER_CODE_CACHE
81      }, allEntries = true)
82      void saveParameters(List<? extends ParameterDTO> parameters);
83  
84      /**
85       * <p>deleteParameters.</p>
86       *
87       * @param parametersCodes a {@link java.util.List} object.
88       */
89      @CacheEvict(value = {
90              PARAMETER_BY_CODE_CACHE,
91              ALL_PARAMETERS_CACHE,
92              ReefDbQualitativeValueDao.QUALITATIVE_VALUES_BY_PARAMETER_CODE_CACHE
93      }, allEntries = true)
94      void deleteParameters(List<String> parametersCodes);
95  
96      /**
97       * <p>replaceTemporaryParameter.</p>
98       *
99       * @param sourceCode a {@link java.lang.String} object.
100      * @param targetCode a {@link java.lang.String} object.
101      * @param delete a boolean.
102      */
103     @CacheEvict(value = {
104             PARAMETER_BY_CODE_CACHE,
105             ALL_PARAMETERS_CACHE,
106             ReefDbQualitativeValueDao.QUALITATIVE_VALUES_BY_PARAMETER_CODE_CACHE
107     }, allEntries = true)
108     void replaceTemporaryParameter(String sourceCode, String targetCode, boolean delete);
109 
110     /**
111      * <p>isParameterUsedInProgram.</p>
112      *
113      * @param parameterCode a {@link java.lang.String} object.
114      * @return a boolean.
115      */
116     boolean isParameterUsedInProgram(String parameterCode);
117 
118     /**
119      * <p>isParameterUsedInRules.</p>
120      *
121      * @param parameterCode a {@link java.lang.String} object.
122      * @return a boolean.
123      */
124     boolean isParameterUsedInRules(String parameterCode);
125 
126     /**
127      * <p>isParameterUsedInReferential.</p>
128      *
129      * @param parameterCode a {@link java.lang.String} object.
130      * @return a boolean.
131      */
132     boolean isParameterUsedInReferential(String parameterCode);
133 
134     /**
135      * <p>getAllParameterGroups.</p>
136      *
137      * @param statusCodes a {@link java.util.List} object.
138      * @return a {@link java.util.List} object.
139      */
140     @Cacheable(value = ALL_PARAMETER_GROUPS_CACHE)
141     List<ParameterGroupDTO> getAllParameterGroups(List<String> statusCodes);
142 
143     /**
144      * <p>getParameterGroupById.</p>
145      *
146      * @param parameterGroupId a int.
147      * @return a {@link fr.ifremer.reefdb.dto.referential.pmfm.ParameterGroupDTO} object.
148      */
149     @Cacheable(value = PARAMETER_GROUP_BY_ID_CACHE)
150     ParameterGroupDTO getParameterGroupById(int parameterGroupId);
151 
152 }