1 /**
2 * Copyright 2004-2013 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.kpme.tklm.leave.service.permission;
17
18 import java.util.Map;
19
20 import org.joda.time.DateTime;
21 import org.kuali.kpme.tklm.leave.block.LeaveBlock;
22
23 public interface LMPermissionService {
24
25 /**
26 * Checks whether the given {@code principalId} is authorized to perform {@code permissionName}.
27 *
28 * @param principalId The person to check the permission for
29 * @param permissionName The name of the permission
30 * @param asOfDate The effective date of the permission
31 *
32 * @return true if {@code principalId} is authorized to perform {@code permissionName}, false otherwise.
33 */
34 boolean isAuthorized(String principalId, String permissionName, DateTime asOfDate);
35
36 /**
37 * Checks whether the given {@code principalId} is authorized to perform {@code permissionName} for the given role qualifications.
38 *
39 * @param principalId The person to check the permission for
40 * @param permissionName The name of the permission
41 * @param qualification The map of role qualifiers for the person
42 * @param asOfDate The effective date of the permission
43 *
44 * @return true if {@code principalId} is authorized to perform {@code permissionName}, false otherwise.
45 */
46 boolean isAuthorized(String principalId, String permissionName, Map<String, String> qualification, DateTime asOfDate);
47
48 /**
49 * Checks whether the given {@code principalId} is authorized to perform {@code permissionName} for the given work area.
50 *
51 * @param principalId The person to check the permission for
52 * @param permissionName The name of the permission
53 * @param workArea The work area qualifier
54 * @param asOfDate The effective date of the permission
55 *
56 * @return true if {@code principalId} is authorized to perform {@code permissionName} for the given work area, false otherwise.
57 */
58 boolean isAuthorizedInWorkArea(String principalId, String permissionName, Long workArea, DateTime asOfDate);
59
60 /**
61 * Checks whether the given {@code principalId} is authorized to perform {@code permissionName} for the given department.
62 *
63 * @param principalId The person to check the permission for
64 * @param permissionName The name of the permission
65 * @param department The department qualifier
66 * @param asOfDate The effective date of the permission
67 *
68 * @return true if {@code principalId} is authorized to perform {@code permissionName} for the given department, false otherwise.
69 */
70 boolean isAuthorizedInDepartment(String principalId, String permissionName, String department, DateTime asOfDate);
71
72 /**
73 * Checks whether the given {@code principalId} is authorized to perform {@code permissionName} for the given location.
74 *
75 * @param principalId The person to check the permission for
76 * @param permissionName The name of the permission
77 * @param location The location qualifier
78 * @param asOfDate The effective date of the permission
79 *
80 * @return true if {@code principalId} is authorized to perform {@code permissionName} for the given location, false otherwise.
81 */
82 boolean isAuthorizedInLocation(String principalId, String permissionName, String location, DateTime asOfDate);
83
84 /**
85 * Checks whether the given {@code principalId} can view the LeaveRequest specified by {@code documentId}.
86 *
87 * @param principalId The person to check
88 * @param documentId The id of the document
89 *
90 * @return true if {@code principalId} can view the LeaveRequest specified by {@code documentId}, false otherwise.
91 */
92 boolean canViewLeaveRequest(String principalId, String documentId);
93
94 /**
95 * Checks whether the given {@code principalId} can edit the LeaveRequest specified by {@code documentId}.
96 *
97 * @param principalId The person to check
98 * @param documentId The id of the document
99 *
100 * @return true if {@code principalId} can edit the LeaveRequest specified by {@code documentId}, false otherwise.
101 */
102 boolean canEditLeaveRequest(String principalId, String documentId);
103
104 /**
105 * Checks whether the given {@code principalId} can submit the LeaveRequest specified by {@code documentId}.
106 *
107 * @param principalId The person to check
108 * @param documentId The id of the document
109 *
110 * @return true if {@code principalId} can submit the LeaveRequest specified by {@code documentId}, false otherwise.
111 */
112 boolean canSubmitLeaveRequest(String principalId, String documentId);
113
114 /**
115 * Checks whether the given {@code principalId} can approve the LeaveRequest specified by {@code documentId}.
116 *
117 * @param principalId The person to check
118 * @param documentId The id of the document
119 *
120 * @return true if {@code principalId} can approve the LeaveRequest specified by {@code documentId}, false otherwise.
121 */
122 boolean canApproveLeaveRequest(String principalId, String documentId);
123
124 /**
125 * Checks whether the given {@code principalId} can super user administer the LeaveRequest specified by {@code documentId}.
126 *
127 * @param principalId The person to check
128 * @param documentId The id of the document
129 *
130 * @return true if {@code principalId} can super user administer the LeaveRequest specified by {@code documentId}, false otherwise.
131 */
132 boolean canSuperUserAdministerLeaveRequest(String principalId, String documentId);
133
134 /**
135 * Checks whether the given {@code principalId} is authorized to perform any permission templated by {@code permissionTemplateName} for the given permission details.
136 *
137 * @param principalId The person to check the permission for
138 * @param namespaceCode The namespace for the permission template
139 * @param permissionTemplateName The name of the permission template
140 * @param permissionDetails The map of permission details for the permission
141 * @param asOfDate The effective date of the permission
142 *
143 * @return true if {@code principalId} is authorized to perform any permission templated by {@code permissionTemplateName}, false otherwise.
144 */
145 boolean isAuthorizedByTemplate(String principalId, String namespaceCode, String permissionTemplateName, Map<String, String> permissionDetails, DateTime asOfDate);
146
147 /**
148 * Checks whether the given {@code principalId} is authorized to perform any permission templated by {@code permissionTemplateName} for the given permission details and role qualifications.
149 *
150 * @param principalId The person to check the permission for
151 * @param namespaceCode The namespace for the permission template
152 * @param permissionTemplateName The name of the permission template
153 * @param permissionDetails The map of permission details for the permission
154 * @param qualification The map of role qualifiers for the person
155 * @param asOfDate The effective date of the permission
156 *
157 * @return true if {@code principalId} is authorized to perform any permission templated by {@code permissionTemplateName}, false otherwise.
158 */
159 boolean isAuthorizedByTemplate(String principalId, String namespaceCode, String permissionTemplateName, Map<String, String> permissionDetails, Map<String, String> qualification, DateTime asOfDate);
160
161 /**
162 * Checks whether the given {@code principalId} is authorized to perform {@code permissionName} for the given work area.
163 *
164 * @param principalId The person to check the permission for
165 * @param permissionName The name of the permission
166 * @param workArea The work area qualifier
167 * @param asOfDate The effective date of the permission
168 *
169 * @return true if {@code principalId} is authorized to perform {@code permissionName} for the given work area, false otherwise.
170 */
171 boolean isAuthorizedByTemplateInWorkArea(String principalId, String namespaceCode, String permissionTemplateName, Long workArea, DateTime asOfDate);
172
173 /**
174 * Checks whether the given {@code principalId} is authorized to perform {@code permissionName} for the given department.
175 *
176 * @param principalId The person to check the permission for
177 * @param permissionName The name of the permission
178 * @param department The department qualifier
179 * @param asOfDate The effective date of the permission
180 *
181 * @return true if {@code principalId} is authorized to perform {@code permissionName} for the given department, false otherwise.
182 */
183 boolean isAuthorizedByTemplateInDepartment(String principalId, String namespaceCode, String permissionTemplateName, String department, DateTime asOfDate);
184
185 /**
186 * Checks whether the given {@code principalId} is authorized to perform {@code permissionName} for the given location.
187 *
188 * @param principalId The person to check the permission for
189 * @param permissionName The name of the permission
190 * @param location The location qualifier
191 * @param asOfDate The effective date of the permission
192 *
193 * @return true if {@code principalId} is authorized to perform {@code permissionName} for the given location, false otherwise.
194 */
195 boolean isAuthorizedByTemplateInLocation(String principalId, String namespaceCode, String permissionTemplateName, String location, DateTime asOfDate);
196
197 boolean canEditLeaveBlock(String principalId, LeaveBlock leaveBlock);
198
199 boolean canDeleteLeaveBlock(String principalId, LeaveBlock leaveBlock);
200
201 /**
202 * Determine if given leave block is a accrual generated System Scheduled Timeoff usage that can be banked/transferred
203 * and if the leave block is on the current leave calendar entry of the current targeted user
204 * @param leaveBlock
205 * @return
206 */
207 boolean canBankOrTransferSSTOUsage(LeaveBlock leaveBlock);
208
209 /**
210 * Determine if given leave block is a accrual generated System Scheduled Timeoff usage that can be transferred
211 * and if the leave block is on the current leave calendar entry of the current targeted user
212 * @param lb
213 * @return
214 */
215 boolean canTransferSSTOUsage(LeaveBlock leaveBlock);
216
217 /**
218 * Determine if given leave block is a accrual generated System Scheduled Timeoff usage that can be banked
219 * and if the leave block is on the current leave calendar entry of the current targeted user
220 * @param leaveBlock
221 * @return
222 */
223 boolean canBankSSTOUsage(LeaveBlock leaveBlock);
224
225 /**
226 * Determine if the given {@code principalId} is authorized to edit given {@code aLeaveBlock}
227 * @param principalId
228 * @param aLeaveBlock
229 * @return
230 */
231 public boolean userHasRolesToEditLeaveBlock(String principalId, LeaveBlock aLeaveBlock);
232
233 }