Coverage Report - org.kuali.student.r2.common.dto.ValidationResultInfo
 
Classes in this File Line Coverage Branch Coverage Complexity
ValidationResultInfo
0%
0/43
0%
0/8
1.048
 
 1  
 /*
 2  
  * Copyright 2010 The Kuali Foundation 
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the
 5  
  * "License"); you may not use this file except in compliance with the
 6  
  * License. You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.osedu.org/licenses/ECL-2.0
 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
 13  
  * implied. See the License for the specific language governing
 14  
  * permissions and limitations under the License.
 15  
  */
 16  
 package org.kuali.student.r2.common.dto;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.List;
 20  
 
 21  
 import javax.xml.bind.annotation.XmlAccessType;
 22  
 import javax.xml.bind.annotation.XmlAccessorType;
 23  
 import javax.xml.bind.annotation.XmlAnyElement;
 24  
 import javax.xml.bind.annotation.XmlElement;
 25  
 import javax.xml.bind.annotation.XmlType;
 26  
 
 27  
 import org.kuali.student.r2.common.infc.ValidationResult;
 28  
 import org.w3c.dom.Element;
 29  
 
 30  
 /**
 31  
  * Information about the results of a data validation.
 32  
  *
 33  
  * @author nwright
 34  
  */
 35  
 @XmlAccessorType(XmlAccessType.FIELD)
 36  
 @XmlType(name = "ValidationResultInfo", propOrder = {
 37  
     "element", "level", "message",
 38  
     "_futureElements"})
 39  
 public class ValidationResultInfo
 40  
         implements ValidationResult, Serializable {
 41  
 
 42  
     private static final long serialVersionUID = 1L;
 43  
     @XmlElement
 44  
     private String element;
 45  
     @XmlElement
 46  
     private ErrorLevel level;
 47  
     @XmlElement
 48  
     private String message;
 49  
 //  used to hold debugging information 
 50  
 //  not intended to be sent over the wire          
 51  
     private transient Object invalidData;
 52  
     @XmlAnyElement
 53  
     private List<Element> _futureElements;
 54  
 
 55  
     /**
 56  
      * Constructs a new ValidationResultInfo.
 57  
      */
 58  0
     public ValidationResultInfo() {
 59  0
       this.level = ErrorLevel.OK;
 60  0
     }
 61  
     
 62  
     /**
 63  
      * convenience constructor carried over from R1
 64  
      */
 65  
     public ValidationResultInfo(String element) {
 66  0
         this();
 67  0
         this.element = element;
 68  0
     }
 69  
     
 70  
     /**
 71  
      * convenience constructor carried over from R1
 72  
      */
 73  
     public ValidationResultInfo(String element, Object invalidData) {
 74  0
         this(element);
 75  0
         this.invalidData = invalidData;
 76  0
     }
 77  
 
 78  
     /**
 79  
      * Constructs a new ValidationResultInfo from another
 80  
      * ValidationResult.
 81  
      *
 82  
      * @param result the ValidationResult to copy
 83  
      */
 84  0
     public ValidationResultInfo(ValidationResult result) {
 85  0
         if (result != null) {
 86  0
             this.level = result.getLevel();
 87  0
             this.element = result.getElement();
 88  0
             this.message = result.getMessage();
 89  
         }
 90  0
     }
 91  
 
 92  
     /**
 93  
      * This is for compatibility with R1.
 94  
      * Use getLevel instead
 95  
      */
 96  
     @Deprecated
 97  
     public ErrorLevel getErrorLevel() {
 98  0
         return level;
 99  
     }
 100  
 
 101  
     public void setErrorLevel(ErrorLevel errorLevel) {
 102  0
         this.level = errorLevel;
 103  0
     }
 104  
 
 105  
     /**
 106  
      * Convenience method from R1 to check if this is ok
 107  
      */
 108  
     public boolean isOk() {
 109  0
         return this.level == ErrorLevel.OK;
 110  
     }
 111  
 
 112  
     /**
 113  
      * convenience method carried over from R1
 114  
      */
 115  
     public boolean isWarn() {
 116  0
         return this.level == ErrorLevel.WARN;
 117  
     }
 118  
 
 119  
     /**
 120  
      * convenience method carried over from R1
 121  
      */
 122  
     public void setWarn(String message) {
 123  0
         this.level = ErrorLevel.WARN;
 124  0
         this.message = message;
 125  0
     }
 126  
 
 127  
     /**
 128  
      * convenience method carried over from R1
 129  
      */
 130  
     public boolean isError() {
 131  0
         return this.level == ErrorLevel.ERROR;
 132  
     }
 133  
 
 134  
     @Override
 135  
     public String getMessage() {
 136  0
         return message;
 137  
     }
 138  
 
 139  
     public void setMessage(String message) {
 140  0
         this.message = message;
 141  0
     }
 142  
 
 143  
     @Override
 144  
     public String getElement() {
 145  0
         return element;
 146  
     }
 147  
 
 148  
     public void setElement(String element) {
 149  0
         this.element = element;
 150  0
     }
 151  
 
 152  
     /**
 153  
      * convenience method carried over from R1
 154  
      * Use getErrorLevel () instead
 155  
      */
 156  
     @Override
 157  
     public ErrorLevel getLevel() {
 158  0
         return this.level;
 159  
     }
 160  
 
 161  
     public void setLevel(ErrorLevel level) {
 162  0
         this.level = level;
 163  0
     }
 164  
 
 165  
     
 166  
     /**
 167  
      * not part of the contract but carried over from r1
 168  
      */
 169  
     public Object getInvalidData() {
 170  0
         return invalidData;
 171  
     }
 172  
 
 173  
     /**
 174  
      * not part of the contract but carried over from r1
 175  
      */
 176  
     public void setInvalidData(Object invalidData) {
 177  0
         this.invalidData = invalidData;
 178  0
     }
 179  
 
 180  
     @Override
 181  
     public String toString() {
 182  0
         return "[" + level + "] Path: [" + element + "] - " + message + " data=[" + invalidData + "]";
 183  
     }
 184  
 
 185  
     /**
 186  
      * Convenience method. Adds a message with an error level of WARN
 187  
      *
 188  
      * @param message the warning message 
 189  
      */
 190  
     public void setWarning(String message) {
 191  0
         this.level = ErrorLevel.WARN;
 192  0
         this.message = message;
 193  0
     }
 194  
 
 195  
     /**
 196  
      * Convenience method. Adds a message with an error level of ERROR
 197  
      *
 198  
      * @param message the error message to add
 199  
      */
 200  
     public void setError(String message) {
 201  0
         this.level = ErrorLevel.ERROR;
 202  0
         this.message = message;
 203  0
     }
 204  
 
 205  
 }