1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary;
17
18 import org.kuali.rice.krad.datadictionary.mask.MaskFormatter;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21 import org.kuali.rice.krad.datadictionary.uif.UifDictionaryBeanBase;
22 import org.kuali.rice.krad.datadictionary.validator.ValidationTrace;
23
24
25
26
27
28
29 @BeanTag(name = "attributeSecurity")
30 public class AttributeSecurity extends UifDictionaryBeanBase {
31 private static final long serialVersionUID = -7923499408946975318L;
32
33 private boolean readOnly = false;
34 private boolean hide = false;
35 private boolean mask = false;
36 private boolean partialMask = false;
37
38 private MaskFormatter partialMaskFormatter;
39 private MaskFormatter maskFormatter;
40
41
42
43
44 @BeanTagAttribute(name = "readOnly")
45 public boolean isReadOnly() {
46 return this.readOnly;
47 }
48
49
50
51
52 public void setReadOnly(boolean readOnly) {
53 this.readOnly = readOnly;
54 }
55
56
57
58
59 @BeanTagAttribute(name = "hide")
60 public boolean isHide() {
61 return this.hide;
62 }
63
64
65
66
67 public void setHide(boolean hide) {
68 this.hide = hide;
69 }
70
71
72
73
74 @BeanTagAttribute(name = "mask")
75 public boolean isMask() {
76 return this.mask;
77 }
78
79
80
81
82 public void setMask(boolean mask) {
83 this.mask = mask;
84 }
85
86
87
88
89 @BeanTagAttribute(name = "partialMask")
90 public boolean isPartialMask() {
91 return this.partialMask;
92 }
93
94
95
96
97 public void setPartialMask(boolean partialMask) {
98 this.partialMask = partialMask;
99 }
100
101
102
103
104 @BeanTagAttribute(name = "maskFormatter", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
105 public MaskFormatter getMaskFormatter() {
106 return this.maskFormatter;
107 }
108
109
110
111
112 public void setMaskFormatter(MaskFormatter maskFormatter) {
113 this.maskFormatter = maskFormatter;
114 }
115
116
117
118
119 @BeanTagAttribute(name = "partialMaskFormatter", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
120 public MaskFormatter getPartialMaskFormatter() {
121 return this.partialMaskFormatter;
122 }
123
124
125
126
127 public void setPartialMaskFormatter(MaskFormatter partialMaskFormatter) {
128 this.partialMaskFormatter = partialMaskFormatter;
129 }
130
131
132
133
134
135
136
137 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
138 completeValidation(rootBusinessObjectClass, otherBusinessObjectClass, new ValidationTrace());
139 }
140
141
142
143
144
145
146 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass,
147 ValidationTrace tracer) {
148 tracer.addBean(this.getClass().getSimpleName(), ValidationTrace.NO_BEAN_ID);
149
150 if (mask && maskFormatter == null) {
151 String currentValues[] = {"mask = " + mask, "maskFormatter = " + maskFormatter};
152 tracer.createError("MaskFormatter is required", currentValues);
153 }
154 if (partialMask && partialMaskFormatter == null) {
155 String currentValues[] = {"partialMask = " + partialMask, "partialMaskFormatter = " + partialMaskFormatter};
156 tracer.createError("PartialMaskFormatter is required", currentValues);
157 }
158
159 }
160
161
162
163
164 public boolean hasAnyRestriction() {
165 return readOnly || mask || partialMask || hide;
166 }
167
168
169
170
171
172
173
174
175 public boolean hasRestrictionThatRemovesValueFromUI() {
176 return mask || partialMask || hide;
177 }
178
179 @Override
180 public String toString() {
181 StringBuilder builder = new StringBuilder();
182 builder.append("DataObjectAttributeSecurityBase [readOnly=").append(readOnly).append(", hide=").append(hide)
183 .append(", mask=").append(mask).append(", partialMask=").append(partialMask).append(", ");
184 if (maskFormatter != null) {
185 builder.append("maskFormatter=").append(maskFormatter).append(", ");
186 }
187 if (partialMaskFormatter != null) {
188 builder.append("partialMaskFormatter=").append(partialMaskFormatter);
189 }
190 builder.append("]");
191 return builder.toString();
192 }
193 }