1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.api.identity.external; |
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.w3c.dom.Element; |
32 | |
|
33 | 0 | @XmlRootElement(name = EntityExternalIdentifier.Constants.ROOT_ELEMENT_NAME) |
34 | |
@XmlAccessorType(XmlAccessType.NONE) |
35 | |
@XmlType(name = EntityExternalIdentifier.Constants.TYPE_NAME, propOrder = { |
36 | |
EntityExternalIdentifier.Elements.ID, |
37 | |
EntityExternalIdentifier.Elements.ENTITY_ID, |
38 | |
EntityExternalIdentifier.Elements.EXTERNAL_IDENTIFIER_TYPE_CODE, |
39 | |
EntityExternalIdentifier.Elements.EXTERNAL_IDENTIFIER_TYPE, |
40 | |
EntityExternalIdentifier.Elements.EXTERNAL_ID, |
41 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
42 | |
CoreConstants.CommonElements.OBJECT_ID, |
43 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
44 | |
}) |
45 | 0 | public final class EntityExternalIdentifier extends AbstractDataTransferObject |
46 | |
implements EntityExternalIdentifierContract |
47 | |
{ |
48 | |
@XmlElement(name = Elements.ENTITY_ID, required = false) |
49 | |
private final String entityId; |
50 | |
@XmlElement(name = Elements.EXTERNAL_IDENTIFIER_TYPE_CODE, required = false) |
51 | |
private final String externalIdentifierTypeCode; |
52 | |
@XmlElement(name = Elements.EXTERNAL_IDENTIFIER_TYPE, required = false) |
53 | |
private final EntityExternalIdentifierType externalIdentifierType; |
54 | |
@XmlElement(name = Elements.EXTERNAL_ID, required = false) |
55 | |
private final String externalId; |
56 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
57 | |
private final Long versionNumber; |
58 | |
@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false) |
59 | |
private final String objectId; |
60 | |
@XmlElement(name = Elements.ID, required = false) |
61 | |
private final String id; |
62 | 0 | @SuppressWarnings("unused") |
63 | |
@XmlAnyElement |
64 | |
private final Collection<Element> _futureElements = null; |
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | 0 | private EntityExternalIdentifier() { |
71 | 0 | this.entityId = null; |
72 | 0 | this.externalIdentifierTypeCode = null; |
73 | 0 | this.externalIdentifierType = null; |
74 | 0 | this.externalId = null; |
75 | 0 | this.versionNumber = null; |
76 | 0 | this.objectId = null; |
77 | 0 | this.id = null; |
78 | 0 | } |
79 | |
|
80 | 0 | private EntityExternalIdentifier(Builder builder) { |
81 | 0 | this.entityId = builder.getEntityId(); |
82 | 0 | this.externalIdentifierTypeCode = builder.getExternalIdentifierTypeCode(); |
83 | 0 | this.externalIdentifierType = builder.getExternalIdentifierType() != null ? builder.getExternalIdentifierType().build() : null; |
84 | 0 | this.externalId = builder.getExternalId(); |
85 | 0 | this.versionNumber = builder.getVersionNumber(); |
86 | 0 | this.objectId = builder.getObjectId(); |
87 | 0 | this.id = builder.getId(); |
88 | 0 | } |
89 | |
|
90 | |
@Override |
91 | |
public String getEntityId() { |
92 | 0 | return this.entityId; |
93 | |
} |
94 | |
|
95 | |
@Override |
96 | |
public String getExternalIdentifierTypeCode() { |
97 | 0 | return this.externalIdentifierTypeCode; |
98 | |
} |
99 | |
|
100 | |
@Override |
101 | |
public EntityExternalIdentifierType getExternalIdentifierType() { |
102 | 0 | return this.externalIdentifierType; |
103 | |
} |
104 | |
|
105 | |
@Override |
106 | |
public String getExternalId() { |
107 | 0 | return this.externalId; |
108 | |
} |
109 | |
|
110 | |
@Override |
111 | |
public Long getVersionNumber() { |
112 | 0 | return this.versionNumber; |
113 | |
} |
114 | |
|
115 | |
@Override |
116 | |
public String getObjectId() { |
117 | 0 | return this.objectId; |
118 | |
} |
119 | |
|
120 | |
@Override |
121 | |
public String getId() { |
122 | 0 | return this.id; |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | 0 | public final static class Builder |
130 | |
implements Serializable, ModelBuilder, EntityExternalIdentifierContract |
131 | |
{ |
132 | |
|
133 | |
private String entityId; |
134 | |
private String externalIdentifierTypeCode; |
135 | |
private EntityExternalIdentifierType.Builder externalIdentifierType; |
136 | |
private String externalId; |
137 | |
private Long versionNumber; |
138 | |
private String objectId; |
139 | |
private String id; |
140 | |
|
141 | 0 | private Builder() { } |
142 | |
|
143 | |
public static Builder create() { |
144 | 0 | return new Builder(); |
145 | |
} |
146 | |
|
147 | |
public static Builder create(EntityExternalIdentifierContract contract) { |
148 | 0 | if (contract == null) { |
149 | 0 | throw new IllegalArgumentException("contract was null"); |
150 | |
} |
151 | 0 | Builder builder = create(); |
152 | 0 | builder.setEntityId(contract.getEntityId()); |
153 | 0 | builder.setExternalIdentifierTypeCode(contract.getExternalIdentifierTypeCode()); |
154 | 0 | if (contract.getExternalIdentifierType() != null) { |
155 | 0 | builder.setExternalIdentifierType( |
156 | |
EntityExternalIdentifierType.Builder.create(contract.getExternalIdentifierType())); |
157 | |
} |
158 | 0 | builder.setExternalId(contract.getExternalId()); |
159 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
160 | 0 | builder.setObjectId(contract.getObjectId()); |
161 | 0 | builder.setId(contract.getId()); |
162 | 0 | return builder; |
163 | |
} |
164 | |
|
165 | |
public EntityExternalIdentifier build() { |
166 | 0 | return new EntityExternalIdentifier(this); |
167 | |
} |
168 | |
|
169 | |
@Override |
170 | |
public String getEntityId() { |
171 | 0 | return this.entityId; |
172 | |
} |
173 | |
|
174 | |
@Override |
175 | |
public String getExternalIdentifierTypeCode() { |
176 | 0 | return this.externalIdentifierTypeCode; |
177 | |
} |
178 | |
|
179 | |
@Override |
180 | |
public EntityExternalIdentifierType.Builder getExternalIdentifierType() { |
181 | 0 | return this.externalIdentifierType; |
182 | |
} |
183 | |
|
184 | |
@Override |
185 | |
public String getExternalId() { |
186 | 0 | return this.externalId; |
187 | |
} |
188 | |
|
189 | |
@Override |
190 | |
public Long getVersionNumber() { |
191 | 0 | return this.versionNumber; |
192 | |
} |
193 | |
|
194 | |
@Override |
195 | |
public String getObjectId() { |
196 | 0 | return this.objectId; |
197 | |
} |
198 | |
|
199 | |
@Override |
200 | |
public String getId() { |
201 | 0 | return this.id; |
202 | |
} |
203 | |
|
204 | |
public void setEntityId(String entityId) { |
205 | 0 | this.entityId = entityId; |
206 | 0 | } |
207 | |
|
208 | |
public void setExternalIdentifierTypeCode(String externalIdentifierTypeCode) { |
209 | 0 | this.externalIdentifierTypeCode = externalIdentifierTypeCode; |
210 | 0 | } |
211 | |
|
212 | |
public void setExternalIdentifierType(EntityExternalIdentifierType.Builder externalIdentifierType) { |
213 | 0 | this.externalIdentifierType = externalIdentifierType; |
214 | 0 | } |
215 | |
|
216 | |
public void setExternalId(String externalId) { |
217 | 0 | this.externalId = externalId; |
218 | 0 | } |
219 | |
|
220 | |
public void setVersionNumber(Long versionNumber) { |
221 | 0 | this.versionNumber = versionNumber; |
222 | 0 | } |
223 | |
|
224 | |
public void setObjectId(String objectId) { |
225 | 0 | this.objectId = objectId; |
226 | 0 | } |
227 | |
|
228 | |
public void setId(String id) { |
229 | 0 | if (StringUtils.isWhitespace(id)) { |
230 | 0 | throw new IllegalArgumentException("id is blank"); |
231 | |
} |
232 | 0 | this.id = id; |
233 | 0 | } |
234 | |
|
235 | |
} |
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
|
242 | 0 | static class Constants { |
243 | |
|
244 | |
final static String ROOT_ELEMENT_NAME = "entityExternalIdentifier"; |
245 | |
final static String TYPE_NAME = "EntityExternalIdentifierType"; |
246 | |
} |
247 | |
|
248 | |
|
249 | |
|
250 | |
|
251 | |
|
252 | |
|
253 | 0 | static class Elements { |
254 | |
|
255 | |
final static String ENTITY_ID = "entityId"; |
256 | |
final static String EXTERNAL_IDENTIFIER_TYPE = "externalIdentifierType"; |
257 | |
final static String EXTERNAL_IDENTIFIER_TYPE_CODE = "externalIdentifierTypeCode"; |
258 | |
final static String EXTERNAL_ID = "externalId"; |
259 | |
final static String ID = "id"; |
260 | |
|
261 | |
} |
262 | |
|
263 | |
} |