Coverage Report - org.kuali.student.enrollment.class2.courseoffering.service.decorators.CourseOfferingServiceValidationDecorator
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseOfferingServiceValidationDecorator
0%
0/59
0%
0/12
3.182
 
 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.CourseOfferingInfo;
 6  
 import org.kuali.student.enrollment.courseoffering.dto.FormatOfferingInfo;
 7  
 import org.kuali.student.r2.common.datadictionary.DataDictionaryValidator;
 8  
 import org.kuali.student.r2.common.dto.ContextInfo;
 9  
 import org.kuali.student.r2.common.dto.StatusInfo;
 10  
 import org.kuali.student.r2.common.dto.ValidationResultInfo;
 11  
 
 12  
 import org.kuali.student.r2.common.exceptions.*;
 13  
 
 14  
 import org.kuali.student.r2.common.infc.HoldsValidator;
 15  
 import org.kuali.student.r2.core.class1.util.ValidationUtils;
 16  
 
 17  
 
 18  0
 public class CourseOfferingServiceValidationDecorator 
 19  
     extends CourseOfferingServiceDecorator 
 20  
     implements HoldsValidator {
 21  
 
 22  
     private DataDictionaryValidator validator;
 23  
 
 24  
     @Override
 25  
     public DataDictionaryValidator getValidator() {
 26  0
         return validator;
 27  
     }
 28  
 
 29  
     @Override
 30  
     public void setValidator(DataDictionaryValidator validator) {
 31  0
         this.validator = validator;
 32  0
     }
 33  
 
 34  
 
 35  
     @Override
 36  
     public List<ValidationResultInfo> validateCourseOffering(
 37  
             String validationType, CourseOfferingInfo courseOfferingInfo,
 38  
             ContextInfo context) throws DoesNotExistException,
 39  
             InvalidParameterException, MissingParameterException,
 40  
             OperationFailedException {
 41  
         List<ValidationResultInfo> errors;
 42  
         try {
 43  0
             errors = ValidationUtils.validateInfo(validator, validationType, courseOfferingInfo, context);
 44  0
             List<ValidationResultInfo> nextDecoratorErrors =
 45  
                     getNextDecorator().validateCourseOffering(validationType, courseOfferingInfo, context);
 46  0
             if (null != nextDecoratorErrors) {
 47  0
                 errors.addAll(nextDecoratorErrors);
 48  
             }
 49  0
         } catch (DoesNotExistException ex) {
 50  0
             throw new OperationFailedException("Error trying to validate course offering", ex);
 51  0
         }
 52  0
         return errors;
 53  
     }
 54  
 
 55  
     private void _courseOfferingFullValidation(CourseOfferingInfo courseOfferingInfo, ContextInfo context)
 56  
             throws DataValidationErrorException, OperationFailedException, InvalidParameterException, MissingParameterException {
 57  
         try {
 58  0
             List<ValidationResultInfo> errors =
 59  
                     this.validateCourseOffering(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), courseOfferingInfo, context);
 60  0
             if (!errors.isEmpty()) {
 61  0
                 throw new DataValidationErrorException("Error(s) validating course offering", errors);
 62  
             }
 63  0
         } catch (DoesNotExistException ex) {
 64  0
             throw new OperationFailedException("Error validating course offering", ex);
 65  0
         }
 66  0
     }
 67  
 
 68  
     private void _formatOfferingFullValidation(FormatOfferingInfo formatOfferingInfo, ContextInfo context)
 69  
             throws DataValidationErrorException, OperationFailedException, InvalidParameterException, MissingParameterException {
 70  
         try {
 71  0
             List<ValidationResultInfo> errors =
 72  
                     this.validateFormatOffering(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), formatOfferingInfo, context);
 73  0
             if (!errors.isEmpty()) {
 74  0
                 throw new DataValidationErrorException("Error(s) validating course offering", errors);
 75  
             }
 76  0
         } catch (DoesNotExistException ex) {
 77  0
             throw new OperationFailedException("Error validating course offering", ex);
 78  0
         }
 79  0
     }
 80  
 
 81  
     @Override
 82  
     public FormatOfferingInfo updateFormatOffering(String formatOfferingId, FormatOfferingInfo formatOfferingInfo, ContextInfo context)
 83  
             throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, 
 84  
             MissingParameterException, OperationFailedException, PermissionDeniedException,
 85  
                    ReadOnlyException, VersionMismatchException {
 86  
         try {
 87  0
             List<ValidationResultInfo> errors = this.validateFormatOffering(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), formatOfferingInfo, context);
 88  0
             if (errors != null) {
 89  0
                 throw new DataValidationErrorException("Update method failed due to validation errors", errors);
 90  
             }
 91  0
         } catch (DoesNotExistException e) {
 92  0
             throw new OperationFailedException(e.getMessage());
 93  0
         }
 94  0
         return getNextDecorator().updateFormatOffering(formatOfferingId, formatOfferingInfo, context);
 95  
 
 96  
     }
 97  
 
 98  
     @Override
 99  
     public CourseOfferingInfo updateCourseOffering(String courseOfferingId,
 100  
             CourseOfferingInfo courseOfferingInfo, ContextInfo context)
 101  
             throws DataValidationErrorException, DoesNotExistException,
 102  
             InvalidParameterException, MissingParameterException,
 103  
             OperationFailedException, PermissionDeniedException,
 104  
                    ReadOnlyException, VersionMismatchException {
 105  0
         _courseOfferingFullValidation(courseOfferingInfo, context);
 106  0
         return getNextDecorator().updateCourseOffering(courseOfferingId, courseOfferingInfo, context);
 107  
     }
 108  
 
 109  
     //createCourseOffering
 110  
     @Override
 111  
     public CourseOfferingInfo createCourseOffering(String courseId, String termId, String courseOfferingTypeKey,
 112  
             CourseOfferingInfo coInfo, List<String> optionKeys, ContextInfo context)
 113  
             throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, 
 114  
                    MissingParameterException, OperationFailedException, PermissionDeniedException, 
 115  
                    ReadOnlyException {
 116  0
         CourseOfferingInfo courseOfferingInfo = getCourseOffering(courseId, context);
 117  0
         _courseOfferingFullValidation(courseOfferingInfo, context);
 118  0
         return getNextDecorator().createCourseOffering(courseId, termId, courseOfferingTypeKey, coInfo, optionKeys, context);
 119  
     }
 120  
 
 121  
     //deleteCourseOffering
 122  
     @Override
 123  
     public StatusInfo deleteCourseOffering(String courseOfferingId, ContextInfo context)
 124  
             throws DoesNotExistException, InvalidParameterException, MissingParameterException,
 125  
             OperationFailedException, PermissionDeniedException,DependentObjectsExistException {
 126  
         try {
 127  0
             CourseOfferingInfo courseOfferingInfo = getCourseOffering(courseOfferingId, context);
 128  0
             _courseOfferingFullValidation(courseOfferingInfo, context);
 129  0
         } catch (DataValidationErrorException ex) {
 130  0
             throw new OperationFailedException("Error validating course offering", ex);
 131  0
         }
 132  0
         return getNextDecorator().deleteCourseOffering(courseOfferingId, context);
 133  
     }
 134  
 
 135  
     @Override
 136  
     public List<ValidationResultInfo> validateFormatOffering(
 137  
             String validationType, FormatOfferingInfo formatOfferingInfo,
 138  
             ContextInfo context) throws DoesNotExistException,
 139  
             InvalidParameterException, MissingParameterException,
 140  
             OperationFailedException {
 141  
         List<ValidationResultInfo> errors;
 142  
         try {
 143  0
             errors = ValidationUtils.validateInfo(validator, validationType, formatOfferingInfo, context);
 144  0
             List<ValidationResultInfo> nextDecoratorErrors =
 145  
                     getNextDecorator().validateFormatOffering(validationType, formatOfferingInfo, context);
 146  0
             if (null != nextDecoratorErrors) {
 147  0
                 errors.addAll(nextDecoratorErrors);
 148  
             }
 149  0
         } catch (DoesNotExistException ex) {
 150  0
             throw new OperationFailedException("Error trying to validate course offering", ex);
 151  0
         }
 152  0
         return errors;
 153  
     }
 154  
 
 155  
     @Override
 156  
     public FormatOfferingInfo createFormatOffering(
 157  
             String courseOfferingId, String formatId, String formatOfferingType, FormatOfferingInfo formatOfferingInfo,
 158  
             ContextInfo context) throws DoesNotExistException, DataValidationErrorException, InvalidParameterException, MissingParameterException,
 159  
                                         OperationFailedException, PermissionDeniedException, ReadOnlyException  {
 160  
         try {
 161  0
             List<ValidationResultInfo> errors = this.validateFormatOffering(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), formatOfferingInfo, context);
 162  0
             if (errors != null) {
 163  0
                 throw new DataValidationErrorException("Create method failed due to validation errors", errors);
 164  
             }
 165  0
         } catch (DoesNotExistException e) {
 166  0
             throw new OperationFailedException(e.getMessage());
 167  0
         }
 168  0
         return getNextDecorator().createFormatOffering(courseOfferingId, formatId, formatOfferingType, formatOfferingInfo, context);
 169  
     }
 170  
 }