001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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:
017: package org.kuali.module.vendor.bo;
018:
019: import java.util.LinkedHashMap;
020:
021: import org.apache.commons.lang.builder.EqualsBuilder;
022: import org.apache.log4j.Logger;
023: import org.kuali.core.bo.Inactivateable;
024: import org.kuali.core.bo.PersistableBusinessObjectBase;
025: import org.kuali.core.util.ObjectUtils;
026: import org.kuali.module.vendor.util.VendorRoutingComparable;
027:
028: /**
029: * Relationship between a Vendor and a <code>SupplierDiversity</code>.
030: *
031: * @see org.kuali.module.vendor.bo.SupplierDiversity
032: */
033: public class VendorSupplierDiversity extends
034: PersistableBusinessObjectBase implements
035: VendorRoutingComparable, Inactivateable {
036: private static Logger LOG = Logger
037: .getLogger(VendorSupplierDiversity.class);
038:
039: private Integer vendorHeaderGeneratedIdentifier;
040: private String vendorSupplierDiversityCode;
041: private boolean active;
042:
043: private VendorHeader vendorHeader;
044: private SupplierDiversity vendorSupplierDiversity;
045:
046: /**
047: * Default constructor.
048: */
049: public VendorSupplierDiversity() {
050:
051: }
052:
053: public Integer getVendorHeaderGeneratedIdentifier() {
054:
055: return vendorHeaderGeneratedIdentifier;
056: }
057:
058: public void setVendorHeaderGeneratedIdentifier(
059: Integer vendorHeaderGeneratedIdentifier) {
060: this .vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier;
061: }
062:
063: public String getVendorSupplierDiversityCode() {
064:
065: return vendorSupplierDiversityCode;
066: }
067:
068: public void setVendorSupplierDiversityCode(
069: String vendorSupplierDiversityCode) {
070: this .vendorSupplierDiversityCode = vendorSupplierDiversityCode;
071: }
072:
073: public boolean isActive() {
074:
075: return active;
076: }
077:
078: public void setActive(boolean active) {
079: this .active = active;
080: }
081:
082: public VendorHeader getVendorHeader() {
083:
084: return vendorHeader;
085: }
086:
087: /**
088: * Sets the vendorHeader attribute value.
089: *
090: * @param vendorHeader The vendorHeader to set.
091: * @deprecated
092: */
093: public void setVendorHeader(VendorHeader vendorHeader) {
094: this .vendorHeader = vendorHeader;
095: }
096:
097: public SupplierDiversity getVendorSupplierDiversity() {
098:
099: return vendorSupplierDiversity;
100: }
101:
102: /**
103: * Sets the vendorSupplierDiversity attribute value.
104: *
105: * @param vendorSupplierDiversity The vendorSupplierDiversity to set.
106: * @deprecated
107: */
108: public void setVendorSupplierDiversity(
109: SupplierDiversity vendorSupplierDiversity) {
110: this .vendorSupplierDiversity = vendorSupplierDiversity;
111: }
112:
113: /**
114: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
115: */
116: protected LinkedHashMap toStringMapper() {
117: LinkedHashMap m = new LinkedHashMap();
118:
119: if (this .vendorHeaderGeneratedIdentifier != null) {
120: m.put("vendorHeaderGeneratedIdentifier",
121: this .vendorHeaderGeneratedIdentifier.toString());
122: }
123: m.put("vendorSupplierDiversityCode",
124: this .vendorSupplierDiversityCode);
125:
126: return m;
127: }
128:
129: /**
130: * @see org.kuali.module.vendor.util.VendorRoutingComparable#isEqualForRouting(java.lang.Object)
131: */
132: public boolean isEqualForRouting(Object toCompare) {
133: LOG.debug("Entering isEqualForRouting.");
134: if ((ObjectUtils.isNull(toCompare))
135: || !(toCompare instanceof VendorSupplierDiversity)) {
136:
137: return false;
138: } else {
139: VendorSupplierDiversity vsd = (VendorSupplierDiversity) toCompare;
140:
141: return new EqualsBuilder().append(
142: this .getVendorHeaderGeneratedIdentifier(),
143: vsd.getVendorHeaderGeneratedIdentifier()).append(
144: this .getVendorSupplierDiversityCode(),
145: vsd.getVendorSupplierDiversityCode()).isEquals();
146: }
147: }
148:
149: /**
150: * This method overrides the superclass method to return the description of the supplier diversity.
151: *
152: * @param mapper A LinkedHashMap
153: * @return A String rendition of this object.
154: */
155: @Override
156: public String toStringBuilder(LinkedHashMap mapper) {
157: if (vendorSupplierDiversity != null) {
158:
159: return vendorSupplierDiversity
160: .getVendorSupplierDiversityDescription();
161: } else {
162:
163: return super.toStringBuilder(mapper);
164: }
165: }
166: }
|