| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.r2.core.class1.scheduling.service.decorators; |
| 17 | |
|
| 18 | |
|
| 19 | |
import org.kuali.student.r2.common.datadictionary.DataDictionaryValidator; |
| 20 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 21 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
| 22 | |
import org.kuali.student.r2.common.exceptions.*; |
| 23 | |
import org.kuali.student.r2.core.class1.util.ValidationUtils; |
| 24 | |
import org.kuali.student.r2.core.scheduling.dto.ScheduleBatchInfo; |
| 25 | |
import org.kuali.student.r2.core.scheduling.dto.ScheduleInfo; |
| 26 | |
import org.kuali.student.r2.core.scheduling.dto.ScheduleRequestInfo; |
| 27 | |
import org.kuali.student.r2.core.scheduling.dto.TimeSlotInfo; |
| 28 | |
|
| 29 | |
import java.util.List; |
| 30 | |
|
| 31 | |
|
| 32 | 0 | public class SchedulingServiceValidationDecorator extends SchedulingServiceDecorator |
| 33 | |
{ |
| 34 | |
|
| 35 | |
private DataDictionaryValidator validator; |
| 36 | |
public DataDictionaryValidator getValidator() { |
| 37 | 0 | return validator; |
| 38 | |
} |
| 39 | |
public void setValidator(DataDictionaryValidator validator) { |
| 40 | 0 | this.validator = validator; |
| 41 | 0 | } |
| 42 | |
|
| 43 | |
@Override |
| 44 | |
public List<ValidationResultInfo> validateSchedule(String validationTypeKey, String scheduleTypeKey, ScheduleInfo scheduleInfo, ContextInfo contextInfo) |
| 45 | |
throws DoesNotExistException |
| 46 | |
,InvalidParameterException |
| 47 | |
,MissingParameterException |
| 48 | |
,OperationFailedException |
| 49 | |
,PermissionDeniedException |
| 50 | |
{ |
| 51 | |
|
| 52 | |
List<ValidationResultInfo> errors; |
| 53 | |
try { |
| 54 | 0 | errors = ValidationUtils.validateInfo(validator, validationTypeKey, scheduleInfo, contextInfo); |
| 55 | 0 | List<ValidationResultInfo> nextDecoratorErrors = getNextDecorator().validateSchedule(validationTypeKey, scheduleTypeKey, scheduleInfo, contextInfo); |
| 56 | 0 | errors.addAll(nextDecoratorErrors); |
| 57 | 0 | } catch (DoesNotExistException ex) { |
| 58 | 0 | throw new OperationFailedException("Error validating", ex); |
| 59 | 0 | } |
| 60 | 0 | return errors; |
| 61 | |
} |
| 62 | |
|
| 63 | |
@Override |
| 64 | |
public ScheduleInfo createSchedule(String scheduleTypeKey, ScheduleInfo scheduleInfo, ContextInfo contextInfo) |
| 65 | |
throws DataValidationErrorException |
| 66 | |
,DoesNotExistException |
| 67 | |
,InvalidParameterException |
| 68 | |
,MissingParameterException |
| 69 | |
,OperationFailedException |
| 70 | |
,PermissionDeniedException |
| 71 | |
,ReadOnlyException |
| 72 | |
{ |
| 73 | |
|
| 74 | |
try { |
| 75 | 0 | List<ValidationResultInfo> errors = |
| 76 | |
this.validateSchedule(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), scheduleTypeKey, scheduleInfo, contextInfo); |
| 77 | 0 | if (!errors.isEmpty()) { |
| 78 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
| 79 | |
} |
| 80 | 0 | } catch (DoesNotExistException ex) { |
| 81 | 0 | throw new OperationFailedException("Error validating", ex); |
| 82 | 0 | } |
| 83 | 0 | return getNextDecorator().createSchedule(scheduleTypeKey, scheduleInfo, contextInfo); |
| 84 | |
} |
| 85 | |
|
| 86 | |
@Override |
| 87 | |
public ScheduleInfo updateSchedule(String scheduleId, ScheduleInfo scheduleInfo, ContextInfo contextInfo) |
| 88 | |
throws DataValidationErrorException |
| 89 | |
,DoesNotExistException |
| 90 | |
,InvalidParameterException |
| 91 | |
,MissingParameterException |
| 92 | |
,OperationFailedException |
| 93 | |
,PermissionDeniedException |
| 94 | |
,ReadOnlyException |
| 95 | |
,VersionMismatchException |
| 96 | |
{ |
| 97 | |
|
| 98 | |
try { |
| 99 | 0 | List<ValidationResultInfo> errors = |
| 100 | |
this.validateSchedule(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), scheduleId, scheduleInfo, contextInfo); |
| 101 | 0 | if (!errors.isEmpty()) { |
| 102 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
| 103 | |
} |
| 104 | 0 | } catch (DoesNotExistException ex) { |
| 105 | 0 | throw new OperationFailedException("Error validating", ex); |
| 106 | 0 | } |
| 107 | 0 | return getNextDecorator().updateSchedule(scheduleId, scheduleInfo, contextInfo); |
| 108 | |
} |
| 109 | |
|
| 110 | |
@Override |
| 111 | |
public List<ValidationResultInfo> validateScheduleBatch(String validationTypeKey, String scheduleBatchTypeKey, ScheduleBatchInfo scheduleBatchInfo, ContextInfo contextInfo) |
| 112 | |
throws DoesNotExistException |
| 113 | |
,InvalidParameterException |
| 114 | |
,MissingParameterException |
| 115 | |
,OperationFailedException |
| 116 | |
,PermissionDeniedException |
| 117 | |
{ |
| 118 | |
|
| 119 | |
List<ValidationResultInfo> errors; |
| 120 | |
try { |
| 121 | 0 | errors = ValidationUtils.validateInfo(validator, validationTypeKey, scheduleBatchInfo, contextInfo); |
| 122 | 0 | List<ValidationResultInfo> nextDecoratorErrors = getNextDecorator().validateScheduleBatch(validationTypeKey, scheduleBatchTypeKey, scheduleBatchInfo, contextInfo); |
| 123 | 0 | errors.addAll(nextDecoratorErrors); |
| 124 | 0 | } catch (DoesNotExistException ex) { |
| 125 | 0 | throw new OperationFailedException("Error validating", ex); |
| 126 | 0 | } |
| 127 | 0 | return errors; |
| 128 | |
} |
| 129 | |
|
| 130 | |
@Override |
| 131 | |
public ScheduleBatchInfo createScheduleBatch(String scheduleBatchTypeKey, ScheduleBatchInfo scheduleBatchInfo, ContextInfo contextInfo) |
| 132 | |
throws DataValidationErrorException |
| 133 | |
,DoesNotExistException |
| 134 | |
,InvalidParameterException |
| 135 | |
,MissingParameterException |
| 136 | |
,OperationFailedException |
| 137 | |
,PermissionDeniedException |
| 138 | |
,ReadOnlyException |
| 139 | |
{ |
| 140 | |
|
| 141 | |
try { |
| 142 | 0 | List<ValidationResultInfo> errors = |
| 143 | |
this.validateScheduleBatch(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), scheduleBatchTypeKey, scheduleBatchInfo, contextInfo); |
| 144 | 0 | if (!errors.isEmpty()) { |
| 145 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
| 146 | |
} |
| 147 | 0 | } catch (DoesNotExistException ex) { |
| 148 | 0 | throw new OperationFailedException("Error validating", ex); |
| 149 | 0 | } |
| 150 | 0 | return getNextDecorator().createScheduleBatch(scheduleBatchTypeKey, scheduleBatchInfo, contextInfo); |
| 151 | |
} |
| 152 | |
|
| 153 | |
@Override |
| 154 | |
public ScheduleBatchInfo updateScheduleBatch(String scheduleBatchId, ScheduleBatchInfo scheduleBatchInfo, ContextInfo contextInfo) |
| 155 | |
throws DataValidationErrorException |
| 156 | |
,DoesNotExistException |
| 157 | |
,InvalidParameterException |
| 158 | |
,MissingParameterException |
| 159 | |
,OperationFailedException |
| 160 | |
,PermissionDeniedException |
| 161 | |
,ReadOnlyException |
| 162 | |
,VersionMismatchException |
| 163 | |
{ |
| 164 | |
|
| 165 | |
try { |
| 166 | 0 | List<ValidationResultInfo> errors = |
| 167 | |
this.validateScheduleBatch(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), scheduleBatchId, scheduleBatchInfo, contextInfo); |
| 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().updateScheduleBatch(scheduleBatchId, scheduleBatchInfo, contextInfo); |
| 175 | |
} |
| 176 | |
|
| 177 | |
@Override |
| 178 | |
public List<ValidationResultInfo> validateScheduleRequest(String validationTypeKey, String scheduleRequestTypeKey, ScheduleRequestInfo scheduleRequestInfo, ContextInfo contextInfo) |
| 179 | |
throws DoesNotExistException |
| 180 | |
,InvalidParameterException |
| 181 | |
,MissingParameterException |
| 182 | |
,OperationFailedException |
| 183 | |
,PermissionDeniedException |
| 184 | |
{ |
| 185 | |
|
| 186 | |
List<ValidationResultInfo> errors; |
| 187 | |
try { |
| 188 | 0 | errors = ValidationUtils.validateInfo(validator, validationTypeKey, scheduleRequestInfo, contextInfo); |
| 189 | 0 | List<ValidationResultInfo> nextDecoratorErrors = getNextDecorator().validateScheduleRequest(validationTypeKey, scheduleRequestTypeKey, scheduleRequestInfo, contextInfo); |
| 190 | 0 | errors.addAll(nextDecoratorErrors); |
| 191 | 0 | } catch (DoesNotExistException ex) { |
| 192 | 0 | throw new OperationFailedException("Error validating", ex); |
| 193 | 0 | } |
| 194 | 0 | return errors; |
| 195 | |
} |
| 196 | |
|
| 197 | |
@Override |
| 198 | |
public ScheduleRequestInfo createScheduleRequest(String scheduleRequestTypeKey, ScheduleRequestInfo scheduleRequestInfo, ContextInfo contextInfo) |
| 199 | |
throws DataValidationErrorException |
| 200 | |
,DoesNotExistException |
| 201 | |
,InvalidParameterException |
| 202 | |
,MissingParameterException |
| 203 | |
,OperationFailedException |
| 204 | |
,PermissionDeniedException |
| 205 | |
,ReadOnlyException |
| 206 | |
{ |
| 207 | |
|
| 208 | |
try { |
| 209 | 0 | List<ValidationResultInfo> errors = |
| 210 | |
this.validateScheduleRequest(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), scheduleRequestTypeKey, scheduleRequestInfo, contextInfo); |
| 211 | 0 | if (!errors.isEmpty()) { |
| 212 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
| 213 | |
} |
| 214 | 0 | } catch (DoesNotExistException ex) { |
| 215 | 0 | throw new OperationFailedException("Error validating", ex); |
| 216 | 0 | } |
| 217 | 0 | return getNextDecorator().createScheduleRequest(scheduleRequestTypeKey, scheduleRequestInfo, contextInfo); |
| 218 | |
} |
| 219 | |
|
| 220 | |
@Override |
| 221 | |
public ScheduleRequestInfo updateScheduleRequest(String scheduleRequestId, ScheduleRequestInfo scheduleRequestInfo, ContextInfo contextInfo) |
| 222 | |
throws DataValidationErrorException |
| 223 | |
,DoesNotExistException |
| 224 | |
,InvalidParameterException |
| 225 | |
,MissingParameterException |
| 226 | |
,OperationFailedException |
| 227 | |
,PermissionDeniedException |
| 228 | |
,ReadOnlyException |
| 229 | |
,VersionMismatchException |
| 230 | |
{ |
| 231 | |
|
| 232 | |
try { |
| 233 | 0 | List<ValidationResultInfo> errors = |
| 234 | |
this.validateScheduleRequest(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), scheduleRequestId, scheduleRequestInfo, contextInfo); |
| 235 | 0 | if (!errors.isEmpty()) { |
| 236 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
| 237 | |
} |
| 238 | 0 | } catch (DoesNotExistException ex) { |
| 239 | 0 | throw new OperationFailedException("Error validating", ex); |
| 240 | 0 | } |
| 241 | 0 | return getNextDecorator().updateScheduleRequest(scheduleRequestId, scheduleRequestInfo, contextInfo); |
| 242 | |
} |
| 243 | |
|
| 244 | |
@Override |
| 245 | |
public List<ValidationResultInfo> validateTimeSlot(String validationTypeKey, String timeSlotTypeKey, TimeSlotInfo timeSlotInfo, ContextInfo contextInfo) |
| 246 | |
throws DoesNotExistException |
| 247 | |
,InvalidParameterException |
| 248 | |
,MissingParameterException |
| 249 | |
,OperationFailedException |
| 250 | |
,PermissionDeniedException |
| 251 | |
{ |
| 252 | |
|
| 253 | |
List<ValidationResultInfo> errors; |
| 254 | |
try { |
| 255 | 0 | errors = ValidationUtils.validateInfo(validator, validationTypeKey, timeSlotInfo, contextInfo); |
| 256 | 0 | List<ValidationResultInfo> nextDecoratorErrors = getNextDecorator().validateTimeSlot(validationTypeKey, timeSlotTypeKey, timeSlotInfo, contextInfo); |
| 257 | 0 | errors.addAll(nextDecoratorErrors); |
| 258 | 0 | } catch (DoesNotExistException ex) { |
| 259 | 0 | throw new OperationFailedException("Error validating", ex); |
| 260 | 0 | } |
| 261 | 0 | return errors; |
| 262 | |
} |
| 263 | |
|
| 264 | |
@Override |
| 265 | |
public TimeSlotInfo createTimeSlot(String timeSlotTypeKey, TimeSlotInfo timeSlotInfo, ContextInfo contextInfo) |
| 266 | |
throws DataValidationErrorException |
| 267 | |
,DoesNotExistException |
| 268 | |
,InvalidParameterException |
| 269 | |
,MissingParameterException |
| 270 | |
,OperationFailedException |
| 271 | |
,PermissionDeniedException |
| 272 | |
,ReadOnlyException |
| 273 | |
{ |
| 274 | |
|
| 275 | |
try { |
| 276 | 0 | List<ValidationResultInfo> errors = |
| 277 | |
this.validateTimeSlot(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), timeSlotTypeKey, timeSlotInfo, contextInfo); |
| 278 | 0 | if (!errors.isEmpty()) { |
| 279 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
| 280 | |
} |
| 281 | 0 | } catch (DoesNotExistException ex) { |
| 282 | 0 | throw new OperationFailedException("Error validating", ex); |
| 283 | 0 | } |
| 284 | 0 | return getNextDecorator().createTimeSlot(timeSlotTypeKey, timeSlotInfo, contextInfo); |
| 285 | |
} |
| 286 | |
|
| 287 | |
@Override |
| 288 | |
public TimeSlotInfo updateTimeSlot(String timeSlotId, TimeSlotInfo timeSlotInfo, ContextInfo contextInfo) |
| 289 | |
throws DataValidationErrorException |
| 290 | |
,DoesNotExistException |
| 291 | |
,InvalidParameterException |
| 292 | |
,MissingParameterException |
| 293 | |
,OperationFailedException |
| 294 | |
,PermissionDeniedException |
| 295 | |
,ReadOnlyException |
| 296 | |
,VersionMismatchException |
| 297 | |
{ |
| 298 | |
|
| 299 | |
try { |
| 300 | 0 | List<ValidationResultInfo> errors = |
| 301 | |
this.validateTimeSlot(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), timeSlotId, timeSlotInfo, contextInfo); |
| 302 | 0 | if (!errors.isEmpty()) { |
| 303 | 0 | throw new DataValidationErrorException("Error(s) occurred validating", errors); |
| 304 | |
} |
| 305 | 0 | } catch (DoesNotExistException ex) { |
| 306 | 0 | throw new OperationFailedException("Error validating", ex); |
| 307 | 0 | } |
| 308 | 0 | return getNextDecorator().updateTimeSlot(timeSlotId, timeSlotInfo, contextInfo); |
| 309 | |
} |
| 310 | |
} |
| 311 | |
|