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 java.io.Serializable;
19 import java.util.Iterator;
20 import java.util.LinkedHashMap;
21 import java.util.Map;
22
23 public class AttributeValidationResult implements Serializable {
24
25 private String attributeName;
26 private Map<String, ConstraintValidationResult> constraintValidationResultMap;
27
28 public AttributeValidationResult(String attributeName) {
29 this.attributeName = attributeName;
30 this.constraintValidationResultMap = new LinkedHashMap<String, ConstraintValidationResult>();
31 }
32
33 public void addConstraintValidationResult(ConstraintValidationResult constraintValidationResult) {
34 constraintValidationResultMap.put(constraintValidationResult.getConstraintName(), constraintValidationResult);
35 }
36
37 public Iterator<ConstraintValidationResult> iterator() {
38 return constraintValidationResultMap.values().iterator();
39 }
40
41 protected ConstraintValidationResult getConstraintValidationResult(String constraintName) {
42 ConstraintValidationResult constraintValidationResult = constraintValidationResultMap.get(constraintName);
43 if (constraintValidationResult == null) {
44 constraintValidationResult = new ConstraintValidationResult(constraintName);
45 constraintValidationResultMap.put(constraintName, constraintValidationResult);
46 }
47 return constraintValidationResult;
48 }
49
50 /**
51 * @return the attributeName
52 */
53 public String getAttributeName() {
54 return this.attributeName;
55 }
56
57 /**
58 * @param attributeName the attributeName to set
59 */
60 public void setAttributeName(String attributeName) {
61 this.attributeName = attributeName;
62 }
63
64 /*
65 private static final long serialVersionUID = 1L;
66
67 protected String element;
68
69 protected ErrorLevel level = ErrorLevel.OK;
70
71 private String entryName;
72 private String attributeName;
73 private String errorKey;
74 private String[] errorParameters;
75
76 public AttributeValidationResult(String attributeName) {
77 this.level = ErrorLevel.OK;
78 this.attributeName = attributeName;
79 }
80
81 public AttributeValidationResult(String entryName, String attributeName) {
82 this.level = ErrorLevel.OK;
83 this.entryName = entryName;
84 this.attributeName = attributeName;
85 }
86
87 public ErrorLevel getLevel() {
88 return level;
89 }
90
91 public void setLevel(ErrorLevel level) {
92 this.level = level;
93 }
94
95 public String getElement() {
96 return element;
97 }
98
99 public void setElement(String element) {
100 this.element = element;
101 }
102
103
104 public ErrorLevel getErrorLevel() {
105 return level;
106 }
107
108 public void setError(String errorKey, String... errorParameters) {
109 this.level = ErrorLevel.ERROR;
110 this.errorKey = errorKey;
111 this.errorParameters = errorParameters;
112 }
113
114 public boolean isOk() {
115 return getErrorLevel() == ErrorLevel.OK;
116 }
117
118
119 public boolean isWarn() {
120 return getErrorLevel() == ErrorLevel.WARN;
121 }
122
123 public boolean isError() {
124 return getErrorLevel() == ErrorLevel.ERROR;
125 }
126
127 public String toString(){
128 return "Entry: [" + entryName + "] Attribute: [" + attributeName + "] - " + errorKey + " data=[" + errorParameters + "]";
129 }
130
131 public String getEntryName() {
132 return this.entryName;
133 }
134
135 public void setEntryName(String entryName) {
136 this.entryName = entryName;
137 }
138
139 public String getAttributeName() {
140 return this.attributeName;
141 }
142
143 public void setAttributeName(String attributeName) {
144 this.attributeName = attributeName;
145 }
146
147 public String getErrorKey() {
148 return this.errorKey;
149 }
150
151 public void setErrorKey(String errorKey) {
152 this.errorKey = errorKey;
153 }
154
155 public String[] getErrorParameters() {
156 return this.errorParameters;
157 }
158 public void setErrorParameters(String[] errorParameters) {
159 this.errorParameters = errorParameters;
160 }
161 */
162
163 }