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.PostalCodeService;
023    import org.kuali.rice.kns.service.StateService;
024    import org.kuali.rice.kns.bo.Country;
025    import org.kuali.rice.kns.bo.Inactivateable;
026    import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
027    import org.kuali.rice.kns.bo.PostalCode;
028    import org.kuali.rice.kns.util.ObjectUtils;
029    
030    public class TaxRegionPostalCode extends PersistableBusinessObjectBase implements Inactivateable {
031            
032        private String postalCountryCode; 
033            private String postalCode;
034            private String taxRegionCode;
035            private boolean active;
036            
037            private Country country;
038            private PostalCode postalZip;
039            private TaxRegion taxRegion;
040            
041            public PostalCode getPostalZip() {
042                postalZip = SpringContext.getBean(PostalCodeService.class).getByPrimaryIdIfNecessary(postalCountryCode, postalCode, postalZip);
043                    return postalZip;
044            }
045            public void setPostalZip(PostalCode postalZip) {
046                    this.postalZip = postalZip;
047            }
048            public TaxRegion getTaxRegion() {
049            if(ObjectUtils.isNull(taxRegion)){
050                this.refreshReferenceObject("taxRegion");
051            }           
052            return taxRegion;
053        }
054        public void setTaxRegion(TaxRegion taxRegion) {
055            this.taxRegion = taxRegion;
056        }
057        public boolean isActive() {
058                    return active;
059            }
060            public void setActive(boolean active) {
061                    this.active = active;
062            }
063            public String getPostalCode() {
064                    return postalCode;
065            }
066            public void setPostalCode(String postalCode) {
067                    this.postalCode = postalCode;
068            }
069            public String getTaxRegionCode() {
070                    return taxRegionCode;
071            }
072            public void setTaxRegionCode(String taxRegionCode) {
073                    this.taxRegionCode = taxRegionCode;
074            }
075            
076            protected LinkedHashMap toStringMapper() {
077            LinkedHashMap m = new LinkedHashMap();
078            m.put("postalCode", this.postalCode);
079            m.put("taxRegionCode", this.taxRegionCode);
080            return m;
081        }
082        /**
083         * Gets the postalCountryCode attribute. 
084         * @return Returns the postalCountryCode.
085         */
086        public String getPostalCountryCode() {
087            return postalCountryCode;
088        }
089        /**
090         * Sets the postalCountryCode attribute value.
091         * @param postalCountryCode The postalCountryCode to set.
092         */
093        public void setPostalCountryCode(String postalCountryCode) {
094            this.postalCountryCode = postalCountryCode;
095        }
096        /**
097         * Gets the country attribute. 
098         * @return Returns the country.
099         */
100        public Country getCountry() {
101            country = SpringContext.getBean(CountryService.class).getByPrimaryIdIfNecessary(postalCountryCode, country);
102            return country;
103        }
104        /**
105         * Sets the country attribute value.
106         * @param country The country to set.
107         */
108        public void setCountry(Country country) {
109            this.country = country;
110        }
111    }