| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.student.enrollment.class2.grading.service.decorators; |
| 17 | |
|
| 18 | |
|
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
import org.kuali.student.enrollment.grading.dto.GradeRosterInfo; |
| 22 | |
import org.kuali.student.enrollment.grading.service.GradingServiceDecorator; |
| 23 | |
import org.kuali.student.r2.common.datadictionary.DataDictionaryValidator; |
| 24 | |
import org.kuali.student.r2.common.datadictionary.service.DataDictionaryService; |
| 25 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 26 | |
import org.kuali.student.r2.common.dto.ValidationResultInfo; |
| 27 | |
import org.kuali.student.r2.common.exceptions.DataValidationErrorException; |
| 28 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
| 29 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
| 30 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
| 31 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
| 32 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
| 33 | |
import org.kuali.student.r2.common.exceptions.VersionMismatchException; |
| 34 | |
import org.kuali.student.r2.common.infc.HoldsDataDictionaryService; |
| 35 | |
import org.kuali.student.r2.common.infc.HoldsValidator; |
| 36 | |
import org.kuali.student.r2.core.class1.util.ValidationUtils; |
| 37 | |
|
| 38 | 0 | public class GradingServiceValidationDecorator extends GradingServiceDecorator implements HoldsValidator, HoldsDataDictionaryService{ |
| 39 | |
private DataDictionaryValidator validator; |
| 40 | |
private DataDictionaryService dataDictionaryService; |
| 41 | |
|
| 42 | |
@Override |
| 43 | |
public DataDictionaryValidator getValidator() { |
| 44 | 0 | return validator; |
| 45 | |
} |
| 46 | |
|
| 47 | |
@Override |
| 48 | |
public void setValidator(DataDictionaryValidator validator) { |
| 49 | 0 | this.validator = validator; |
| 50 | 0 | } |
| 51 | |
|
| 52 | |
@Override |
| 53 | |
public DataDictionaryService getDataDictionaryService() { |
| 54 | 0 | return dataDictionaryService; |
| 55 | |
} |
| 56 | |
|
| 57 | |
@Override |
| 58 | |
public void setDataDictionaryService( |
| 59 | |
DataDictionaryService dataDictionaryService) { |
| 60 | 0 | this.dataDictionaryService = dataDictionaryService; |
| 61 | 0 | } |
| 62 | |
|
| 63 | |
private void gradingFullValidation(GradeRosterInfo gradeRoster, ContextInfo context) |
| 64 | |
throws DataValidationErrorException, OperationFailedException, InvalidParameterException, MissingParameterException { |
| 65 | |
try { |
| 66 | 0 | List<ValidationResultInfo> errors = |
| 67 | |
this.validateGradeRoster(gradeRoster, context); |
| 68 | 0 | if (!errors.isEmpty()) { |
| 69 | 0 | throw new DataValidationErrorException("Error(s) validating graderoster", errors); |
| 70 | |
} |
| 71 | 0 | } catch (DoesNotExistException ex) { |
| 72 | 0 | throw new OperationFailedException("Error validating graderoster", ex); |
| 73 | 0 | } |
| 74 | 0 | } |
| 75 | |
|
| 76 | |
@Override |
| 77 | |
public List<ValidationResultInfo> validateGradeRoster( |
| 78 | |
GradeRosterInfo gradeRoster, ContextInfo context) |
| 79 | |
throws DoesNotExistException, InvalidParameterException, |
| 80 | |
MissingParameterException, OperationFailedException { |
| 81 | |
List<ValidationResultInfo> errors; |
| 82 | |
try { |
| 83 | 0 | errors = ValidationUtils.validateInfo(validator, DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), gradeRoster, context); |
| 84 | 0 | List<ValidationResultInfo> nextDecoratorErrors = |
| 85 | |
getNextDecorator().validateGradeRoster(gradeRoster, context); |
| 86 | 0 | if (null != nextDecoratorErrors) { |
| 87 | 0 | errors.addAll(nextDecoratorErrors); |
| 88 | |
} |
| 89 | |
} |
| 90 | 0 | catch (DoesNotExistException ex) { |
| 91 | 0 | throw new OperationFailedException("Error trying to validate course offering", ex); |
| 92 | 0 | } |
| 93 | 0 | return errors; |
| 94 | |
} |
| 95 | |
|
| 96 | |
@Override |
| 97 | |
public GradeRosterInfo updateInterimGradeRoster(GradeRosterInfo gradeRoster, ContextInfo context) |
| 98 | |
throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, |
| 99 | |
MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException { |
| 100 | 0 | gradingFullValidation(gradeRoster, context); |
| 101 | 0 | return getNextDecorator().updateInterimGradeRoster(gradeRoster, context); |
| 102 | |
} |
| 103 | |
} |