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 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 @SuppressWarnings("unused")
68 @XmlAnyElement
69 private final Collection<Element> _futureElements = null;
70
71
72
73
74 private EntityPrivacyPreferences() {
75 this.entityId = null;
76 this.suppressName = false;
77 this.suppressAddress = false;
78 this.suppressEmail = false;
79 this.suppressPhone = false;
80 this.suppressPersonal = false;
81 this.versionNumber = null;
82 this.objectId = null;
83 }
84
85 private EntityPrivacyPreferences(Builder builder) {
86 this.entityId = builder.getEntityId();
87 this.suppressName = builder.isSuppressName();
88 this.suppressAddress = builder.isSuppressAddress();
89 this.suppressEmail = builder.isSuppressEmail();
90 this.suppressPhone = builder.isSuppressPhone();
91 this.suppressPersonal = builder.isSuppressPersonal();
92 this.versionNumber = builder.getVersionNumber();
93 this.objectId = builder.getObjectId();
94 }
95
96 @Override
97 public String getEntityId() {
98 return this.entityId;
99 }
100
101 @Override
102 public boolean isSuppressName() {
103 return this.suppressName;
104 }
105
106 @Override
107 public boolean isSuppressAddress() {
108 return this.suppressAddress;
109 }
110
111 @Override
112 public boolean isSuppressEmail() {
113 return this.suppressEmail;
114 }
115
116 @Override
117 public boolean isSuppressPhone() {
118 return this.suppressPhone;
119 }
120
121 @Override
122 public boolean isSuppressPersonal() {
123 return this.suppressPersonal;
124 }
125
126 @Override
127 public Long getVersionNumber() {
128 return this.versionNumber;
129 }
130
131 @Override
132 public String getObjectId() {
133 return this.objectId;
134 }
135
136
137
138
139
140
141 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 private Builder(String entityId) {
155 setEntityId(entityId);
156 }
157
158 public static Builder create(String entityId) {
159 return new Builder(entityId);
160 }
161
162 public static Builder create(EntityPrivacyPreferencesContract contract) {
163 if (contract == null) {
164 throw new IllegalArgumentException("contract was null");
165 }
166 Builder builder = create(contract.getEntityId());
167 builder.setSuppressName(contract.isSuppressName());
168 builder.setSuppressAddress(contract.isSuppressAddress());
169 builder.setSuppressEmail(contract.isSuppressEmail());
170 builder.setSuppressPhone(contract.isSuppressPhone());
171 builder.setSuppressPersonal(contract.isSuppressPersonal());
172 builder.setVersionNumber(contract.getVersionNumber());
173 builder.setObjectId(contract.getObjectId());
174 return builder;
175 }
176
177 public EntityPrivacyPreferences build() {
178 return new EntityPrivacyPreferences(this);
179 }
180
181 @Override
182 public String getEntityId() {
183 return this.entityId;
184 }
185
186 @Override
187 public boolean isSuppressName() {
188 return this.suppressName;
189 }
190
191 @Override
192 public boolean isSuppressAddress() {
193 return this.suppressAddress;
194 }
195
196 @Override
197 public boolean isSuppressEmail() {
198 return this.suppressEmail;
199 }
200
201 @Override
202 public boolean isSuppressPhone() {
203 return this.suppressPhone;
204 }
205
206 @Override
207 public boolean isSuppressPersonal() {
208 return this.suppressPersonal;
209 }
210
211 @Override
212 public Long getVersionNumber() {
213 return this.versionNumber;
214 }
215
216 @Override
217 public String getObjectId() {
218 return this.objectId;
219 }
220
221 public void setEntityId(String entityId) {
222 if (StringUtils.isEmpty(entityId)) {
223 throw new IllegalArgumentException("entityId is empty");
224 }
225 this.entityId = entityId;
226 }
227
228 public void setSuppressName(boolean suppressName) {
229
230 this.suppressName = suppressName;
231 }
232
233 public void setSuppressAddress(boolean suppressAddress) {
234
235 this.suppressAddress = suppressAddress;
236 }
237
238 public void setSuppressEmail(boolean suppressEmail) {
239
240 this.suppressEmail = suppressEmail;
241 }
242
243 public void setSuppressPhone(boolean suppressPhone) {
244
245 this.suppressPhone = suppressPhone;
246 }
247
248 public void setSuppressPersonal(boolean suppressPersonal) {
249
250 this.suppressPersonal = suppressPersonal;
251 }
252
253 public void setVersionNumber(Long versionNumber) {
254
255 this.versionNumber = versionNumber;
256 }
257
258 public void setObjectId(String objectId) {
259
260 this.objectId = objectId;
261 }
262
263 }
264
265
266
267
268
269
270 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 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 public static class Cache {
294 public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + EntityPrivacyPreferences.Constants.TYPE_NAME;
295 }
296
297 }