View Javadoc
1   package fr.ifremer.reefdb.dao.administration.user;
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.user.DepartmentDao;
27  import fr.ifremer.reefdb.dto.referential.DepartmentDTO;
28  import org.springframework.cache.annotation.CacheEvict;
29  import org.springframework.cache.annotation.Cacheable;
30  
31  import java.util.List;
32  
33  /**
34   * <p>ReefDbDepartmentDao interface.</p>
35   *
36   */
37  public interface ReefDbDepartmentDao extends DepartmentDao {
38  
39      String ALL_DEPARTMENTS_CACHE = "all_departments";
40      String DEPARTMENT_BY_ID_CACHE = "department_by_id";
41      String DEPARTMENTS_BY_IDS_CACHE = "departments_by_ids";
42  
43      /**
44       * <p>getAllDepartments.</p>
45       *
46       * @param statusCodes a {@link java.util.List} object.
47       * @return a {@link java.util.List} object.
48       */
49      @Cacheable(value = ALL_DEPARTMENTS_CACHE)
50      List<DepartmentDTO> getAllDepartments(List<String> statusCodes);
51  
52      /**
53       * <p>getDepartmentById.</p>
54       *
55       * @param departementId a int.
56       * @return a {@link fr.ifremer.reefdb.dto.referential.DepartmentDTO} object.
57       */
58      @Cacheable(value = DEPARTMENT_BY_ID_CACHE)
59      DepartmentDTO getDepartmentById(int departementId);
60  
61      /**
62       * <p>getDepartmentsByIds.</p>
63       *
64       * @param departementIds a {@link java.util.List} object.
65       * @return a {@link java.util.List} object.
66       */
67      @Cacheable(value = DEPARTMENTS_BY_IDS_CACHE)
68      List<DepartmentDTO> getDepartmentsByIds(List<Integer> departementIds);
69  
70      /**
71       * <p>findDepartmentsByCodeAndName.</p>
72       *
73       * @param code a {@link java.lang.String} object.
74       * @param name a {@link java.lang.String} object.
75       * @param strictName a boolean.
76       * @param parentId a {@link java.lang.Integer} object.
77       * @param statusCodes a {@link java.util.List} object.
78       * @return a {@link java.util.List} object.
79       */
80      List<DepartmentDTO> findDepartmentsByCodeAndName(String code, String name, boolean strictName, Integer parentId, List<String> statusCodes);
81  
82      /**
83       * <p>saveTemporaryDepartment.</p>
84       *
85       * @param departmentBean a {@link fr.ifremer.reefdb.dto.referential.DepartmentDTO} object.
86       */
87      @CacheEvict(value = {
88              ALL_DEPARTMENTS_CACHE,
89              DEPARTMENT_BY_ID_CACHE,
90              DEPARTMENTS_BY_IDS_CACHE
91      }, allEntries = true)
92      void saveTemporaryDepartment(DepartmentDTO departmentBean);
93  
94      /**
95       * <p>deleteTemporaryDepartments.</p>
96       *
97       * @param departmentIds a {@link java.util.List} object.
98       */
99      @CacheEvict(value = {
100             ALL_DEPARTMENTS_CACHE,
101             DEPARTMENT_BY_ID_CACHE,
102             DEPARTMENTS_BY_IDS_CACHE
103     }, allEntries = true)
104     void deleteTemporaryDepartments(List<Integer> departmentIds);
105 
106     /**
107      * <p>replaceTemporaryDepartmentFks.</p>
108      *
109      * @param sourceDepId a {@link java.lang.Integer} object.
110      * @param targetDepId a {@link java.lang.Integer} object.
111      * @param delete a boolean.
112      */
113     @CacheEvict(value = {
114             ALL_DEPARTMENTS_CACHE,
115             DEPARTMENT_BY_ID_CACHE,
116             DEPARTMENTS_BY_IDS_CACHE
117     }, allEntries = true)
118     void replaceTemporaryDepartmentFks(Integer sourceDepId, Integer targetDepId, boolean delete);
119 
120     /**
121      * <p>isDepartmentUsedInProgram.</p>
122      *
123      * @param departmentId a int.
124      * @return a boolean.
125      */
126     boolean isDepartmentUsedInProgram(int departmentId);
127 
128     /**
129      * <p>isDepartmentUsedInRules.</p>
130      *
131      * @param departmentId a int.
132      * @return a boolean.
133      */
134     boolean isDepartmentUsedInRules(int departmentId);
135 
136     /**
137      * <p>isDepartmentUsedInData.</p>
138      *
139      * @param departmentId a int.
140      * @return a boolean.
141      */
142     boolean isDepartmentUsedInData(int departmentId);
143 
144     /**
145      * <p>isDepartmentUsedInValidatedData.</p>
146      *
147      * @param id a int.
148      * @return a boolean.
149      */
150     boolean isDepartmentUsedInValidatedData(int id);
151 }