1 package fr.ifremer.quadrige2.core.service.administration.program;
2
3 /*-
4 * #%L
5 * Quadrige2 Core :: Quadrige2 Server Core
6 * $Id:$
7 * $HeadURL:$
8 * %%
9 * Copyright (C) 2017 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.quadrige2.core.exception.DataLockedException;
27 import fr.ifremer.quadrige2.core.vo.administration.program.ProgramVO;
28 import org.springframework.transaction.annotation.Propagation;
29 import org.springframework.transaction.annotation.Transactional;
30
31 import java.util.Collection;
32 import java.util.List;
33 import java.util.Set;
34
35 /**
36 * <p>
37 * ProgramService interface.
38 * </p>
39 *
40 */
41 @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
42 public interface ProgramService {
43
44 /**
45 * Save a list of programs
46 *
47 * @param programs
48 * a program list
49 * @return a {@link java.util.List} object.
50 */
51 @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = { RuntimeException.class, DataLockedException.class })
52 List<ProgramVO> save(List<ProgramVO> programs);
53
54 /**
55 * <p>
56 * save.
57 * </p>
58 *
59 * @param bean
60 * a {@link fr.ifremer.quadrige2.core.vo.administration.program.ProgramVO} object.
61 * @return a {@link fr.ifremer.quadrige2.core.vo.administration.program.ProgramVO} object.
62 */
63 @Transactional(readOnly = false, propagation = Propagation.REQUIRED, rollbackFor = { RuntimeException.class, DataLockedException.class })
64 ProgramVO save(ProgramVO bean);
65
66 /**
67 * <p>
68 * getByCode.
69 * </p>
70 *
71 * @param progCd
72 * a {@link java.lang.String} object.
73 * @return a {@link fr.ifremer.quadrige2.core.vo.administration.program.ProgramVO} object.
74 */
75 ProgramVO getByCode(String progCd);
76
77 /**
78 * Get user's programs (program with write rights <u>on data</u>). <br/>
79 * Programs are limited to config program codes (if config option is not blank)
80 *
81 * @param quserId
82 * a int.
83 * @return a {@link java.util.List} object.
84 */
85 List<ProgramVO> getWritableProgramsByQuserId(int quserId);
86
87 /**
88 * Get user's program codes (program with write rights <u>on data</u>). <br/>
89 * Programs are limited to config program codes (if config option is not blank)
90 *
91 * @param quserId
92 * a int.
93 * @return a {@link java.util.Set} object.
94 */
95 Set<String> getWritableProgramCodesByQuserId(int quserId);
96
97 /**
98 * Check if user has some right on programs
99 *
100 * @param quserId
101 * a int.
102 * @return true is at least user could access to one program
103 */
104 boolean hasAccessRightOnProgram(int quserId);
105
106 /**
107 * Check if user has write access on all given program codes
108 * @param quserId a int.
109 * @param progCds a list of program code
110 * @return true if user has write access on ALL programs
111 */
112 boolean hasWritePermission(int quserId, Collection<String> progCds);
113
114 /**
115 * Check if user has write permission on at least on program
116 * @param quserId a int.
117 * @return true if user has write permission
118 */
119 boolean hasSomeWritePermission(int quserId);
120
121 }