Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 The Kuali Foundation 
   *
   * Licensed under the Educational Community License, Version 2.0 (the
   * "License"); you may not use this file except in compliance with the
   * License. You may obtain a copy of the License at
   *
   * http://www.osedu.org/licenses/ECL-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  * implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package org.kuali.student.r2.common.dto;
 
 import java.util.List;
 
 
Information about the results of a data validation.

Author(s):
nwright
 
 @XmlType(name = "ValidationResultInfo", propOrder = {
     "element""level""message" , "_futureElements" }) 
     
 public class ValidationResultInfo
         implements ValidationResultSerializable {
 
     private static final long serialVersionUID = 1L;
     @XmlElement
     private String element;
     @XmlElement
     private ErrorLevel level;
     @XmlElement
     private String message;
 //  used to hold debugging information 
 //  not intended to be sent over the wire          
     private transient Object invalidData;
     
     @XmlAnyElement
     private List<Object_futureElements;  

    
Constructs a new ValidationResultInfo.
 
     public ValidationResultInfo() {
       this. = .;
     }
    
    
convenience constructor carried over from R1
 
     public ValidationResultInfo(String element) {
         this();
         this. = element;
     }
    
    
convenience constructor carried over from R1
 
     public ValidationResultInfo(String elementObject invalidData) {
         this(element);
         this. = invalidData;
     }

    
Constructs a new ValidationResultInfo from another ValidationResult.

Parameters:
result the ValidationResult to copy
 
     public ValidationResultInfo(ValidationResult result) {
         if (result != null) {
             this. = result.getLevel();
             this. = result.getElement();
             this. = result.getMessage();
         }
     }

    
This is for compatibility with R1. Use getLevel instead
 
     @Deprecated
     public ErrorLevel getErrorLevel() {
         return ;
     }
    public void setErrorLevel(ErrorLevel errorLevel) {
        this. = errorLevel;
    }

    
Convenience method from R1 to check if this is ok
    public boolean isOk() {
        return this. == .;
    }

    
convenience method carried over from R1
    public boolean isWarn() {
        return this. == .;
    }

    
convenience method carried over from R1
    public void setWarn(String message) {
        this. = .;
        this. = message;
    }

    
convenience method carried over from R1
    public boolean isError() {
        return this. == .;
    }
    @Override
    public String getMessage() {
        return ;
    }
    public void setMessage(String message) {
        this. = message;
    }
    @Override
    public String getElement() {
        return ;
    }
    public void setElement(String element) {
        this. = element;
    }

    
convenience method carried over from R1 Use getErrorLevel () instead
    @Override
    public ErrorLevel getLevel() {
        return this.;
    }
    public void setLevel(ErrorLevel level) {
        this. = level;
    }

    
    
not part of the contract but carried over from r1
    public Object getInvalidData() {
        return ;
    }

    
not part of the contract but carried over from r1
    public void setInvalidData(Object invalidData) {
        this. = invalidData;
    }
    @Override
    public String toString() {
        return "[" +  + "] Path: [" +  + "] - " +  + " data=[" +  + "]";
    }

    
Convenience method. Adds a message with an error level of WARN

Parameters:
message the warning message
    public void setWarning(String message) {
        this. = .;
        this. = message;
    }

    
Convenience method. Adds a message with an error level of ERROR

Parameters:
message the error message to add
    public void setError(String message) {
        this. = .;
        this. = message;
    }
    public static boolean hasValidationErrors(List<ValidationResultInfovalidationResultsErrorLevel thresholdList<StringignoreFields) {
	    if (validationResults != null) {
            for (ValidationResultInfo validationResult : validationResults) {
                //Ignore any fields that are in the list
                if(ignoreFields!=null && !ignoreFields.contains(validationResult.getElement())){
                    //Return true if any of the validation results exceed your threshold
                    if (validationResult.getLevel() == .) {
                        return true;
                    }
                    if (..equals(threshold) && validationResult.getLevel() == .) {
                        return true;
                    }
                }
            }
        }
        return false;
	}
New to GrepCode? Check out our FAQ X