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.vnd.businessobject; 017 018 import java.util.LinkedHashMap; 019 020 import org.kuali.kfs.vnd.VendorPropertyConstants; 021 import org.kuali.rice.kns.bo.Inactivateable; 022 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; 023 024 public class VendorCommodityCode extends PersistableBusinessObjectBase implements Inactivateable { 025 026 private Integer vendorHeaderGeneratedIdentifier; 027 private Integer vendorDetailAssignedIdentifier; 028 private String purchasingCommodityCode; 029 private boolean commodityDefaultIndicator; 030 private boolean active; 031 032 private VendorDetail vendorDetail; 033 private CommodityCode commodityCode; 034 035 /** 036 * Default constructor. 037 */ 038 public VendorCommodityCode() { 039 040 } 041 042 public VendorCommodityCode(Integer vendorHeaderGeneratedIdentifier, Integer vendorDetailAssignedIdentifier, CommodityCode commodityCode, boolean active) { 043 this.vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier; 044 this.vendorDetailAssignedIdentifier = vendorDetailAssignedIdentifier; 045 this.commodityCode = commodityCode; 046 if (commodityCode != null) { 047 this.purchasingCommodityCode = commodityCode.getPurchasingCommodityCode(); 048 } 049 this.active = active; 050 } 051 052 /** 053 * Gets the vendorHeaderGeneratedIdentifier attribute. 054 * 055 * @return Returns the vendorHeaderGeneratedIdentifier 056 * 057 */ 058 public Integer getVendorHeaderGeneratedIdentifier() { 059 return vendorHeaderGeneratedIdentifier; 060 } 061 062 /** 063 * Sets the vendorHeaderGeneratedIdentifier attribute. 064 * 065 * @param vendorHeaderGeneratedIdentifier The vendorHeaderGeneratedIdentifier to set. 066 * 067 */ 068 public void setVendorHeaderGeneratedIdentifier(Integer vendorHeaderGeneratedIdentifier) { 069 this.vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier; 070 } 071 072 073 /** 074 * Gets the vendorDetailAssignedIdentifier attribute. 075 * 076 * @return Returns the vendorDetailAssignedIdentifier 077 * 078 */ 079 public Integer getVendorDetailAssignedIdentifier() { 080 return vendorDetailAssignedIdentifier; 081 } 082 083 /** 084 * Sets the vendorDetailAssignedIdentifier attribute. 085 * 086 * @param vendorDetailAssignedIdentifier The vendorDetailAssignedIdentifier to set. 087 * 088 */ 089 public void setVendorDetailAssignedIdentifier(Integer vendorDetailAssignedIdentifier) { 090 this.vendorDetailAssignedIdentifier = vendorDetailAssignedIdentifier; 091 } 092 093 094 /** 095 * Gets the commodityCode attribute. 096 * 097 * @return Returns the commodityCode 098 * 099 */ 100 public String getPurchasingCommodityCode() { 101 return purchasingCommodityCode; 102 } 103 104 /** 105 * Sets the commodityCode attribute. 106 * 107 * @param commodityCode The commodityCode to set. 108 * 109 */ 110 public void setPurchasingCommodityCode(String purchasingCommodityCode) { 111 this.purchasingCommodityCode = purchasingCommodityCode; 112 } 113 114 115 /** 116 * Gets the commodityDefaultIndicator attribute. 117 * 118 * @return Returns the commodityDefaultIndicator 119 * 120 */ 121 public boolean isCommodityDefaultIndicator() { 122 return commodityDefaultIndicator; 123 } 124 125 /** 126 * Sets the commodityDefaultIndicator attribute. 127 * 128 * @param commodityDefaultIndicator The commodityDefaultIndicator to set. 129 * 130 */ 131 public void setCommodityDefaultIndicator(boolean commodityDefaultIndicator) { 132 this.commodityDefaultIndicator = commodityDefaultIndicator; 133 } 134 135 136 /** 137 * Gets the active attribute. 138 * 139 * @return Returns the active 140 * 141 */ 142 public boolean isActive() { 143 return active; 144 } 145 146 /** 147 * Sets the active attribute. 148 * 149 * @param active The active to set. 150 * 151 */ 152 public void setActive(boolean active) { 153 this.active = active; 154 } 155 156 /** 157 * Gets the vendorDetail attribute. 158 * @return Returns the vendorDetail. 159 */ 160 public VendorDetail getVendorDetail() { 161 return vendorDetail; 162 } 163 164 /** 165 * Sets the vendorDetail attribute value. 166 * @param vendorDetail The vendorDetail to set. 167 * @deprecated 168 */ 169 public void setVendorDetail(VendorDetail vendorDetail) { 170 this.vendorDetail = vendorDetail; 171 } 172 173 public CommodityCode getCommodityCode() { 174 return commodityCode; 175 } 176 177 public void setCommodityCode(CommodityCode commodityCode) { 178 this.commodityCode = commodityCode; 179 } 180 181 /** 182 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper() 183 */ 184 protected LinkedHashMap toStringMapper() { 185 LinkedHashMap m = new LinkedHashMap(); 186 if (this.vendorHeaderGeneratedIdentifier != null) { 187 m.put(VendorPropertyConstants.VENDOR_HEADER_GENERATED_ID, this.vendorHeaderGeneratedIdentifier.toString()); 188 } 189 if (this.vendorDetailAssignedIdentifier != null) { 190 m.put(VendorPropertyConstants.VENDOR_DETAIL_ASSIGNED_ID, this.vendorDetailAssignedIdentifier.toString()); 191 } 192 m.put(VendorPropertyConstants.PURCHASING_COMMODITY_CODE, this.purchasingCommodityCode); 193 return m; 194 } 195 196 /** 197 * This method overrides the superclass method to return the description of the commodity code. 198 * 199 * @param mapper A LinkedHashMap 200 * @return A String rendition of this object. 201 */ 202 @Override 203 public String toStringBuilder(LinkedHashMap mapper) { 204 if (commodityCode != null) { 205 206 return commodityCode.getCommodityDescription(); 207 } 208 else { 209 210 return super.toStringBuilder(mapper); 211 } 212 } 213 }