001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.datadictionary.validation.result; 017 018import org.kuali.rice.krad.datadictionary.validation.ErrorLevel; 019import org.kuali.rice.krad.datadictionary.validation.constraint.Constraint; 020import org.kuali.rice.krad.datadictionary.validation.processor.ConstraintProcessor; 021 022import java.util.LinkedList; 023import java.util.List; 024 025/** 026 * This is a composite class for all the different members that need to be returned when a {@link ConstraintProcessor} 027 * processes a {@link Constraint}. 028 * 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 */ 031public class ConstraintValidationResult { 032 033 private String entryName; 034 private String attributeName; 035 private String attributePath; 036 private String constraintName; 037 private ErrorLevel level; 038 039 private String errorKey; 040 private String[] errorParameters = {}; 041 private String constraintLabelKey; 042 043 private List<ConstraintValidationResult> children; 044 045 046 public ConstraintValidationResult(String constraintName) { 047 this.constraintName = constraintName; 048 this.children = new LinkedList<ConstraintValidationResult>(); 049 this.level = ErrorLevel.OK; 050 } 051 052 public ConstraintValidationResult(String constraintName, ErrorLevel level) { 053 this.constraintName = constraintName; 054 this.children = new LinkedList<ConstraintValidationResult>(); 055 this.level = level; 056 } 057 058 public void addChild(ConstraintValidationResult child) { 059 this.children.add(child); 060 } 061 062 public void setError(String errorKey, String... errorParameters) { 063 this.level = ErrorLevel.ERROR; 064 this.errorKey = errorKey; 065 this.errorParameters = errorParameters; 066 } 067 068 public void setWarning(String errorKey, String... errorParameters) { 069 this.level = ErrorLevel.WARN; 070 this.errorKey = errorKey; 071 this.errorParameters = errorParameters; 072 } 073 074 /** 075 * @return the level 076 */ 077 public ErrorLevel getStatus() { 078 return this.level; 079 } 080 081 /** 082 * @param level the level to set 083 */ 084 public void setStatus(ErrorLevel level) { 085 this.level = level; 086 } 087 088 /** 089 * @return the errorKey 090 */ 091 public String getErrorKey() { 092 return this.errorKey; 093 } 094 095 /** 096 * @param errorKey the errorKey to set 097 */ 098 public void setErrorKey(String errorKey) { 099 this.errorKey = errorKey; 100 } 101 102 /** 103 * @return the errorParameters 104 */ 105 public String[] getErrorParameters() { 106 return this.errorParameters; 107 } 108 109 /** 110 * @param errorParameters the errorParameters to set 111 */ 112 public void setErrorParameters(String[] errorParameters) { 113 this.errorParameters = errorParameters; 114 } 115 116 /** 117 * @return the entryName 118 */ 119 public String getEntryName() { 120 return this.entryName; 121 } 122 123 /** 124 * @param entryName the entryName to set 125 */ 126 public void setEntryName(String entryName) { 127 this.entryName = entryName; 128 } 129 130 /** 131 * @return the attributeName 132 */ 133 public String getAttributeName() { 134 return this.attributeName; 135 } 136 137 /** 138 * @param attributeName the attributeName to set 139 */ 140 public void setAttributeName(String attributeName) { 141 this.attributeName = attributeName; 142 } 143 144 /** 145 * @return the constraintName 146 */ 147 public String getConstraintName() { 148 return this.constraintName; 149 } 150 151 /** 152 * @param constraintName the constraintName to set 153 */ 154 public void setConstraintName(String constraintName) { 155 this.constraintName = constraintName; 156 } 157 158 /** 159 * @return the children 160 */ 161 public List<ConstraintValidationResult> getChildren() { 162 return this.children; 163 } 164 165 /** 166 * @return the constraintLabelKey 167 */ 168 public String getConstraintLabelKey() { 169 return this.constraintLabelKey; 170 } 171 172 /** 173 * @param constraintLabelKey the constraintLabelKey to set 174 */ 175 public void setConstraintLabelKey(String constraintLabelKey) { 176 this.constraintLabelKey = constraintLabelKey; 177 } 178 179 /** 180 * @return the attributePath 181 */ 182 public String getAttributePath() { 183 return this.attributePath; 184 } 185 186 /** 187 * @param attributePath the attributePath to set 188 */ 189 public void setAttributePath(String attributePath) { 190 this.attributePath = attributePath; 191 } 192 193}