001 /* 002 * Copyright 2011 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 package org.kuali.kfs.sys.businessobject; 017 018 import java.util.LinkedHashMap; 019 020 import org.kuali.kfs.sys.context.SpringContext; 021 import org.kuali.rice.kns.service.CountryService; 022 import org.kuali.rice.kns.service.StateService; 023 import org.kuali.rice.kns.bo.Country; 024 import org.kuali.rice.kns.bo.Inactivateable; 025 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; 026 import org.kuali.rice.kns.bo.State; 027 import org.kuali.rice.kns.util.ObjectUtils; 028 029 public class TaxRegionState extends PersistableBusinessObjectBase implements Inactivateable { 030 031 private String postalCountryCode; 032 private String stateCode; 033 private String taxRegionCode; 034 private boolean active; 035 036 private Country country; 037 private State state; 038 private TaxRegion taxRegion; 039 040 public boolean isActive() { 041 return active; 042 } 043 044 public void setActive(boolean active) { 045 this.active = active; 046 } 047 048 public String getStateCode() { 049 return stateCode; 050 } 051 052 public void setStateCode(String stateCode) { 053 this.stateCode = stateCode; 054 } 055 056 public TaxRegion getTaxRegion() { 057 if(ObjectUtils.isNull(taxRegion)){ 058 this.refreshReferenceObject("taxRegion"); 059 } 060 return taxRegion; 061 } 062 063 public void setTaxRegion(TaxRegion taxRegion) { 064 this.taxRegion = taxRegion; 065 } 066 067 public String getTaxRegionCode() { 068 return taxRegionCode; 069 } 070 071 public void setTaxRegionCode(String taxRegionCode) { 072 this.taxRegionCode = taxRegionCode; 073 } 074 075 protected LinkedHashMap toStringMapper() { 076 LinkedHashMap m = new LinkedHashMap(); 077 m.put("stateCode", this.stateCode); 078 m.put("taxRegionCode", this.taxRegionCode); 079 return m; 080 } 081 082 public State getState() { 083 state = SpringContext.getBean(StateService.class).getByPrimaryIdIfNecessary(postalCountryCode, stateCode, state); 084 return state; 085 } 086 087 public void setState(State state) { 088 this.state = state; 089 } 090 091 /** 092 * Gets the postalCountryCode attribute. 093 * 094 * @return Returns the postalCountryCode. 095 */ 096 public String getPostalCountryCode() { 097 return postalCountryCode; 098 } 099 100 /** 101 * Sets the postalCountryCode attribute value. 102 * 103 * @param postalCountryCode The postalCountryCode to set. 104 */ 105 public void setPostalCountryCode(String postalCountryCode) { 106 this.postalCountryCode = postalCountryCode; 107 } 108 109 /** 110 * Gets the country attribute. 111 * @return Returns the country. 112 */ 113 public Country getCountry() { 114 country = SpringContext.getBean(CountryService.class).getByPrimaryIdIfNecessary(postalCountryCode, country); 115 return country; 116 } 117 118 /** 119 * Sets the country attribute value. 120 * @param country The country to set. 121 */ 122 public void setCountry(Country country) { 123 this.country = country; 124 } 125 }