Coverage Report - org.kuali.student.enrollment.class1.lui.service.decorators.LuiServiceValidationDecorator
 
Classes in this File Line Coverage Branch Coverage Complexity
LuiServiceValidationDecorator
0%
0/45
0%
0/8
2.167
 
 1  
 package org.kuali.student.enrollment.class1.lui.service.decorators;
 2  
 
 3  
 import java.util.List;
 4  
 
 5  
 import org.kuali.student.enrollment.lui.dto.LuiInfo;
 6  
 import org.kuali.student.enrollment.lui.dto.LuiLuiRelationInfo;
 7  
 import org.kuali.student.enrollment.lui.service.LuiServiceDecorator;
 8  
 import org.kuali.student.r2.common.datadictionary.DataDictionaryValidator;
 9  
 import org.kuali.student.r2.common.datadictionary.service.DataDictionaryService;
 10  
 import org.kuali.student.r2.common.dto.ContextInfo;
 11  
 import org.kuali.student.r2.common.dto.ValidationResultInfo;
 12  
 import org.kuali.student.r2.common.exceptions.AlreadyExistsException;
 13  
 import org.kuali.student.r2.common.exceptions.CircularRelationshipException;
 14  
 import org.kuali.student.r2.common.exceptions.DataValidationErrorException;
 15  
 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
 16  
 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
 17  
 import org.kuali.student.r2.common.exceptions.MissingParameterException;
 18  
 import org.kuali.student.r2.common.exceptions.OperationFailedException;
 19  
 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
 20  
 import org.kuali.student.r2.common.exceptions.VersionMismatchException;
 21  
 import org.kuali.student.r2.common.infc.HoldsDataDictionaryService;
 22  
 import org.kuali.student.r2.common.infc.HoldsValidator;
 23  
 import org.kuali.student.r2.core.class1.util.ValidationUtils;
 24  
 
 25  0
 public class LuiServiceValidationDecorator extends LuiServiceDecorator implements HoldsValidator, HoldsDataDictionaryService{
 26  
     private DataDictionaryValidator validator;
 27  
     private DataDictionaryService dataDictionaryService;
 28  
     
 29  
     @Override
 30  
     public DataDictionaryValidator getValidator() {
 31  0
         return validator;
 32  
     }
 33  
 
 34  
     @Override
 35  
     public void setValidator(DataDictionaryValidator validator) {
 36  0
         this.validator = validator;        
 37  0
     }
 38  
 
 39  
     @Override
 40  
     public DataDictionaryService getDataDictionaryService() {
 41  0
         return dataDictionaryService;
 42  
     }
 43  
 
 44  
     @Override
 45  
     public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
 46  0
         this.dataDictionaryService = dataDictionaryService;
 47  0
     }
 48  
 
 49  
 
 50  
         @Override
 51  
         public List<ValidationResultInfo> validateLui(String validationType,
 52  
                         LuiInfo luiInfo, ContextInfo context) throws DoesNotExistException,
 53  
                         InvalidParameterException, MissingParameterException,
 54  
                         OperationFailedException {
 55  
         List<ValidationResultInfo> errors;
 56  
         try {
 57  0
             errors = ValidationUtils.validateInfo(validator, validationType, luiInfo, context);
 58  0
             List<ValidationResultInfo> nextDecoratorErrors =
 59  
                     getNextDecorator().validateLui(validationType, luiInfo, context);
 60  0
             if (null != nextDecoratorErrors) {
 61  0
                 errors.addAll(nextDecoratorErrors);
 62  
             }
 63  
         }
 64  0
         catch (DoesNotExistException ex) {
 65  0
             throw new OperationFailedException("Error trying to validate lui", ex);
 66  0
         }
 67  0
         return errors;
 68  
         }
 69  
         
 70  
     private void _luiFullValidation(LuiInfo luiInfo, ContextInfo context)
 71  
                     throws DataValidationErrorException, OperationFailedException, InvalidParameterException, MissingParameterException {
 72  
         try {
 73  0
             List<ValidationResultInfo> errors =
 74  
                     this.validateLui(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), luiInfo, context);
 75  0
             if (!errors.isEmpty()) {
 76  0
                 throw new DataValidationErrorException("Error(s) validating lui", errors);
 77  
             }
 78  0
         } catch (DoesNotExistException ex) {
 79  0
             throw new OperationFailedException("Error validating lui", ex);
 80  0
         }
 81  0
     }
 82  
         
 83  
         @Override
 84  
         public LuiInfo createLui(String cluId, String atpId, LuiInfo luiInfo,
 85  
                         ContextInfo context) throws AlreadyExistsException,
 86  
                         DataValidationErrorException, DoesNotExistException,
 87  
                         InvalidParameterException, MissingParameterException,
 88  
                         OperationFailedException, PermissionDeniedException {
 89  0
                 _luiFullValidation(luiInfo, context);
 90  0
                 return getNextDecorator().createLui(cluId,atpId,luiInfo, context);
 91  
         }
 92  
 
 93  
         @Override
 94  
         public LuiInfo updateLui(String luiId, LuiInfo luiInfo, ContextInfo context)
 95  
                         throws DataValidationErrorException, DoesNotExistException,
 96  
                         InvalidParameterException, MissingParameterException,
 97  
                         OperationFailedException, PermissionDeniedException,
 98  
                         VersionMismatchException {
 99  0
                 _luiFullValidation(luiInfo, context);
 100  0
                 return getNextDecorator().updateLui(luiId,luiInfo, context);
 101  
         }
 102  
         
 103  
         @Override
 104  
         public List<ValidationResultInfo> validateLuiLuiRelation(
 105  
                         String validationType, LuiLuiRelationInfo luiLuiRelationInfo,
 106  
                         ContextInfo context) throws DoesNotExistException,
 107  
                         InvalidParameterException, MissingParameterException,
 108  
                         OperationFailedException {
 109  
         List<ValidationResultInfo> errors;
 110  
         try {
 111  0
             errors = ValidationUtils.validateInfo(validator, validationType, luiLuiRelationInfo, context);
 112  0
             List<ValidationResultInfo> nextDecoratorErrors =
 113  
                     getNextDecorator().validateLuiLuiRelation(validationType, luiLuiRelationInfo, context);
 114  0
             if (null != nextDecoratorErrors) {
 115  0
                 errors.addAll(nextDecoratorErrors);
 116  
             }
 117  
         }
 118  0
         catch (DoesNotExistException ex) {
 119  0
             throw new OperationFailedException("Error trying to validate lui-lui relation", ex);
 120  0
         }
 121  0
         return errors;
 122  
         }
 123  
 
 124  
     private void _luiLuiRelationFullValidation(LuiLuiRelationInfo luiLuiRelationInfo, ContextInfo context)
 125  
                         throws DataValidationErrorException, OperationFailedException, InvalidParameterException, MissingParameterException {
 126  
                 try {
 127  0
                     List<ValidationResultInfo> errors =
 128  
                     this.validateLuiLuiRelation(DataDictionaryValidator.ValidationType.FULL_VALIDATION.toString(), luiLuiRelationInfo, context);
 129  0
                     if (!errors.isEmpty()) {
 130  0
                         throw new DataValidationErrorException("Error(s) validating lui-lui relation", errors);
 131  
                     }
 132  0
                 } catch (DoesNotExistException ex) {
 133  0
                     throw new OperationFailedException("Error validating lui-lui relation", ex);
 134  0
                 }
 135  0
     }
 136  
     
 137  
         @Override
 138  
         public LuiLuiRelationInfo createLuiLuiRelation(String luiId,
 139  
                         String relatedLuiId, String luLuRelationTypeKey,
 140  
                         LuiLuiRelationInfo luiLuiRelationInfo, ContextInfo context)
 141  
                         throws AlreadyExistsException, CircularRelationshipException,
 142  
                         DataValidationErrorException, DoesNotExistException,
 143  
                         InvalidParameterException, MissingParameterException,
 144  
                         OperationFailedException, PermissionDeniedException {
 145  0
                 _luiLuiRelationFullValidation(luiLuiRelationInfo, context);
 146  0
                 return getNextDecorator().createLuiLuiRelation(luiId, relatedLuiId, luLuRelationTypeKey, luiLuiRelationInfo, context);
 147  
         }
 148  
 
 149  
         @Override
 150  
         public LuiLuiRelationInfo updateLuiLuiRelation(String luiLuiRelationId,
 151  
                         LuiLuiRelationInfo luiLuiRelationInfo, ContextInfo context)
 152  
                         throws DataValidationErrorException, DoesNotExistException,
 153  
                         InvalidParameterException, MissingParameterException,
 154  
                         OperationFailedException, PermissionDeniedException,
 155  
                         VersionMismatchException {
 156  0
                 _luiLuiRelationFullValidation(luiLuiRelationInfo, context);
 157  0
                 return getNextDecorator().updateLuiLuiRelation(luiLuiRelationId, luiLuiRelationInfo, context);
 158  
         }
 159  
 
 160  
 }