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.LinkedHashMap;
020
021import org.apache.commons.lang.builder.EqualsBuilder;
022import org.apache.log4j.Logger;
023import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
024import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
025import org.kuali.rice.krad.util.ObjectUtils;
026
027/**
028 * Relationship between a Vendor and a <code>SupplierDiversity</code>.
029 * 
030 * @see org.kuali.ole.vnd.businessobject.SupplierDiversity
031 */
032public class VendorSupplierDiversity extends PersistableBusinessObjectBase implements VendorRoutingComparable, MutableInactivatable {
033    private static Logger LOG = Logger.getLogger(VendorSupplierDiversity.class);
034
035    private Integer vendorHeaderGeneratedIdentifier;
036    private String vendorSupplierDiversityCode;
037    private boolean active;
038
039    private VendorHeader vendorHeader;
040    private SupplierDiversity vendorSupplierDiversity;
041
042
043    /**
044     * Default constructor.
045     */
046    public VendorSupplierDiversity() {
047
048    }
049
050    public Integer getVendorHeaderGeneratedIdentifier() {
051
052        return vendorHeaderGeneratedIdentifier;
053    }
054
055    public void setVendorHeaderGeneratedIdentifier(Integer vendorHeaderGeneratedIdentifier) {
056        this.vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier;
057    }
058
059    public String getVendorSupplierDiversityCode() {
060
061        return vendorSupplierDiversityCode;
062    }
063
064    public void setVendorSupplierDiversityCode(String vendorSupplierDiversityCode) {
065        this.vendorSupplierDiversityCode = vendorSupplierDiversityCode;
066    }
067
068    public boolean isActive() {
069
070        return active;
071    }
072
073    public void setActive(boolean active) {
074        this.active = active;
075    }
076
077    public VendorHeader getVendorHeader() {
078
079        return vendorHeader;
080    }
081
082    /**
083     * Sets the vendorHeader attribute value.
084     * 
085     * @param vendorHeader The vendorHeader to set.
086     * @deprecated
087     */
088    public void setVendorHeader(VendorHeader vendorHeader) {
089        this.vendorHeader = vendorHeader;
090    }
091
092    public SupplierDiversity getVendorSupplierDiversity() {
093
094        return vendorSupplierDiversity;
095    }
096
097    /**
098     * Sets the vendorSupplierDiversity attribute value.
099     * 
100     * @param vendorSupplierDiversity The vendorSupplierDiversity to set.
101     * @deprecated
102     */
103    public void setVendorSupplierDiversity(SupplierDiversity vendorSupplierDiversity) {
104        this.vendorSupplierDiversity = vendorSupplierDiversity;
105    }
106
107    /**
108     * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
109     */
110    protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
111        LinkedHashMap m = new LinkedHashMap();
112
113        if (this.vendorHeaderGeneratedIdentifier != null) {
114            m.put("vendorHeaderGeneratedIdentifier", this.vendorHeaderGeneratedIdentifier.toString());
115        }
116        m.put("vendorSupplierDiversityCode", this.vendorSupplierDiversityCode);
117
118        return m;
119    }
120
121    /**
122     * @see org.kuali.ole.vnd.document.routing.VendorRoutingComparable#isEqualForRouting(java.lang.Object)
123     */
124    public boolean isEqualForRouting(Object toCompare) {
125        LOG.debug("Entering isEqualForRouting.");
126        if ((ObjectUtils.isNull(toCompare)) || !(toCompare instanceof VendorSupplierDiversity)) {
127
128            return false;
129        }
130        else {
131            VendorSupplierDiversity vsd = (VendorSupplierDiversity) toCompare;
132
133            return new EqualsBuilder().append(this.getVendorHeaderGeneratedIdentifier(), vsd.getVendorHeaderGeneratedIdentifier()).append(this.getVendorSupplierDiversityCode(), vsd.getVendorSupplierDiversityCode()).isEquals();
134        }
135    }
136
137}