1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.ole.sys.businessobject;
18
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.ole.sys.context.SpringContext;
24 import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
25 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
26 import org.kuali.rice.krad.service.KualiModuleService;
27 import org.kuali.rice.krad.service.ModuleService;
28 import org.kuali.rice.location.api.LocationConstants;
29 import org.kuali.rice.location.framework.campus.CampusEbo;
30 import org.kuali.rice.location.framework.country.CountryEbo;
31 import org.kuali.rice.location.framework.postalcode.PostalCodeEbo;
32 import org.kuali.rice.location.framework.state.StateEbo;
33
34
35
36
37 public class Building extends PersistableBusinessObjectBase implements MutableInactivatable {
38
39 protected String campusCode;
40 protected String buildingCode;
41 protected String buildingName;
42 protected String buildingStreetAddress;
43 protected String buildingAddressCityName;
44 protected String buildingAddressStateCode;
45 protected String buildingAddressZipCode;
46 protected String alternateBuildingCode;
47 protected boolean active;
48 protected String buildingAddressCountryCode;
49
50 protected CampusEbo campus;
51 protected StateEbo buildingAddressState;
52 protected PostalCodeEbo buildingAddressZip;
53 protected CountryEbo buildingAddressCountry;
54
55
56
57
58
59
60 public String getCampusCode() {
61 return campusCode;
62 }
63
64
65
66
67
68
69 public void setCampusCode(String campusCode) {
70 this.campusCode = campusCode;
71 }
72
73
74
75
76
77
78
79 public String getBuildingCode() {
80 return buildingCode;
81 }
82
83
84
85
86
87
88 public void setBuildingCode(String buildingCode) {
89 this.buildingCode = buildingCode;
90 }
91
92
93
94
95
96
97
98 public String getBuildingName() {
99 return buildingName;
100 }
101
102
103
104
105
106
107 public void setBuildingName(String buildingName) {
108 this.buildingName = buildingName;
109 }
110
111
112
113
114
115
116 public CampusEbo getCampus() {
117 if ( StringUtils.isBlank(campusCode) ) {
118 campus = null;
119 } else {
120 if ( campus == null || !StringUtils.equals( campus.getCode(),campusCode) ) {
121 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CampusEbo.class);
122 if ( moduleService != null ) {
123 Map<String,Object> keys = new HashMap<String, Object>(1);
124 keys.put(LocationConstants.PrimaryKeyConstants.CODE, campusCode);
125 campus = moduleService.getExternalizableBusinessObject(CampusEbo.class, keys);
126 } else {
127 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
128 }
129 }
130 }
131 return campus;
132 }
133
134
135
136
137
138
139 public void setCampus(CampusEbo campus) {
140 this.campus = campus;
141 }
142
143
144
145
146
147
148 public String getAlternateBuildingCode() {
149 return alternateBuildingCode;
150 }
151
152
153
154
155
156
157 public void setAlternateBuildingCode(String alternateBuildingCode) {
158 this.alternateBuildingCode = alternateBuildingCode;
159 }
160
161
162
163
164
165
166 public String getBuildingAddressCityName() {
167 return buildingAddressCityName;
168 }
169
170
171
172
173
174
175 public void setBuildingAddressCityName(String buildingAddressCityName) {
176 this.buildingAddressCityName = buildingAddressCityName;
177 }
178
179
180
181
182
183
184 public String getBuildingAddressStateCode() {
185 return buildingAddressStateCode;
186 }
187
188
189
190
191
192
193 public void setBuildingAddressStateCode(String buildingAddressStateCode) {
194 this.buildingAddressStateCode = buildingAddressStateCode;
195 }
196
197
198
199
200
201
202 public String getBuildingAddressZipCode() {
203 return buildingAddressZipCode;
204 }
205
206
207
208
209
210
211 public void setBuildingAddressZipCode(String buildingAddressZipCode) {
212 this.buildingAddressZipCode = buildingAddressZipCode;
213 }
214
215
216
217
218
219
220 public String getBuildingStreetAddress() {
221 return buildingStreetAddress;
222 }
223
224
225
226
227
228
229 public void setBuildingStreetAddress(String buildingStreetAddress) {
230 this.buildingStreetAddress = buildingStreetAddress;
231 }
232
233
234
235
236
237 @Override
238 public boolean isActive() {
239 return active;
240 }
241
242
243
244
245
246 @Override
247 public void setActive(boolean active) {
248 this.active = active;
249 }
250
251
252
253
254
255
256 public StateEbo getBuildingAddressState() {
257 if ( StringUtils.isBlank(buildingAddressStateCode) || StringUtils.isBlank(buildingAddressCountryCode ) ) {
258 buildingAddressState = null;
259 } else {
260 if ( buildingAddressState == null || !StringUtils.equals( buildingAddressState.getCode(),buildingAddressStateCode) || !StringUtils.equals(buildingAddressState.getCountryCode(), buildingAddressCountryCode ) ) {
261 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(StateEbo.class);
262 if ( moduleService != null ) {
263 Map<String,Object> keys = new HashMap<String, Object>(2);
264 keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, buildingAddressCountryCode);
265 keys.put(LocationConstants.PrimaryKeyConstants.CODE, buildingAddressStateCode);
266 buildingAddressState = moduleService.getExternalizableBusinessObject(StateEbo.class, keys);
267 } else {
268 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
269 }
270 }
271 }
272 return buildingAddressState;
273 }
274
275
276
277
278
279
280
281 public void setBuildingAddressState(StateEbo buildingAddressState) {
282 this.buildingAddressState = buildingAddressState;
283 }
284
285
286
287
288
289
290 public PostalCodeEbo getBuildingAddressZip() {
291 if ( StringUtils.isBlank(buildingAddressZipCode) || StringUtils.isBlank(buildingAddressCountryCode) ) {
292 buildingAddressZip = null;
293 } else {
294 if ( buildingAddressZip == null || !StringUtils.equals( buildingAddressZip.getCode(),buildingAddressZipCode) || !StringUtils.equals(buildingAddressZip.getCountryCode(), buildingAddressCountryCode ) ) {
295 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(PostalCodeEbo.class);
296 if ( moduleService != null ) {
297 Map<String,Object> keys = new HashMap<String, Object>(2);
298 keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, buildingAddressCountryCode);
299 keys.put(LocationConstants.PrimaryKeyConstants.CODE, buildingAddressZipCode);
300 buildingAddressZip = moduleService.getExternalizableBusinessObject(PostalCodeEbo.class, keys);
301 } else {
302 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
303 }
304 }
305 }
306 return buildingAddressZip;
307 }
308
309
310
311
312
313
314
315 public void setBuildingAddressZip(PostalCodeEbo buildingAddressZip) {
316 this.buildingAddressZip = buildingAddressZip;
317 }
318
319
320
321
322
323 public String getBuildingAddressCountryCode() {
324 return buildingAddressCountryCode;
325 }
326
327
328
329
330
331 public void setBuildingAddressCountryCode(String buildingAddressCountryCode) {
332 this.buildingAddressCountryCode = buildingAddressCountryCode;
333 }
334
335
336
337
338
339 public CountryEbo getBuildingAddressCountry() {
340 if ( StringUtils.isBlank(buildingAddressCountryCode) ) {
341 buildingAddressCountry = null;
342 } else {
343 if ( buildingAddressCountry == null || !StringUtils.equals( buildingAddressCountry.getCode(),buildingAddressCountryCode) ) {
344 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CountryEbo.class);
345 if ( moduleService != null ) {
346 Map<String,Object> keys = new HashMap<String, Object>(1);
347 keys.put(LocationConstants.PrimaryKeyConstants.CODE, buildingAddressCountryCode);
348 buildingAddressCountry = moduleService.getExternalizableBusinessObject(CountryEbo.class, keys);
349 } else {
350 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
351 }
352 }
353 }
354 return buildingAddressCountry;
355 }
356
357
358
359
360
361 public void setBuildingAddressCountry(CountryEbo buildingAddressCountry) {
362 this.buildingAddressCountry = buildingAddressCountry;
363 }
364
365 }