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