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.MatrixDTO;
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 29/07/2015.
34   */
35  public interface ReefDbMatrixDao {
36  
37      String ALL_MATRICES_CACHE = "all_matrices";
38      String MATRIX_BY_ID_CACHE = "matrix_by_id";
39  
40      /**
41       * <p>getAllMatrices.</p>
42       *
43       * @param statusCodes a {@link java.util.List} object.
44       * @return a {@link java.util.List} object.
45       */
46      @Cacheable(value = ALL_MATRICES_CACHE)
47      List<MatrixDTO> getAllMatrices(List<String> statusCodes);
48  
49      /**
50       * <p>getMatrixById.</p>
51       *
52       * @param matrixId a int.
53       * @return a {@link fr.ifremer.reefdb.dto.referential.pmfm.MatrixDTO} object.
54       */
55      @Cacheable(value = MATRIX_BY_ID_CACHE)
56      MatrixDTO getMatrixById(int matrixId);
57  
58      /**
59       * <p>findMatrices.</p>
60       *
61       * @param matrixId a {@link java.lang.Integer} object.
62       * @param statusCodes a {@link java.util.List} object.
63       * @return a {@link java.util.List} object.
64       */
65      List<MatrixDTO> findMatrices(Integer matrixId, List<String> statusCodes);
66  
67      /**
68       * <p>saveMatrices.</p>
69       *
70       * @param matrices a {@link java.util.List} object.
71       */
72      @CacheEvict(value = {
73              ALL_MATRICES_CACHE,
74              MATRIX_BY_ID_CACHE,
75              ReefDbFractionDao.FRACTIONS_BY_MATRIX_ID_CACHE
76      }, allEntries = true)
77      void saveMatrices(List<? extends MatrixDTO> matrices);
78  
79      /**
80       * <p>deleteMatrices.</p>
81       *
82       * @param matrixIds a {@link java.util.List} object.
83       */
84      @CacheEvict(value = {
85              ALL_MATRICES_CACHE,
86              MATRIX_BY_ID_CACHE,
87              ReefDbFractionDao.FRACTIONS_BY_MATRIX_ID_CACHE
88      }, allEntries = true)
89      void deleteMatrices(List<Integer> matrixIds);
90  
91      /**
92       * <p>replaceTemporaryMatrix.</p>
93       *
94       * @param sourceId a {@link java.lang.Integer} object.
95       * @param targetId a {@link java.lang.Integer} object.
96       * @param delete a boolean.
97       */
98      @CacheEvict(value = {
99              ALL_MATRICES_CACHE,
100             MATRIX_BY_ID_CACHE,
101             ReefDbFractionDao.FRACTIONS_BY_MATRIX_ID_CACHE
102     }, allEntries = true)
103     void replaceTemporaryMatrix(Integer sourceId, Integer targetId, boolean delete);
104 
105     /**
106      * <p>isMatrixUsedInProgram.</p>
107      *
108      * @param matrixId a int.
109      * @return a boolean.
110      */
111     boolean isMatrixUsedInProgram(int matrixId);
112 
113     /**
114      * <p>isMatrixUsedInRules.</p>
115      *
116      * @param matrixId a int.
117      * @return a boolean.
118      */
119     boolean isMatrixUsedInRules(int matrixId);
120 
121     /**
122      * <p>isMatrixUsedInReferential.</p>
123      *
124      * @param matrixId a int.
125      * @return a boolean.
126      */
127     boolean isMatrixUsedInReferential(int matrixId);
128 
129 }