1 package fr.ifremer.reefdb.dao.administration.user;
2
3 /*
4 * #%L
5 * Reef DB :: Core
6 * $Id:$
7 * $HeadURL:$
8 * %%
9 * Copyright (C) 2013 - 2014 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.QuserExtendDao;
27 import fr.ifremer.reefdb.dto.referential.PersonDTO;
28 import fr.ifremer.reefdb.dto.referential.PrivilegeDTO;
29 import org.springframework.cache.annotation.CacheEvict;
30 import org.springframework.cache.annotation.Cacheable;
31
32 import java.util.Collection;
33 import java.util.List;
34
35 /**
36 * <p>ReefDbQuserDao interface.</p>
37 *
38 */
39 public interface ReefDbQuserDao extends QuserExtendDao {
40
41 int TRANSFORM_PERSON_DTO = 100;
42 String USER_BY_ID_CACHE = "user_by_id";
43 String ALL_USER_CACHE = "all_users";
44
45 /**
46 * <p>getUserById.</p>
47 *
48 * @param personId a int.
49 * @return a {@link fr.ifremer.reefdb.dto.referential.PersonDTO} object.
50 */
51 @Cacheable(value = USER_BY_ID_CACHE)
52 PersonDTO getUserById(int personId);
53
54 /**
55 * <p>getAllUsers.</p>
56 *
57 * @param statusCodes a {@link java.util.List} object.
58 * @return a {@link java.util.List} object.
59 */
60 @Cacheable(value = ALL_USER_CACHE)
61 List<PersonDTO> getAllUsers(List<String> statusCodes);
62
63 /**
64 * <p>findUsersByCriteria.</p>
65 *
66 * @param lastName a {@link java.lang.String} object.
67 * @param firstName a {@link java.lang.String} object.
68 * @param strictName a boolean.
69 * @param login a {@link java.lang.String} object.
70 * @param departmentId a {@link java.lang.Integer} object.
71 * @param privilegeCode a {@link java.lang.String} object.
72 * @param statusCodes @return
73 * @return a {@link java.util.List} object.
74 */
75 List<PersonDTO> findUsersByCriteria(String lastName, String firstName, boolean strictName, String login, Integer departmentId, String privilegeCode, List<String> statusCodes);
76
77 /**
78 * <p>getUserByLogin.</p>
79 *
80 * @param statusCodes a {@link java.util.List} object.
81 * @param login a {@link java.lang.String} object.
82 * @return a {@link fr.ifremer.reefdb.dto.referential.PersonDTO} object.
83 */
84 PersonDTO getUserByLogin(List<String> statusCodes, String login);
85
86 /**
87 * <p>getUsersByIds.</p>
88 *
89 * @param userIds a {@link java.util.List} object.
90 * @return a {@link java.util.List} object.
91 */
92 List<PersonDTO> getUsersByIds(List<Integer> userIds);
93
94 /**
95 * <p>isUserUsedInProgram.</p>
96 *
97 * @param id a int.
98 * @return a boolean.
99 */
100 boolean isUserUsedInProgram(int id);
101
102 /**
103 * <p>isUserUsedInRules.</p>
104 *
105 * @param id a int.
106 * @return a boolean.
107 */
108 boolean isUserUsedInRules(int id);
109
110 /**
111 * <p>isUserUsedInData.</p>
112 *
113 * @param id a int.
114 * @return a boolean.
115 */
116 boolean isUserUsedInData(int id);
117
118 /**
119 * <p>isUserUsedInValidatedData.</p>
120 *
121 * @param id a int.
122 * @return a boolean.
123 */
124 boolean isUserUsedInValidatedData(int id);
125
126 /**
127 * <p>deleteTemporaryUser.</p>
128 *
129 * @param ids a {@link java.util.List} object.
130 */
131 @CacheEvict(value = {
132 ALL_USER_CACHE,
133 USER_BY_ID_CACHE
134 }, allEntries = true)
135 void deleteTemporaryUser(List<Integer> ids);
136
137 /**
138 * <p>deleteTemporaryUser.</p>
139 *
140 * @param id a {@link java.lang.Integer} object.
141 */
142 @CacheEvict(value = {
143 ALL_USER_CACHE,
144 USER_BY_ID_CACHE
145 }, allEntries = true)
146 void deleteTemporaryUser(Integer id);
147
148 /**
149 * <p>getAllPrivileges.</p>
150 *
151 * @return a {@link java.util.List} object.
152 */
153 List<PrivilegeDTO> getAllPrivileges();
154
155 Collection<PrivilegeDTO> getPrivilegesByUserId(Integer userId);
156
157 /**
158 * <p>saveTemporaryUser.</p>
159 *
160 * @param user a {@link PersonDTO} object.
161 * @return a {@link fr.ifremer.reefdb.dto.referential.PersonDTO} object.
162 */
163 @CacheEvict(value = {
164 ALL_USER_CACHE,
165 USER_BY_ID_CACHE
166 }, allEntries = true)
167 void saveTemporaryUser(PersonDTO user);
168
169 @CacheEvict(value = {
170 ALL_USER_CACHE,
171 USER_BY_ID_CACHE
172 }, allEntries = true)
173 void replaceTemporaryUserFks(Integer sourceQuserId, Integer targetQuserId, boolean delete);
174 }