Coverage Report - org.kuali.rice.krad.datadictionary.validation.result.ConstraintValidationResult
 
Classes in this File Line Coverage Branch Coverage Complexity
ConstraintValidationResult
60%
27/45
N/A
1
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.krad.datadictionary.validation.result;
 17  
 
 18  
 import org.kuali.rice.krad.datadictionary.validation.ErrorLevel;
 19  
 import org.kuali.rice.krad.datadictionary.validation.constraint.Constraint;
 20  
 import org.kuali.rice.krad.datadictionary.validation.processor.ConstraintProcessor;
 21  
 
 22  
 import java.util.LinkedList;
 23  
 import java.util.List;
 24  
 
 25  
 /**
 26  
  * This is a composite class for all the different members that need to be returned when a {@link ConstraintProcessor}
 27  
  * processes a {@link Constraint}. 
 28  
  * 
 29  
  * @author Kuali Rice Team (rice.collab@kuali.org) 
 30  
  */
 31  
 public class ConstraintValidationResult {
 32  
         
 33  
         private String entryName;
 34  
         private String attributeName;
 35  
         private String attributePath;
 36  
         private String constraintName;
 37  
         private ErrorLevel level;
 38  
         
 39  
         private String errorKey;
 40  
         private String[] errorParameters;
 41  
         private String constraintLabelKey;
 42  
         
 43  
         private List<ConstraintValidationResult> children;
 44  
         
 45  
         
 46  155
         public ConstraintValidationResult(String constraintName) {
 47  155
                 this.constraintName = constraintName;
 48  155
                 this.children = new LinkedList<ConstraintValidationResult>();
 49  155
                 this.level = ErrorLevel.OK;
 50  155
         }
 51  
         
 52  0
         public ConstraintValidationResult(String constraintName, ErrorLevel level) {
 53  0
                 this.constraintName = constraintName;
 54  0
                 this.children = new LinkedList<ConstraintValidationResult>();
 55  0
                 this.level = level;
 56  0
         }
 57  
         
 58  
         public void addChild(ConstraintValidationResult child) {
 59  12
                 this.children.add(child);
 60  12
         }
 61  
         
 62  
         public void setError(String errorKey, String... errorParameters) {
 63  75
                 this.level = ErrorLevel.ERROR;
 64  75
                 this.errorKey = errorKey;
 65  75
                 this.errorParameters = errorParameters;
 66  75
         }
 67  
         
 68  
         public void setWarning(String errorKey, String... errorParameters) {
 69  0
                 this.level = ErrorLevel.WARN;
 70  0
                 this.errorKey = errorKey;
 71  0
                 this.errorParameters = errorParameters;
 72  0
         }
 73  
 
 74  
         /**
 75  
          * @return the level
 76  
          */
 77  
         public ErrorLevel getStatus() {
 78  285
                 return this.level;
 79  
         }
 80  
 
 81  
         /**
 82  
          * @param level the level to set
 83  
          */
 84  
         public void setStatus(ErrorLevel level) {
 85  19
                 this.level = level;
 86  19
         }
 87  
 
 88  
         /**
 89  
          * @return the errorKey
 90  
          */
 91  
         public String getErrorKey() {
 92  1
                 return this.errorKey;
 93  
         }
 94  
 
 95  
         /**
 96  
          * @param errorKey the errorKey to set
 97  
          */
 98  
         public void setErrorKey(String errorKey) {
 99  0
                 this.errorKey = errorKey;
 100  0
         }
 101  
 
 102  
         /**
 103  
          * @return the errorParameters
 104  
          */
 105  
         public String[] getErrorParameters() {
 106  0
                 return this.errorParameters;
 107  
         }
 108  
 
 109  
         /**
 110  
          * @param errorParameters the errorParameters to set
 111  
          */
 112  
         public void setErrorParameters(String[] errorParameters) {
 113  0
                 this.errorParameters = errorParameters;
 114  0
         }
 115  
 
 116  
         /**
 117  
          * @return the entryName
 118  
          */
 119  
         public String getEntryName() {
 120  66
                 return this.entryName;
 121  
         }
 122  
 
 123  
         /**
 124  
          * @param entryName the entryName to set
 125  
          */
 126  
         public void setEntryName(String entryName) {
 127  143
                 this.entryName = entryName;
 128  143
         }
 129  
 
 130  
         /**
 131  
          * @return the attributeName
 132  
          */
 133  
         public String getAttributeName() {
 134  66
                 return this.attributeName;
 135  
         }
 136  
 
 137  
         /**
 138  
          * @param attributeName the attributeName to set
 139  
          */
 140  
         public void setAttributeName(String attributeName) {
 141  144
                 this.attributeName = attributeName;
 142  144
         }
 143  
 
 144  
         /**
 145  
          * @return the constraintName
 146  
          */
 147  
         public String getConstraintName() {
 148  207
                 return this.constraintName;
 149  
         }
 150  
 
 151  
         /**
 152  
          * @param constraintName the constraintName to set
 153  
          */
 154  
         public void setConstraintName(String constraintName) {
 155  0
                 this.constraintName = constraintName;
 156  0
         }
 157  
 
 158  
         /**
 159  
          * @return the children
 160  
          */
 161  
         public List<ConstraintValidationResult> getChildren() {
 162  0
                 return this.children;
 163  
         }
 164  
 
 165  
         /**
 166  
          * @return the constraintLabelKey
 167  
          */
 168  
         public String getConstraintLabelKey() {
 169  0
                 return this.constraintLabelKey;
 170  
         }
 171  
 
 172  
         /**
 173  
          * @param constraintLabelKey the constraintLabelKey to set
 174  
          */
 175  
         public void setConstraintLabelKey(String constraintLabelKey) {
 176  3
                 this.constraintLabelKey = constraintLabelKey;
 177  3
         }
 178  
 
 179  
         /**
 180  
          * @return the attributePath
 181  
          */
 182  
         public String getAttributePath() {
 183  66
                 return this.attributePath;
 184  
         }
 185  
 
 186  
         /**
 187  
          * @param attributePath the attributePath to set
 188  
          */
 189  
         public void setAttributePath(String attributePath) {
 190  143
                 this.attributePath = attributePath;
 191  143
         }
 192  
         
 193  
 }