View Javadoc

1   /**
2    * Copyright 2005-2015 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  	public ConstraintValidationResult(String constraintName) {
47  		this.constraintName = constraintName;
48  		this.children = new LinkedList<ConstraintValidationResult>();
49  		this.level = ErrorLevel.OK;
50  	}
51  	
52  	public ConstraintValidationResult(String constraintName, ErrorLevel level) {
53  		this.constraintName = constraintName;
54  		this.children = new LinkedList<ConstraintValidationResult>();
55  		this.level = level;
56  	}
57  	
58  	public void addChild(ConstraintValidationResult child) {
59  		this.children.add(child);
60  	}
61  	
62  	public void setError(String errorKey, String... errorParameters) {
63  		this.level = ErrorLevel.ERROR;
64  		this.errorKey = errorKey;
65  		this.errorParameters = errorParameters;
66  	}
67  	
68  	public void setWarning(String errorKey, String... errorParameters) {
69  		this.level = ErrorLevel.WARN;
70  		this.errorKey = errorKey;
71  		this.errorParameters = errorParameters;
72  	}
73  
74  	/**
75  	 * @return the level
76  	 */
77  	public ErrorLevel getStatus() {
78  		return this.level;
79  	}
80  
81  	/**
82  	 * @param level the level to set
83  	 */
84  	public void setStatus(ErrorLevel level) {
85  		this.level = level;
86  	}
87  
88  	/**
89  	 * @return the errorKey
90  	 */
91  	public String getErrorKey() {
92  		return this.errorKey;
93  	}
94  
95  	/**
96  	 * @param errorKey the errorKey to set
97  	 */
98  	public void setErrorKey(String errorKey) {
99  		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 }