View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.kuali.ole.vnd.businessobject;
18  
19  import java.util.ArrayList;
20  import java.util.HashMap;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.apache.commons.lang.StringUtils;
25  import org.kuali.ole.coa.businessobject.Account;
26  import org.kuali.ole.sys.context.SpringContext;
27  import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
28  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
29  import org.kuali.rice.krad.service.KualiModuleService;
30  import org.kuali.rice.krad.service.ModuleService;
31  import org.kuali.rice.location.api.LocationConstants;
32  import org.kuali.rice.location.framework.country.CountryEbo;
33  import org.kuali.rice.location.framework.state.StateEbo;
34  
35  /**
36   * Container for information about how to get in Contact with a person at a Vendor for a particular purpose.
37   */
38  public class VendorContact extends PersistableBusinessObjectBase implements MutableInactivatable {
39  
40      protected Integer vendorContactGeneratedIdentifier;
41      protected Integer vendorHeaderGeneratedIdentifier;
42      protected Integer vendorDetailAssignedIdentifier;
43      protected String vendorContactTypeCode;
44      protected String vendorContactName;
45      protected String vendorContactEmailAddress;
46      protected String vendorContactCommentText;
47      protected String vendorLine1Address;
48      protected String vendorLine2Address;
49     // protected String vendorPhoneNumber;
50     // protected String vendorPhoneTypeCode;
51      protected String vendorCityName;
52      protected String vendorStateCode;
53      protected String vendorZipCode;
54      protected String vendorCountryCode;
55      protected String vendorAttentionName;
56      protected String vendorAddressInternationalProvinceName;
57      protected boolean active;
58  
59      // These aren't persisted in db, only for lookup page
60      protected String phoneNumberForLookup;
61      protected String tollFreeForLookup;
62      protected String faxForLookup;
63     // protected String vendorCustomerNumberGeneratedIdentifier;
64     // protected List<VendorPhoneNumber> vendorPhoneNumbers;
65      protected List<VendorContactPhoneNumber> vendorContactPhoneNumbers;
66      protected VendorDetail vendorDetail;
67      protected ContactType vendorContactType;
68      protected StateEbo vendorState;
69      protected CountryEbo vendorCountry;
70      protected Account vendorAccounts;
71      //protected String vendorCustomerNumbers;
72      //protected List<VendorCustomerNumber> vendorCustomerNumberList;
73  
74      /**
75       * Default constructor.
76       */
77      public VendorContact() {
78          vendorContactPhoneNumbers = new ArrayList<VendorContactPhoneNumber>();
79      }
80  
81  
82     /* public String getVendorCustomerNumbers() {
83          return vendorCustomerNumbers;
84      }
85  
86      public void setVendorCustomerNumbers(String vendorCustomerNumbers) {
87          this.vendorCustomerNumbers = vendorCustomerNumbers;
88      }*/
89  
90      public Integer getVendorContactGeneratedIdentifier() {
91          return vendorContactGeneratedIdentifier;
92      }
93  
94      public void setVendorContactGeneratedIdentifier(Integer vendorContactGeneratedIdentifier) {
95          this.vendorContactGeneratedIdentifier = vendorContactGeneratedIdentifier;
96      }
97  
98      public Integer getVendorHeaderGeneratedIdentifier() {
99          return vendorHeaderGeneratedIdentifier;
100     }
101 
102     public void setVendorHeaderGeneratedIdentifier(Integer vendorHeaderGeneratedIdentifier) {
103         this.vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier;
104     }
105 
106     public Integer getVendorDetailAssignedIdentifier() {
107         return vendorDetailAssignedIdentifier;
108     }
109 
110     public void setVendorDetailAssignedIdentifier(Integer vendorDetailAssignedIdentifier) {
111         this.vendorDetailAssignedIdentifier = vendorDetailAssignedIdentifier;
112     }
113 
114     public String getVendorContactTypeCode() {
115         return vendorContactTypeCode;
116     }
117 
118     public void setVendorContactTypeCode(String vendorContactTypeCode) {
119         this.vendorContactTypeCode = vendorContactTypeCode;
120     }
121 
122     public String getVendorContactName() {
123         return vendorContactName;
124     }
125 
126     public void setVendorContactName(String vendorContactName) {
127         this.vendorContactName = vendorContactName;
128     }
129 
130     public String getVendorContactEmailAddress() {
131         return vendorContactEmailAddress;
132     }
133 
134     public void setVendorContactEmailAddress(String vendorContactEmailAddress) {
135         this.vendorContactEmailAddress = vendorContactEmailAddress;
136     }
137 
138     public String getVendorContactCommentText() {
139         return vendorContactCommentText;
140     }
141 
142     public void setVendorContactCommentText(String vendorContactCommentText) {
143         this.vendorContactCommentText = vendorContactCommentText;
144     }
145 
146     public ContactType getVendorContactType() {
147         return vendorContactType;
148     }
149 
150     public void setVendorContactType(ContactType vendorContactType) {
151         this.vendorContactType = vendorContactType;
152     }
153 
154     public VendorDetail getVendorDetail() {
155         return vendorDetail;
156     }
157 
158     public void setVendorDetail(VendorDetail vendorDetail) {
159         this.vendorDetail = vendorDetail;
160     }
161 
162     public String getVendorAddressInternationalProvinceName() {
163         return vendorAddressInternationalProvinceName;
164     }
165 
166     public void setVendorAddressInternationalProvinceName(String vendorAddressInternationalProvinceName) {
167         this.vendorAddressInternationalProvinceName = vendorAddressInternationalProvinceName;
168     }
169 
170     @Override
171     public boolean isActive() {
172         return active;
173     }
174 
175     @Override
176     public void setActive(boolean active) {
177         this.active = active;
178     }
179 
180     public String getVendorAttentionName() {
181         return vendorAttentionName;
182     }
183 
184     public void setVendorAttentionName(String vendorAttentionName) {
185         this.vendorAttentionName = vendorAttentionName;
186     }
187 
188     public String getVendorCityName() {
189         return vendorCityName;
190     }
191 
192     public void setVendorCityName(String vendorCityName) {
193         this.vendorCityName = vendorCityName;
194     }
195 
196     public String getVendorCountryCode() {
197         return vendorCountryCode;
198     }
199 
200     public void setVendorCountryCode(String vendorCountryCode) {
201         this.vendorCountryCode = vendorCountryCode;
202     }
203 
204     public String getVendorLine1Address() {
205         return vendorLine1Address;
206     }
207 
208     public void setVendorLine1Address(String vendorLine1Address) {
209         this.vendorLine1Address = vendorLine1Address;
210     }
211 
212     public String getVendorLine2Address() {
213         return vendorLine2Address;
214     }
215 
216     public void setVendorLine2Address(String vendorLine2Address) {
217         this.vendorLine2Address = vendorLine2Address;
218     }
219 
220     public String getVendorStateCode() {
221         return vendorStateCode;
222     }
223 
224     public void setVendorStateCode(String vendorStateCode) {
225         this.vendorStateCode = vendorStateCode;
226     }
227 
228     public String getVendorZipCode() {
229         return vendorZipCode;
230     }
231 
232     public void setVendorZipCode(String vendorZipCode) {
233         this.vendorZipCode = vendorZipCode;
234     }
235 
236     public CountryEbo getVendorCountry() {
237         if ( StringUtils.isBlank(vendorCountryCode) ) {
238             vendorCountry = null;
239         } else {
240             if ( vendorCountry == null || !StringUtils.equals( vendorCountry.getCode(),vendorCountryCode) ) {
241                 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CountryEbo.class);
242                 if ( moduleService != null ) {
243                     Map<String,Object> keys = new HashMap<String, Object>(1);
244                     keys.put(LocationConstants.PrimaryKeyConstants.CODE, vendorCountryCode);
245                     vendorCountry = moduleService.getExternalizableBusinessObject(CountryEbo.class, keys);
246                 } else {
247                     throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
248                 }
249             }
250         }
251         return vendorCountry;
252     }
253 
254     public void setVendorCountry(CountryEbo vendorCountry) {
255         this.vendorCountry = vendorCountry;
256     }
257 
258     public StateEbo getVendorState() {
259         if ( StringUtils.isBlank(vendorStateCode) || StringUtils.isBlank(vendorCountryCode ) ) {
260             vendorState = null;
261         } else {
262             if ( vendorState == null || !StringUtils.equals( vendorState.getCode(),vendorStateCode) || !StringUtils.equals(vendorState.getCountryCode(), vendorCountryCode ) ) {
263                 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(StateEbo.class);
264                 if ( moduleService != null ) {
265                     Map<String,Object> keys = new HashMap<String, Object>(2);
266                     keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, vendorCountryCode);
267                     keys.put(LocationConstants.PrimaryKeyConstants.CODE, vendorStateCode);
268                     vendorState = moduleService.getExternalizableBusinessObject(StateEbo.class, keys);
269                 } else {
270                     throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
271                 }
272             }
273         }
274         return vendorState;
275     }
276 
277     public void setVendorState(StateEbo vendorState) {
278         this.vendorState = vendorState;
279     }
280 
281     public String getFaxForLookup() {
282         return faxForLookup;
283     }
284 
285     public void setFaxForLookup(String faxForLookup) {
286         this.faxForLookup = faxForLookup;
287     }
288 
289     public String getPhoneNumberForLookup() {
290         return phoneNumberForLookup;
291     }
292 
293     public void setPhoneNumberForLookup(String phoneNumberForLookup) {
294         this.phoneNumberForLookup = phoneNumberForLookup;
295     }
296 
297     public String getTollFreeForLookup() {
298         return tollFreeForLookup;
299     }
300 
301     public void setTollFreeForLookup(String tollFreeForLookup) {
302         this.tollFreeForLookup = tollFreeForLookup;
303     }
304 
305     public List<VendorContactPhoneNumber> getVendorContactPhoneNumbers() {
306         return vendorContactPhoneNumbers;
307     }
308 
309     public void setVendorContactPhoneNumbers(List<VendorContactPhoneNumber> vendorContactPhoneNumbers) {
310         this.vendorContactPhoneNumbers = vendorContactPhoneNumbers;
311     }
312 
313    /* public String getVendorAccount() {
314         return vendorAccount;
315     }
316 
317     public void setVendorAccount(String vendorAccount) {
318         this.vendorAccount = vendorAccount;
319     }*/
320 
321     public Account getVendorAccounts() {
322         return vendorAccounts;
323     }
324 
325     public void setVendorAccounts(Account vendorAccounts) {
326         this.vendorAccounts = vendorAccounts;
327     }
328 
329   /*  public String getVendorAccountNumber() {
330         return vendorAccountNumber;
331     }
332 
333     public void setVendorAccountNumber(String vendorAccountNumber) {
334         this.vendorAccountNumber = vendorAccountNumber;
335     }
336 
337     public String getChartOfAccountsCode() {
338         return chartOfAccountsCode;
339     }
340 
341     public void setChartOfAccountsCode(String chartOfAccountsCode) {
342         this.chartOfAccountsCode = chartOfAccountsCode;
343     }
344 
345     public Account getVendorAccount() {
346         return vendorAccount;
347     }
348 
349     public void setVendorAccount(Account vendorAccount) {
350         this.vendorAccount = vendorAccount;
351     }
352 
353     public Chart getChartOfAccounts() {
354         return chartOfAccounts;
355     }
356 
357     public void setChartOfAccounts(Chart chartOfAccounts) {
358         this.chartOfAccounts = chartOfAccounts;
359     }
360 
361     public List<VendorCustomerNumber> getVendorCustomerNumberList() {
362         return vendorCustomerNumberList;
363     }
364 
365     public void setVendorCustomerNumberList(List<VendorCustomerNumber> vendorCustomerNumberList) {
366         this.vendorCustomerNumberList = vendorCustomerNumberList;
367     }
368 
369     public String getVendorCustomerNumberGeneratedIdentifier() {
370         return vendorCustomerNumberGeneratedIdentifier;
371     }
372 
373     public void setVendorCustomerNumberGeneratedIdentifier(String vendorCustomerNumberGeneratedIdentifier) {
374         this.vendorCustomerNumberGeneratedIdentifier = vendorCustomerNumberGeneratedIdentifier;
375     }*/
376 
377 
378 
379    /* public String getVendorPhoneNumber() {
380         return vendorPhoneNumber;
381     }
382 
383     public void setVendorPhoneNumber(String vendorPhoneNumber) {
384         this.vendorPhoneNumber = vendorPhoneNumber;
385     }
386 
387     public String getVendorPhoneTypeCode() {
388         return vendorPhoneTypeCode;
389     }
390 
391     public void setVendorPhoneTypeCode(String vendorPhoneTypeCode) {
392         this.vendorPhoneTypeCode = vendorPhoneTypeCode;
393     }
394 */
395 }