1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.api.identity.privacy; |
17 | |
|
18 | |
import java.io.Serializable; |
19 | |
import java.util.Collection; |
20 | |
import javax.xml.bind.annotation.XmlAccessType; |
21 | |
import javax.xml.bind.annotation.XmlAccessorType; |
22 | |
import javax.xml.bind.annotation.XmlAnyElement; |
23 | |
import javax.xml.bind.annotation.XmlElement; |
24 | |
import javax.xml.bind.annotation.XmlRootElement; |
25 | |
import javax.xml.bind.annotation.XmlType; |
26 | |
|
27 | |
import org.apache.commons.lang.StringUtils; |
28 | |
import org.kuali.rice.core.api.CoreConstants; |
29 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
30 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
31 | |
import org.kuali.rice.kim.api.KimConstants; |
32 | |
import org.w3c.dom.Element; |
33 | |
|
34 | |
@XmlRootElement(name = EntityPrivacyPreferences.Constants.ROOT_ELEMENT_NAME) |
35 | |
@XmlAccessorType(XmlAccessType.NONE) |
36 | |
@XmlType(name = EntityPrivacyPreferences.Constants.TYPE_NAME, propOrder = { |
37 | |
EntityPrivacyPreferences.Elements.ENTITY_ID, |
38 | |
EntityPrivacyPreferences.Elements.SUPPRESS_NAME, |
39 | |
EntityPrivacyPreferences.Elements.SUPPRESS_ADDRESS, |
40 | |
EntityPrivacyPreferences.Elements.SUPPRESS_EMAIL, |
41 | |
EntityPrivacyPreferences.Elements.SUPPRESS_PHONE, |
42 | |
EntityPrivacyPreferences.Elements.SUPPRESS_PERSONAL, |
43 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
44 | |
CoreConstants.CommonElements.OBJECT_ID, |
45 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
46 | |
}) |
47 | 0 | public final class EntityPrivacyPreferences extends AbstractDataTransferObject |
48 | |
implements EntityPrivacyPreferencesContract |
49 | |
{ |
50 | |
|
51 | |
@XmlElement(name = Elements.ENTITY_ID, required = false) |
52 | |
private final String entityId; |
53 | |
@XmlElement(name = Elements.SUPPRESS_NAME, required = false) |
54 | |
private final boolean suppressName; |
55 | |
@XmlElement(name = Elements.SUPPRESS_ADDRESS, required = false) |
56 | |
private final boolean suppressAddress; |
57 | |
@XmlElement(name = Elements.SUPPRESS_EMAIL, required = false) |
58 | |
private final boolean suppressEmail; |
59 | |
@XmlElement(name = Elements.SUPPRESS_PHONE, required = false) |
60 | |
private final boolean suppressPhone; |
61 | |
@XmlElement(name = Elements.SUPPRESS_PERSONAL, required = false) |
62 | |
private final boolean suppressPersonal; |
63 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
64 | |
private final Long versionNumber; |
65 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
66 | |
private final String objectId; |
67 | 0 | @SuppressWarnings("unused") |
68 | |
@XmlAnyElement |
69 | |
private final Collection<Element> _futureElements = null; |
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | 0 | private EntityPrivacyPreferences() { |
75 | 0 | this.entityId = null; |
76 | 0 | this.suppressName = false; |
77 | 0 | this.suppressAddress = false; |
78 | 0 | this.suppressEmail = false; |
79 | 0 | this.suppressPhone = false; |
80 | 0 | this.suppressPersonal = false; |
81 | 0 | this.versionNumber = null; |
82 | 0 | this.objectId = null; |
83 | 0 | } |
84 | |
|
85 | 0 | private EntityPrivacyPreferences(Builder builder) { |
86 | 0 | this.entityId = builder.getEntityId(); |
87 | 0 | this.suppressName = builder.isSuppressName(); |
88 | 0 | this.suppressAddress = builder.isSuppressAddress(); |
89 | 0 | this.suppressEmail = builder.isSuppressEmail(); |
90 | 0 | this.suppressPhone = builder.isSuppressPhone(); |
91 | 0 | this.suppressPersonal = builder.isSuppressPersonal(); |
92 | 0 | this.versionNumber = builder.getVersionNumber(); |
93 | 0 | this.objectId = builder.getObjectId(); |
94 | 0 | } |
95 | |
|
96 | |
@Override |
97 | |
public String getEntityId() { |
98 | 0 | return this.entityId; |
99 | |
} |
100 | |
|
101 | |
@Override |
102 | |
public boolean isSuppressName() { |
103 | 0 | return this.suppressName; |
104 | |
} |
105 | |
|
106 | |
@Override |
107 | |
public boolean isSuppressAddress() { |
108 | 0 | return this.suppressAddress; |
109 | |
} |
110 | |
|
111 | |
@Override |
112 | |
public boolean isSuppressEmail() { |
113 | 0 | return this.suppressEmail; |
114 | |
} |
115 | |
|
116 | |
@Override |
117 | |
public boolean isSuppressPhone() { |
118 | 0 | return this.suppressPhone; |
119 | |
} |
120 | |
|
121 | |
@Override |
122 | |
public boolean isSuppressPersonal() { |
123 | 0 | return this.suppressPersonal; |
124 | |
} |
125 | |
|
126 | |
@Override |
127 | |
public Long getVersionNumber() { |
128 | 0 | return this.versionNumber; |
129 | |
} |
130 | |
|
131 | |
@Override |
132 | |
public String getObjectId() { |
133 | 0 | return this.objectId; |
134 | |
} |
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | 0 | public final static class Builder |
142 | |
implements Serializable, ModelBuilder, EntityPrivacyPreferencesContract |
143 | |
{ |
144 | |
|
145 | |
private String entityId; |
146 | |
private boolean suppressName; |
147 | |
private boolean suppressAddress; |
148 | |
private boolean suppressEmail; |
149 | |
private boolean suppressPhone; |
150 | |
private boolean suppressPersonal; |
151 | |
private Long versionNumber; |
152 | |
private String objectId; |
153 | |
|
154 | 0 | private Builder(String entityId) { |
155 | 0 | setEntityId(entityId); |
156 | 0 | } |
157 | |
|
158 | |
public static Builder create(String entityId) { |
159 | 0 | return new Builder(entityId); |
160 | |
} |
161 | |
|
162 | |
public static Builder create(EntityPrivacyPreferencesContract contract) { |
163 | 0 | if (contract == null) { |
164 | 0 | throw new IllegalArgumentException("contract was null"); |
165 | |
} |
166 | 0 | Builder builder = create(contract.getEntityId()); |
167 | 0 | builder.setSuppressName(contract.isSuppressName()); |
168 | 0 | builder.setSuppressAddress(contract.isSuppressAddress()); |
169 | 0 | builder.setSuppressEmail(contract.isSuppressEmail()); |
170 | 0 | builder.setSuppressPhone(contract.isSuppressPhone()); |
171 | 0 | builder.setSuppressPersonal(contract.isSuppressPersonal()); |
172 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
173 | 0 | builder.setObjectId(contract.getObjectId()); |
174 | 0 | return builder; |
175 | |
} |
176 | |
|
177 | |
public EntityPrivacyPreferences build() { |
178 | 0 | return new EntityPrivacyPreferences(this); |
179 | |
} |
180 | |
|
181 | |
@Override |
182 | |
public String getEntityId() { |
183 | 0 | return this.entityId; |
184 | |
} |
185 | |
|
186 | |
@Override |
187 | |
public boolean isSuppressName() { |
188 | 0 | return this.suppressName; |
189 | |
} |
190 | |
|
191 | |
@Override |
192 | |
public boolean isSuppressAddress() { |
193 | 0 | return this.suppressAddress; |
194 | |
} |
195 | |
|
196 | |
@Override |
197 | |
public boolean isSuppressEmail() { |
198 | 0 | return this.suppressEmail; |
199 | |
} |
200 | |
|
201 | |
@Override |
202 | |
public boolean isSuppressPhone() { |
203 | 0 | return this.suppressPhone; |
204 | |
} |
205 | |
|
206 | |
@Override |
207 | |
public boolean isSuppressPersonal() { |
208 | 0 | return this.suppressPersonal; |
209 | |
} |
210 | |
|
211 | |
@Override |
212 | |
public Long getVersionNumber() { |
213 | 0 | return this.versionNumber; |
214 | |
} |
215 | |
|
216 | |
@Override |
217 | |
public String getObjectId() { |
218 | 0 | return this.objectId; |
219 | |
} |
220 | |
|
221 | |
public void setEntityId(String entityId) { |
222 | 0 | if (StringUtils.isEmpty(entityId)) { |
223 | 0 | throw new IllegalArgumentException("entityId is empty"); |
224 | |
} |
225 | 0 | this.entityId = entityId; |
226 | 0 | } |
227 | |
|
228 | |
public void setSuppressName(boolean suppressName) { |
229 | |
|
230 | 0 | this.suppressName = suppressName; |
231 | 0 | } |
232 | |
|
233 | |
public void setSuppressAddress(boolean suppressAddress) { |
234 | |
|
235 | 0 | this.suppressAddress = suppressAddress; |
236 | 0 | } |
237 | |
|
238 | |
public void setSuppressEmail(boolean suppressEmail) { |
239 | |
|
240 | 0 | this.suppressEmail = suppressEmail; |
241 | 0 | } |
242 | |
|
243 | |
public void setSuppressPhone(boolean suppressPhone) { |
244 | |
|
245 | 0 | this.suppressPhone = suppressPhone; |
246 | 0 | } |
247 | |
|
248 | |
public void setSuppressPersonal(boolean suppressPersonal) { |
249 | |
|
250 | 0 | this.suppressPersonal = suppressPersonal; |
251 | 0 | } |
252 | |
|
253 | |
public void setVersionNumber(Long versionNumber) { |
254 | |
|
255 | 0 | this.versionNumber = versionNumber; |
256 | 0 | } |
257 | |
|
258 | |
public void setObjectId(String objectId) { |
259 | |
|
260 | 0 | this.objectId = objectId; |
261 | 0 | } |
262 | |
|
263 | |
} |
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | 0 | static class Constants { |
271 | |
|
272 | |
final static String ROOT_ELEMENT_NAME = "entityPrivacyPreferences"; |
273 | |
final static String TYPE_NAME = "EntityPrivacyPreferencesType"; |
274 | |
|
275 | |
} |
276 | |
|
277 | |
|
278 | |
|
279 | |
|
280 | |
|
281 | |
|
282 | 0 | static class Elements { |
283 | |
|
284 | |
final static String ENTITY_ID = "entityId"; |
285 | |
final static String SUPPRESS_NAME = "suppressName"; |
286 | |
final static String SUPPRESS_ADDRESS = "suppressAddress"; |
287 | |
final static String SUPPRESS_EMAIL = "suppressEmail"; |
288 | |
final static String SUPPRESS_PHONE = "suppressPhone"; |
289 | |
final static String SUPPRESS_PERSONAL = "suppressPersonal"; |
290 | |
|
291 | |
} |
292 | |
|
293 | 0 | public static class Cache { |
294 | |
public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + EntityPrivacyPreferences.Constants.TYPE_NAME; |
295 | |
} |
296 | |
|
297 | |
} |