1 package org.kuali.ole.deliver.bo;
2
3 import org.apache.commons.collections.CollectionUtils;
4 import org.kuali.ole.deliver.api.OlePatronAffiliationContract;
5 import org.kuali.ole.deliver.api.OlePatronAffiliationDefinition;
6 import org.kuali.rice.kim.api.identity.employment.EntityEmployment;
7 import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationBo;
8 import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationTypeBo;
9 import org.kuali.rice.kim.impl.identity.employment.EntityEmploymentBo;
10 import org.kuali.rice.krad.bo.BusinessObjectBase;
11
12 import java.util.ArrayList;
13 import java.util.List;
14
15
16
17
18 public class OlePatronAffiliation extends BusinessObjectBase implements OlePatronAffiliationContract {
19
20 private String entityAffiliationId;
21
22 private String entityId;
23
24 private String affiliationTypeCode;
25
26 private String campusCode;
27
28 private boolean defaultValue;
29
30 private boolean active;
31
32 private EntityAffiliationTypeBo affiliationType = new EntityAffiliationTypeBo();
33
34 private List<EntityEmploymentBo> employments = new ArrayList<EntityEmploymentBo>();
35
36 private Long versionNumber;
37
38 private String objectId;
39
40 public OlePatronAffiliation() {
41
42 }
43
44
45
46
47
48
49 public OlePatronAffiliation(EntityAffiliationBo entityAffiliationBo) {
50 this.setEntityAffiliationId(entityAffiliationBo.getId());
51 this.setAffiliationTypeCode(entityAffiliationBo.getAffiliationTypeCode());
52 this.setAffiliationType(entityAffiliationBo.getAffiliationType());
53 this.setCampusCode(entityAffiliationBo.getCampusCode());
54 this.setDefaultValue(entityAffiliationBo.getDefaultValue());
55 this.setActive(entityAffiliationBo.getActive());
56 this.setVersionNumber(entityAffiliationBo.getVersionNumber());
57 this.setObjectId(entityAffiliationBo.getObjectId());
58 }
59
60
61
62
63
64
65 public String getEntityAffiliationId() {
66 return entityAffiliationId;
67 }
68
69
70
71
72
73
74 public void setEntityAffiliationId(String entityAffiliationId) {
75 this.entityAffiliationId = entityAffiliationId;
76 }
77
78
79
80
81
82
83 public String getAffiliationTypeCode() {
84 return affiliationTypeCode;
85 }
86
87
88
89
90
91
92 public void setAffiliationTypeCode(String affiliationTypeCode) {
93 this.affiliationTypeCode = affiliationTypeCode;
94 }
95
96
97
98
99
100
101 public String getCampusCode() {
102 return campusCode;
103 }
104
105
106
107
108
109
110 public void setCampusCode(String campusCode) {
111 this.campusCode = campusCode;
112 }
113
114
115
116
117
118
119 public boolean isDefaultValue() {
120 return defaultValue;
121 }
122
123
124
125
126
127
128 public void setDefaultValue(boolean defaultValue) {
129 this.defaultValue = defaultValue;
130 }
131
132
133
134
135
136
137 public boolean isActive() {
138 return active;
139 }
140
141
142
143
144
145
146 public void setActive(boolean active) {
147 this.active = active;
148 }
149
150
151
152
153
154
155 public EntityAffiliationTypeBo getAffiliationType() {
156 return affiliationType;
157 }
158
159
160
161
162
163
164 public void setAffiliationType(EntityAffiliationTypeBo affiliationType) {
165 this.affiliationType = affiliationType;
166 }
167
168
169
170
171
172
173 public List<EntityEmploymentBo> getEmployments() {
174 return employments;
175 }
176
177
178
179
180
181
182 public void setEmployments(List<EntityEmploymentBo> employments) {
183 this.employments = employments;
184 }
185
186
187
188
189
190
191 public EntityAffiliationBo getEntityAffliationBo() {
192 EntityAffiliationBo entityAffiliationBo = new EntityAffiliationBo();
193 entityAffiliationBo.setId(this.getEntityAffiliationId());
194 entityAffiliationBo.setAffiliationTypeCode(this.getAffiliationTypeCode());
195 entityAffiliationBo.setAffiliationType(this.getAffiliationType());
196 entityAffiliationBo.setActive(this.isActive());
197 entityAffiliationBo.setDefaultValue(this.defaultValue);
198 entityAffiliationBo.setCampusCode(this.getCampusCode());
199 entityAffiliationBo.setObjectId(this.getObjectId());
200 entityAffiliationBo.setVersionNumber(this.getVersionNumber());
201 entityAffiliationBo.setEntityId(this.getEntityId());
202 return entityAffiliationBo;
203 }
204
205
206
207
208
209
210
211 static OlePatronAffiliationDefinition to(OlePatronAffiliation bo) {
212 if (bo == null) {
213 return null;
214 }
215 return OlePatronAffiliationDefinition.Builder.create(bo).build();
216 }
217
218
219
220
221
222
223
224
225 static OlePatronAffiliation from(OlePatronAffiliationDefinition im) {
226 if (im == null) {
227 return null;
228 }
229
230 OlePatronAffiliation bo = new OlePatronAffiliation();
231 bo.entityAffiliationId = im.getEntityAffiliationId();
232 bo.affiliationTypeCode = im.getAffiliationTypeCode();
233 if (im.getAffiliationType() != null) {
234 bo.affiliationType = EntityAffiliationTypeBo.from(im.getAffiliationType());
235 }
236 bo.defaultValue = im.isDefaultValue();
237 bo.active = im.isActive();
238 bo.versionNumber = im.getVersionNumber();
239 bo.entityId = im.getEntityId();
240 bo.objectId = im.getObjectId();
241
242 if (CollectionUtils.isNotEmpty(im.getEmployments())) {
243 for (EntityEmployment entityEmployment : im.getEmployments()) {
244 bo.employments.add(EntityEmploymentBo.from(entityEmployment));
245 }
246 }
247 return bo;
248 }
249
250 @Override
251 public void refresh() {
252
253 }
254
255
256
257
258
259
260 @Override
261 public String getId() {
262 return this.entityAffiliationId;
263 }
264
265
266
267
268
269
270 @Override
271 public Long getVersionNumber() {
272 return this.versionNumber;
273 }
274
275
276
277
278
279
280 public void setVersionNumber(Long versionNumber) {
281 this.versionNumber = versionNumber;
282 }
283
284
285
286
287
288
289 public String getObjectId() {
290 return objectId;
291 }
292
293
294
295
296
297
298 public void setObjectId(String objectId) {
299 this.objectId = objectId;
300 }
301
302
303
304
305
306
307 public String getEntityId() {
308 return entityId;
309 }
310
311
312
313
314
315
316 public void setEntityId(String entityId) {
317 this.entityId = entityId;
318 }
319 }