1 | |
package org.kuali.student.enrollment.class2.courseoffering.service.decorators; |
2 | |
|
3 | |
import java.util.List; |
4 | |
|
5 | |
import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo; |
6 | |
import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo; |
7 | |
import org.kuali.student.enrollment.courseoffering.dto.FormatOfferingInfo; |
8 | |
import org.kuali.student.enrollment.courseoffering.dto.RegistrationGroupInfo; |
9 | |
import org.kuali.student.enrollment.courseoffering.dto.SeatPoolDefinitionInfo; |
10 | |
import org.kuali.student.r2.common.datadictionary.DataDictionaryValidator; |
11 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
12 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
13 | |
|
14 | |
import org.kuali.student.r2.common.exceptions.*; |
15 | |
|
16 | |
import org.kuali.student.r2.common.infc.HoldsValidator; |
17 | |
import org.kuali.student.r2.core.class1.util.ValidationUtils; |
18 | |
|
19 | 0 | public class CourseOfferingServiceValidationDecorator |
20 | |
extends CourseOfferingServiceDecorator |
21 | |
implements HoldsValidator { |
22 | |
|
23 | |
private DataDictionaryValidator validator; |
24 | |
|
25 | |
@Override |
26 | |
public DataDictionaryValidator getValidator() { |
27 | 0 | return validator; |
28 | |
} |
29 | |
|
30 | |
@Override |
31 | |
public void setValidator(DataDictionaryValidator validator) { |
32 | 0 | this.validator = validator; |
33 | 0 | } |
34 | |
|
35 | |
@Override |
36 | |
public CourseOfferingInfo createCourseOffering(String courseId, String termId, String courseOfferingTypeKey, CourseOfferingInfo courseOfferingInfo, List<String> optionKeys, ContextInfo context) |
37 | |
throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, |
38 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException { |
39 | |
|
40 | |
try { |
41 | 0 | List<ValidationResultInfo> errors = |
42 | |
this.validateCourseOffering(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), |
43 | |
courseOfferingInfo, context); |
44 | 0 | if (!errors.isEmpty()) { |
45 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
46 | |
} |
47 | 0 | } catch (DoesNotExistException ex) { |
48 | 0 | throw new OperationFailedException("Error validating", ex); |
49 | 0 | } |
50 | 0 | return getNextDecorator().createCourseOffering(courseId, termId, courseOfferingTypeKey, courseOfferingInfo, optionKeys, |
51 | |
context); |
52 | |
} |
53 | |
|
54 | |
@Override |
55 | |
public CourseOfferingInfo updateCourseOffering(String courseOfferingId, CourseOfferingInfo courseOfferingInfo, ContextInfo context) |
56 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
57 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
58 | |
|
59 | |
try { |
60 | 0 | List<ValidationResultInfo> errors = |
61 | |
this.validateCourseOffering(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), |
62 | |
courseOfferingInfo, context); |
63 | 0 | if (!errors.isEmpty()) { |
64 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
65 | |
} |
66 | 0 | } catch (DoesNotExistException ex) { |
67 | 0 | throw new OperationFailedException("Error validating", ex); |
68 | 0 | } |
69 | 0 | return getNextDecorator().updateCourseOffering(courseOfferingId, courseOfferingInfo, context); |
70 | |
} |
71 | |
|
72 | |
@Override |
73 | |
public List<ValidationResultInfo> validateCourseOffering(String validationType, CourseOfferingInfo courseOfferingInfo, ContextInfo context) |
74 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
75 | |
|
76 | |
List<ValidationResultInfo> errors; |
77 | |
try { |
78 | 0 | errors = ValidationUtils.validateInfo(validator, validationType, courseOfferingInfo, context); |
79 | 0 | List<ValidationResultInfo> nextDecoratorErrors = getNextDecorator().validateCourseOffering(validationType, |
80 | |
courseOfferingInfo, context); |
81 | 0 | errors.addAll(nextDecoratorErrors); |
82 | 0 | } catch (DoesNotExistException ex) { |
83 | 0 | throw new OperationFailedException("Error validating", ex); |
84 | 0 | } |
85 | 0 | return errors; |
86 | |
} |
87 | |
|
88 | |
@Override |
89 | |
public FormatOfferingInfo createFormatOffering(String courseOfferingId, String formatId, String formatOfferingType, FormatOfferingInfo formatOfferingInfo, ContextInfo context) |
90 | |
throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, |
91 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException { |
92 | |
|
93 | |
try { |
94 | 0 | List<ValidationResultInfo> errors = |
95 | |
this.validateFormatOffering(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), |
96 | |
formatOfferingInfo, context); |
97 | 0 | if (!errors.isEmpty()) { |
98 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
99 | |
} |
100 | 0 | } catch (DoesNotExistException ex) { |
101 | 0 | throw new OperationFailedException("Error validating", ex); |
102 | 0 | } |
103 | 0 | return getNextDecorator().createFormatOffering(courseOfferingId, formatId, formatOfferingType, formatOfferingInfo, context); |
104 | |
} |
105 | |
|
106 | |
@Override |
107 | |
public FormatOfferingInfo updateFormatOffering(String formatOfferingId, FormatOfferingInfo formatOfferingInfo, ContextInfo context) |
108 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
109 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
110 | |
|
111 | |
try { |
112 | 0 | List<ValidationResultInfo> errors = |
113 | |
this.validateFormatOffering(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), |
114 | |
formatOfferingInfo, context); |
115 | 0 | if (!errors.isEmpty()) { |
116 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
117 | |
} |
118 | 0 | } catch (DoesNotExistException ex) { |
119 | 0 | throw new OperationFailedException("Error validating", ex); |
120 | 0 | } |
121 | 0 | return getNextDecorator().updateFormatOffering(formatOfferingId, formatOfferingInfo, context); |
122 | |
} |
123 | |
|
124 | |
@Override |
125 | |
public List<ValidationResultInfo> validateFormatOffering(String validationType, FormatOfferingInfo formatOfferingInfo, ContextInfo context) |
126 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
127 | |
|
128 | |
List<ValidationResultInfo> errors; |
129 | |
try { |
130 | 0 | errors = ValidationUtils.validateInfo(validator, validationType, formatOfferingInfo, context); |
131 | 0 | List<ValidationResultInfo> nextDecoratorErrors = getNextDecorator().validateFormatOffering(validationType, |
132 | |
formatOfferingInfo, context); |
133 | 0 | errors.addAll(nextDecoratorErrors); |
134 | 0 | } catch (DoesNotExistException ex) { |
135 | 0 | throw new OperationFailedException("Error validating", ex); |
136 | 0 | } |
137 | 0 | return errors; |
138 | |
} |
139 | |
|
140 | |
@Override |
141 | |
public ActivityOfferingInfo createActivityOffering(String formatOfferingId, String activityId, String activityOfferingTypeKey, ActivityOfferingInfo activityOfferingInfo, ContextInfo context) |
142 | |
throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, |
143 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException { |
144 | |
|
145 | |
try { |
146 | 0 | List<ValidationResultInfo> errors = |
147 | |
this.validateActivityOffering(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), |
148 | |
activityOfferingInfo, context); |
149 | 0 | if (!errors.isEmpty()) { |
150 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
151 | |
} |
152 | 0 | } catch (DoesNotExistException ex) { |
153 | 0 | throw new OperationFailedException("Error validating", ex); |
154 | 0 | } |
155 | 0 | return getNextDecorator().createActivityOffering(formatOfferingId, activityId, activityOfferingTypeKey, |
156 | |
activityOfferingInfo, context); |
157 | |
} |
158 | |
|
159 | |
@Override |
160 | |
public ActivityOfferingInfo updateActivityOffering(String activityOfferingId, ActivityOfferingInfo activityOfferingInfo, ContextInfo context) |
161 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
162 | |
OperationFailedException, PermissionDeniedException, VersionMismatchException, ReadOnlyException { |
163 | |
|
164 | |
try { |
165 | 0 | List<ValidationResultInfo> errors = |
166 | |
this.validateActivityOffering(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), |
167 | |
activityOfferingInfo, context); |
168 | 0 | if (!errors.isEmpty()) { |
169 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
170 | |
} |
171 | 0 | } catch (DoesNotExistException ex) { |
172 | 0 | throw new OperationFailedException("Error validating", ex); |
173 | 0 | } |
174 | 0 | return getNextDecorator().updateActivityOffering(activityOfferingId, activityOfferingInfo, context); |
175 | |
} |
176 | |
|
177 | |
@Override |
178 | |
public List<ValidationResultInfo> validateActivityOffering(String validationType, ActivityOfferingInfo activityOfferingInfo, ContextInfo context) |
179 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
180 | |
|
181 | |
List<ValidationResultInfo> errors; |
182 | |
try { |
183 | 0 | errors = ValidationUtils.validateInfo(validator, validationType, activityOfferingInfo, context); |
184 | 0 | List<ValidationResultInfo> nextDecoratorErrors = getNextDecorator().validateActivityOffering(validationType, |
185 | |
activityOfferingInfo, context); |
186 | 0 | errors.addAll(nextDecoratorErrors); |
187 | 0 | } catch (DoesNotExistException ex) { |
188 | 0 | throw new OperationFailedException("Error validating", ex); |
189 | 0 | } |
190 | 0 | return errors; |
191 | |
} |
192 | |
|
193 | |
@Override |
194 | |
public RegistrationGroupInfo createRegistrationGroup(String formatOfferingId, String registrationGroupType, RegistrationGroupInfo registrationGroupInfo, ContextInfo context) |
195 | |
throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException, |
196 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException { |
197 | |
|
198 | |
try { |
199 | 0 | List<ValidationResultInfo> errors = |
200 | |
this.validateRegistrationGroup(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), |
201 | |
registrationGroupInfo, context); |
202 | 0 | if (!errors.isEmpty()) { |
203 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
204 | |
} |
205 | 0 | } catch (DoesNotExistException ex) { |
206 | 0 | throw new OperationFailedException("Error validating", ex); |
207 | 0 | } |
208 | 0 | return getNextDecorator().createRegistrationGroup(formatOfferingId, registrationGroupType, registrationGroupInfo, context); |
209 | |
} |
210 | |
|
211 | |
@Override |
212 | |
public RegistrationGroupInfo updateRegistrationGroup(String registrationGroupId, RegistrationGroupInfo registrationGroupInfo, ContextInfo context) |
213 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
214 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
215 | |
|
216 | |
try { |
217 | 0 | List<ValidationResultInfo> errors = |
218 | |
this.validateRegistrationGroup(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), |
219 | |
registrationGroupInfo, context); |
220 | 0 | if (!errors.isEmpty()) { |
221 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
222 | |
} |
223 | 0 | } catch (DoesNotExistException ex) { |
224 | 0 | throw new OperationFailedException("Error validating", ex); |
225 | 0 | } |
226 | 0 | return getNextDecorator().updateRegistrationGroup(registrationGroupId, registrationGroupInfo, context); |
227 | |
} |
228 | |
|
229 | |
@Override |
230 | |
public List<ValidationResultInfo> validateRegistrationGroup(String validationType, RegistrationGroupInfo registrationGroupInfo, ContextInfo context) |
231 | |
throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
232 | |
|
233 | |
List<ValidationResultInfo> errors; |
234 | |
try { |
235 | 0 | errors = ValidationUtils.validateInfo(validator, validationType, registrationGroupInfo, context); |
236 | 0 | List<ValidationResultInfo> nextDecoratorErrors = getNextDecorator().validateRegistrationGroup(validationType, |
237 | |
registrationGroupInfo, context); |
238 | 0 | errors.addAll(nextDecoratorErrors); |
239 | 0 | } catch (DoesNotExistException ex) { |
240 | 0 | throw new OperationFailedException("Error validating", ex); |
241 | 0 | } |
242 | 0 | return errors; |
243 | |
} |
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
@Override |
270 | |
public SeatPoolDefinitionInfo createSeatPoolDefinition(SeatPoolDefinitionInfo seatPoolDefinitionInfo, ContextInfo context) |
271 | |
throws DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, |
272 | |
PermissionDeniedException, ReadOnlyException { |
273 | |
|
274 | |
try { |
275 | |
List<ValidationResultInfo> errors; |
276 | |
try { |
277 | 0 | errors = this.validateSeatPoolDefinition(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), |
278 | |
seatPoolDefinitionInfo, context); |
279 | 0 | } catch (VersionMismatchException ex) { |
280 | 0 | throw new OperationFailedException("Unexpected", ex); |
281 | 0 | } |
282 | 0 | if (!errors.isEmpty()) { |
283 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
284 | |
} |
285 | 0 | } catch (DoesNotExistException ex) { |
286 | 0 | throw new OperationFailedException("Error validating", ex); |
287 | 0 | } |
288 | 0 | return getNextDecorator().createSeatPoolDefinition(seatPoolDefinitionInfo, context); |
289 | |
} |
290 | |
|
291 | |
@Override |
292 | |
public SeatPoolDefinitionInfo updateSeatPoolDefinition(String seatPoolDefinitionId, SeatPoolDefinitionInfo seatPoolDefinitionInfo, ContextInfo context) |
293 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
294 | |
OperationFailedException, PermissionDeniedException, ReadOnlyException, VersionMismatchException { |
295 | |
|
296 | |
try { |
297 | 0 | List<ValidationResultInfo> errors = |
298 | |
this.validateSeatPoolDefinition(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), |
299 | |
seatPoolDefinitionInfo, context); |
300 | 0 | if (!errors.isEmpty()) { |
301 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
302 | |
} |
303 | 0 | } catch (DoesNotExistException ex) { |
304 | 0 | throw new OperationFailedException("Error validating", ex); |
305 | 0 | } |
306 | 0 | return getNextDecorator().updateSeatPoolDefinition(seatPoolDefinitionId, seatPoolDefinitionInfo, context); |
307 | |
} |
308 | |
|
309 | |
@Override |
310 | |
public List<ValidationResultInfo> validateSeatPoolDefinition(String validationTypeKey, SeatPoolDefinitionInfo seatPoolDefinitionInfo, ContextInfo context) |
311 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, |
312 | |
OperationFailedException, PermissionDeniedException, VersionMismatchException { |
313 | |
|
314 | |
List<ValidationResultInfo> errors; |
315 | |
try { |
316 | 0 | errors = ValidationUtils.validateInfo(validator, validationTypeKey, seatPoolDefinitionInfo, context); |
317 | 0 | List<ValidationResultInfo> nextDecoratorErrors = getNextDecorator().validateSeatPoolDefinition(validationTypeKey, |
318 | |
seatPoolDefinitionInfo, context); |
319 | 0 | errors.addAll(nextDecoratorErrors); |
320 | 0 | } catch (DoesNotExistException ex) { |
321 | 0 | throw new OperationFailedException("Error validating", ex); |
322 | 0 | } |
323 | 0 | return errors; |
324 | |
} |
325 | |
} |