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 org.apache.commons.lang.builder.EqualsBuilder;
020import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
021import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
022import org.kuali.rice.krad.util.ObjectUtils;
023
024/**
025 * An association between a <code>Campus</code> and a <code>VendorAddress</code> to indicate that the Address is the default one
026 * for this Campus among the various Addresses available for this Vendor.
027 * 
028 * @see org.kuali.rice.location.framework.campus.CampusEbo
029 * @see org.kuali.ole.vnd.businessobject.VendorAddress
030 */
031public class VendorDefaultAddress extends PersistableBusinessObjectBase implements VendorRoutingComparable, MutableInactivatable {
032
033    protected Integer vendorDefaultAddressGeneratedIdentifier;
034    protected Integer vendorAddressGeneratedIdentifier;
035    protected String vendorCampusCode;
036    protected boolean active;
037
038    protected VendorAddress vendorAddress;
039    protected CampusParameter vendorCampus;
040
041    /**
042     * Default constructor.
043     */
044    public VendorDefaultAddress() {
045
046    }
047
048    public String getVendorCampusCode() {
049
050        return vendorCampusCode;
051    }
052
053    public void setVendorCampusCode(String vendorCampusCode) {
054        this.vendorCampusCode = vendorCampusCode;
055    }
056
057    public Integer getVendorAddressGeneratedIdentifier() {
058
059        return vendorAddressGeneratedIdentifier;
060    }
061
062    public void setVendorAddressGeneratedIdentifier(Integer vendorAddressGeneratedIdentifier) {
063        this.vendorAddressGeneratedIdentifier = vendorAddressGeneratedIdentifier;
064    }
065
066    @Override
067    public boolean isActive() {
068
069        return active;
070    }
071
072    @Override
073    public void setActive(boolean active) {
074        this.active = active;
075    }
076
077    public VendorAddress getVendorAddress() {
078
079        return vendorAddress;
080    }
081
082    /**
083     * Sets the vendorAddress attribute.
084     * 
085     * @param vendorAddress The vendorAddress to set.
086     * @deprecated
087     */
088    public void setVendorAddress(VendorAddress vendorAddress) {
089        this.vendorAddress = vendorAddress;
090    }
091
092
093    public CampusParameter getVendorCampus() {
094        return vendorCampus;
095    }
096
097    /**
098     * Sets the vendorCampus attribute.
099     * 
100     * @param vendorCampus The vendorCampus to set.
101     * @deprecated
102     */
103    public void setVendorCampus(CampusParameter vendorCampus) {
104        this.vendorCampus = vendorCampus;
105    }
106
107    public Integer getVendorDefaultAddressGeneratedIdentifier() {
108
109        return vendorDefaultAddressGeneratedIdentifier;
110    }
111
112    public void setVendorDefaultAddressGeneratedIdentifier(Integer vendorDefaultAddressGeneratedIdentifier) {
113        this.vendorDefaultAddressGeneratedIdentifier = vendorDefaultAddressGeneratedIdentifier;
114    }
115
116    /**
117     * @see org.kuali.ole.vnd.document.routing.VendorRoutingComparable#isEqualForRouting(java.lang.Object)
118     */
119    @Override
120    public boolean isEqualForRouting(Object toCompare) {
121        if ((ObjectUtils.isNull(toCompare)) || !(toCompare instanceof VendorDefaultAddress)) {
122
123            return false;
124        }
125        else {
126            VendorDefaultAddress vda = (VendorDefaultAddress) toCompare;
127
128            return new EqualsBuilder().append(this.getVendorDefaultAddressGeneratedIdentifier(), vda.getVendorDefaultAddressGeneratedIdentifier()).append(this.getVendorAddressGeneratedIdentifier(), vda.getVendorAddressGeneratedIdentifier()).append(this.getVendorCampusCode(), vda.getVendorCampusCode()).isEquals();
129        }
130    }
131}