Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AttributeValidationResult |
|
| 1.1666666666666667;1.167 |
1 | /** | |
2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | ||
16 | package org.kuali.rice.kns.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 | 0 | public AttributeValidationResult(String attributeName) { |
29 | 0 | this.attributeName = attributeName; |
30 | 0 | this.constraintValidationResultMap = new LinkedHashMap<String, ConstraintValidationResult>(); |
31 | 0 | } |
32 | ||
33 | public void addConstraintValidationResult(ConstraintValidationResult constraintValidationResult) { | |
34 | 0 | constraintValidationResultMap.put(constraintValidationResult.getConstraintName(), constraintValidationResult); |
35 | 0 | } |
36 | ||
37 | public Iterator<ConstraintValidationResult> iterator() { | |
38 | 0 | return constraintValidationResultMap.values().iterator(); |
39 | } | |
40 | ||
41 | protected ConstraintValidationResult getConstraintValidationResult(String constraintName) { | |
42 | 0 | ConstraintValidationResult constraintValidationResult = constraintValidationResultMap.get(constraintName); |
43 | 0 | if (constraintValidationResult == null) { |
44 | 0 | constraintValidationResult = new ConstraintValidationResult(constraintName); |
45 | 0 | constraintValidationResultMap.put(constraintName, constraintValidationResult); |
46 | } | |
47 | 0 | return constraintValidationResult; |
48 | } | |
49 | ||
50 | /** | |
51 | * @return the attributeName | |
52 | */ | |
53 | public String getAttributeName() { | |
54 | 0 | return this.attributeName; |
55 | } | |
56 | ||
57 | /** | |
58 | * @param attributeName the attributeName to set | |
59 | */ | |
60 | public void setAttributeName(String attributeName) { | |
61 | 0 | this.attributeName = attributeName; |
62 | 0 | } |
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 | } |