1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.ole.module.cg.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.OLEConstants;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
26 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
27 import org.kuali.rice.krad.service.KualiModuleService;
28 import org.kuali.rice.krad.service.ModuleService;
29 import org.kuali.rice.location.api.LocationConstants;
30 import org.kuali.rice.location.framework.country.CountryEbo;
31 import org.kuali.rice.location.framework.state.StateEbo;
32
33
34
35
36 public class SubContractor extends PersistableBusinessObjectBase implements MutableInactivatable {
37
38 protected String subcontractorNumber;
39 protected String subcontractorName;
40 protected String subcontractorAddressLine1;
41 protected String subcontractorAddressLine2;
42 protected String subcontractorCity;
43 protected String subcontractorStateCode;
44 protected String subcontractorZipCode;
45 protected String subcontractorCountryCode;
46 protected boolean active;
47
48 protected StateEbo subcontractorState;
49 protected CountryEbo subcontractorCountry;
50
51 public static final String CACHE_NAME = OLEConstants.APPLICATION_NAMESPACE_CODE + "/" + "SubContractor";
52
53
54
55 public SubContractor() {
56 }
57
58
59
60
61
62
63 public String getSubcontractorNumber() {
64 return subcontractorNumber;
65 }
66
67
68
69
70
71
72 public void setSubcontractorNumber(String subcontractorNumber) {
73 this.subcontractorNumber = subcontractorNumber;
74 }
75
76
77
78
79
80
81 public String getSubcontractorName() {
82 return subcontractorName;
83 }
84
85
86
87
88
89
90 public void setSubcontractorName(String subcontractorName) {
91 this.subcontractorName = subcontractorName;
92 }
93
94
95
96
97
98
99 public String getSubcontractorAddressLine1() {
100 return subcontractorAddressLine1;
101 }
102
103
104
105
106
107
108 public void setSubcontractorAddressLine1(String subcontractorAddressLine1) {
109 this.subcontractorAddressLine1 = subcontractorAddressLine1;
110 }
111
112
113
114
115
116
117 public String getSubcontractorAddressLine2() {
118 return subcontractorAddressLine2;
119 }
120
121
122
123
124
125
126 public void setSubcontractorAddressLine2(String subcontractorAddressLine2) {
127 this.subcontractorAddressLine2 = subcontractorAddressLine2;
128 }
129
130
131
132
133
134
135 public String getSubcontractorCity() {
136 return subcontractorCity;
137 }
138
139
140
141
142
143
144 public void setSubcontractorCity(String subcontractorCity) {
145 this.subcontractorCity = subcontractorCity;
146 }
147
148
149
150
151
152
153 public String getSubcontractorStateCode() {
154 return subcontractorStateCode;
155 }
156
157
158
159
160
161
162 public void setSubcontractorStateCode(String subcontractorStateCode) {
163 this.subcontractorStateCode = subcontractorStateCode;
164 }
165
166
167
168
169
170
171 public String getSubcontractorZipCode() {
172 return subcontractorZipCode;
173 }
174
175
176
177
178
179
180 public void setSubcontractorZipCode(String subcontractorZipCode) {
181 this.subcontractorZipCode = subcontractorZipCode;
182 }
183
184
185
186
187
188
189 public String getSubcontractorCountryCode() {
190 return subcontractorCountryCode;
191 }
192
193
194
195
196
197
198 public void setSubcontractorCountryCode(String subcontractorCountryCode) {
199 this.subcontractorCountryCode = subcontractorCountryCode;
200 }
201
202
203
204
205
206
207 @Override
208 public boolean isActive() {
209 return active;
210 }
211
212
213
214
215
216
217 @Override
218 public void setActive(boolean active) {
219 this.active = active;
220 }
221
222
223
224
225
226
227 public CountryEbo getSubcontractorCountry() {
228 if ( StringUtils.isBlank(subcontractorCountryCode) ) {
229 subcontractorCountry = null;
230 } else {
231 if ( subcontractorCountry == null || !StringUtils.equals( subcontractorCountry.getCode(), subcontractorCountryCode) ) {
232 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CountryEbo.class);
233 if ( moduleService != null ) {
234 Map<String,Object> keys = new HashMap<String, Object>(1);
235 keys.put(LocationConstants.PrimaryKeyConstants.CODE, subcontractorCountryCode);
236 subcontractorCountry = moduleService.getExternalizableBusinessObject(CountryEbo.class, keys);
237 } else {
238 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
239 }
240 }
241 }
242 return subcontractorCountry;
243 }
244
245
246
247
248
249
250 public void setSubcontractorCountry(CountryEbo country) {
251 this.subcontractorCountry = country;
252 }
253
254
255
256
257
258
259 public StateEbo getSubcontractorState() {
260 if ( StringUtils.isBlank(subcontractorCountryCode) || StringUtils.isBlank(OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
261 subcontractorState = null;
262 } else {
263 if ( subcontractorState == null || !StringUtils.equals( subcontractorState.getCode(),subcontractorCountryCode) || !StringUtils.equals(subcontractorState.getCountryCode(), OLEConstants.COUNTRY_CODE_UNITED_STATES ) ) {
264 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(StateEbo.class);
265 if ( moduleService != null ) {
266 Map<String,Object> keys = new HashMap<String, Object>(2);
267 keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, OLEConstants.COUNTRY_CODE_UNITED_STATES);
268 keys.put(LocationConstants.PrimaryKeyConstants.CODE, subcontractorCountryCode);
269 subcontractorState = moduleService.getExternalizableBusinessObject(StateEbo.class, keys);
270 } else {
271 throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class. Unable to proceed." );
272 }
273 }
274 }
275
276 return subcontractorState;
277 }
278
279
280
281
282
283
284
285 public void setSubcontractorState(StateEbo state) {
286 this.subcontractorState = state;
287 }
288
289 }