001/* 002 * Copyright 2007 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.kuali.ole.vnd.businessobject; 018 019import java.util.ArrayList; 020import java.util.HashMap; 021import java.util.List; 022import java.util.Map; 023 024import org.apache.commons.lang.StringUtils; 025import org.kuali.ole.coa.businessobject.Account; 026import org.kuali.ole.sys.context.SpringContext; 027import org.kuali.rice.core.api.mo.common.active.MutableInactivatable; 028import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; 029import org.kuali.rice.krad.service.KualiModuleService; 030import org.kuali.rice.krad.service.ModuleService; 031import org.kuali.rice.location.api.LocationConstants; 032import org.kuali.rice.location.framework.country.CountryEbo; 033import org.kuali.rice.location.framework.state.StateEbo; 034 035/** 036 * Container for information about how to get in Contact with a person at a Vendor for a particular purpose. 037 */ 038public class VendorContact extends PersistableBusinessObjectBase implements MutableInactivatable { 039 040 protected Integer vendorContactGeneratedIdentifier; 041 protected Integer vendorHeaderGeneratedIdentifier; 042 protected Integer vendorDetailAssignedIdentifier; 043 protected String vendorContactTypeCode; 044 protected String vendorContactName; 045 protected String vendorContactEmailAddress; 046 protected String vendorContactCommentText; 047 protected String vendorLine1Address; 048 protected String vendorLine2Address; 049 // protected String vendorPhoneNumber; 050 // protected String vendorPhoneTypeCode; 051 protected String vendorCityName; 052 protected String vendorStateCode; 053 protected String vendorZipCode; 054 protected String vendorCountryCode; 055 protected String vendorAttentionName; 056 protected String vendorAddressInternationalProvinceName; 057 protected boolean active; 058 059 // These aren't persisted in db, only for lookup page 060 protected String phoneNumberForLookup; 061 protected String tollFreeForLookup; 062 protected String faxForLookup; 063 // protected String vendorCustomerNumberGeneratedIdentifier; 064 // protected List<VendorPhoneNumber> vendorPhoneNumbers; 065 protected List<VendorContactPhoneNumber> vendorContactPhoneNumbers; 066 protected VendorDetail vendorDetail; 067 protected ContactType vendorContactType; 068 protected StateEbo vendorState; 069 protected CountryEbo vendorCountry; 070 protected Account vendorAccounts; 071 //protected String vendorCustomerNumbers; 072 //protected List<VendorCustomerNumber> vendorCustomerNumberList; 073 074 /** 075 * Default constructor. 076 */ 077 public VendorContact() { 078 vendorContactPhoneNumbers = new ArrayList<VendorContactPhoneNumber>(); 079 } 080 081 082 /* public String getVendorCustomerNumbers() { 083 return vendorCustomerNumbers; 084 } 085 086 public void setVendorCustomerNumbers(String vendorCustomerNumbers) { 087 this.vendorCustomerNumbers = vendorCustomerNumbers; 088 }*/ 089 090 public Integer getVendorContactGeneratedIdentifier() { 091 return vendorContactGeneratedIdentifier; 092 } 093 094 public void setVendorContactGeneratedIdentifier(Integer vendorContactGeneratedIdentifier) { 095 this.vendorContactGeneratedIdentifier = vendorContactGeneratedIdentifier; 096 } 097 098 public Integer getVendorHeaderGeneratedIdentifier() { 099 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}