Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AttributeSecurity |
|
| 1.7333333333333334;1.733 |
1 | /* | |
2 | * Copyright 2007-2008 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.kns.datadictionary; | |
17 | ||
18 | import org.kuali.rice.kns.datadictionary.exception.AttributeValidationException; | |
19 | import org.kuali.rice.kns.datadictionary.mask.MaskFormatter; | |
20 | ||
21 | /** | |
22 | * This class defines a set of restrictions that are possible on an attribute in a | |
23 | * {@link BusinessObjectEntry} or a maintainable field in a {@link MaintenanceDocumentEntry} | |
24 | * | |
25 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
26 | * | |
27 | */ | |
28 | 0 | public class AttributeSecurity extends DataDictionaryDefinitionBase { |
29 | private static final long serialVersionUID = -7923499408946975318L; | |
30 | ||
31 | 0 | boolean readOnly = false; |
32 | 0 | boolean hide = false; |
33 | 0 | boolean mask = false; |
34 | 0 | boolean partialMask = false; |
35 | MaskFormatter partialMaskFormatter; | |
36 | MaskFormatter maskFormatter; | |
37 | ||
38 | /** | |
39 | * @return the readOnly | |
40 | */ | |
41 | public boolean isReadOnly() { | |
42 | 0 | return this.readOnly; |
43 | } | |
44 | ||
45 | /** | |
46 | * @param readOnly | |
47 | * the readOnly to set | |
48 | */ | |
49 | public void setReadOnly(boolean readOnly) { | |
50 | 0 | this.readOnly = readOnly; |
51 | 0 | } |
52 | ||
53 | /** | |
54 | * @return the hide | |
55 | */ | |
56 | public boolean isHide() { | |
57 | 0 | return this.hide; |
58 | } | |
59 | ||
60 | /** | |
61 | * @param hide | |
62 | * the hide to set | |
63 | */ | |
64 | public void setHide(boolean hide) { | |
65 | 0 | this.hide = hide; |
66 | 0 | } |
67 | ||
68 | /** | |
69 | * @return the mask | |
70 | */ | |
71 | public boolean isMask() { | |
72 | 0 | return this.mask; |
73 | } | |
74 | ||
75 | /** | |
76 | * @param mask | |
77 | * the mask to set | |
78 | */ | |
79 | public void setMask(boolean mask) { | |
80 | 0 | this.mask = mask; |
81 | 0 | } |
82 | ||
83 | /** | |
84 | * @return the partialMask | |
85 | */ | |
86 | public boolean isPartialMask() { | |
87 | 0 | return this.partialMask; |
88 | } | |
89 | ||
90 | /** | |
91 | * @param partialMask | |
92 | * the partialMask to set | |
93 | */ | |
94 | public void setPartialMask(boolean partialMask) { | |
95 | 0 | this.partialMask = partialMask; |
96 | 0 | } |
97 | ||
98 | /** | |
99 | * @return the maskFormatter | |
100 | */ | |
101 | public MaskFormatter getMaskFormatter() { | |
102 | 0 | return this.maskFormatter; |
103 | } | |
104 | ||
105 | /** | |
106 | * @param maskFormatter | |
107 | * the maskFormatter to set | |
108 | */ | |
109 | public void setMaskFormatter(MaskFormatter maskFormatter) { | |
110 | 0 | this.maskFormatter = maskFormatter; |
111 | 0 | } |
112 | ||
113 | /** | |
114 | * @return the partialMaskFormatter | |
115 | */ | |
116 | public MaskFormatter getPartialMaskFormatter() { | |
117 | 0 | return this.partialMaskFormatter; |
118 | } | |
119 | ||
120 | /** | |
121 | * @param partialMaskFormatter | |
122 | * the partialMaskFormatter to set | |
123 | */ | |
124 | public void setPartialMaskFormatter(MaskFormatter partialMaskFormatter) { | |
125 | 0 | this.partialMaskFormatter = partialMaskFormatter; |
126 | 0 | } |
127 | ||
128 | /** | |
129 | * This overridden method ... | |
130 | * | |
131 | * @see org.kuali.rice.kns.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, | |
132 | * java.lang.Class) | |
133 | */ | |
134 | public void completeValidation(Class rootBusinessObjectClass, | |
135 | Class otherBusinessObjectClass) { | |
136 | ||
137 | 0 | if (mask && maskFormatter == null) { |
138 | 0 | throw new AttributeValidationException("MaskFormatter is required"); |
139 | } | |
140 | 0 | if (partialMask && partialMaskFormatter == null) { |
141 | 0 | throw new AttributeValidationException( |
142 | "PartialMaskFormatter is required"); | |
143 | } | |
144 | 0 | } |
145 | ||
146 | /** | |
147 | * Returns whether any of the restrictions defined in this class are true. | |
148 | */ | |
149 | public boolean hasAnyRestriction() { | |
150 | 0 | return readOnly || mask || partialMask || hide; |
151 | } | |
152 | ||
153 | ||
154 | /** | |
155 | * Returns whether any of the restrictions defined in this class indicate that the attribute value potentially needs | |
156 | * to be not shown to the user (i.e. masked, partial mask, hide). Note that readonly does not fall in this category. | |
157 | * | |
158 | * @return | |
159 | */ | |
160 | public boolean hasRestrictionThatRemovesValueFromUI() { | |
161 | 0 | return mask || partialMask || hide; |
162 | } | |
163 | } |