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