View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.kuali.ole.vnd.businessobject;
18  
19  import java.sql.Date;
20  import java.util.ArrayList;
21  import java.util.LinkedHashMap;
22  import java.util.List;
23  
24  import org.apache.commons.lang.builder.EqualsBuilder;
25  import org.apache.log4j.Logger;
26  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
27  
28  /**
29   * Contains information specific to a parent Vendor, which may be shared by its division Vendors if it has any. Contained by a
30   * <code>VendorDetail</code>.
31   * 
32   * @see org.kuali.ole.vnd.businessobject.VendorDetail
33   */
34  public class VendorHeader extends PersistableBusinessObjectBase {
35      private static Logger LOG = Logger.getLogger(VendorHeader.class);
36  
37      private Integer vendorHeaderGeneratedIdentifier;
38      private String vendorTypeCode;
39      private String vendorTaxNumber;
40      private String vendorTaxTypeCode;
41      private String vendorOwnershipCode;
42      private String vendorOwnershipCategoryCode;
43      private Date vendorFederalWithholdingTaxBeginningDate;
44      private Date vendorFederalWithholdingTaxEndDate;
45      private Boolean vendorW9ReceivedIndicator;
46      private Boolean vendorW8BenReceivedIndicator;
47      private Boolean vendorDebarredIndicator;
48      private Boolean vendorForeignIndicator;
49  
50      private VendorType vendorType;
51      private OwnershipType vendorOwnership;
52      private OwnershipCategory vendorOwnershipCategory;
53      private List<VendorSupplierDiversity> vendorSupplierDiversities;
54      private List<VendorTaxChange> vendorTaxChanges;
55  
56      /**
57       * Default constructor.
58       */
59      public VendorHeader() {
60          vendorSupplierDiversities = new ArrayList<VendorSupplierDiversity>();
61      }
62  
63      public Integer getVendorHeaderGeneratedIdentifier() {
64  
65          return vendorHeaderGeneratedIdentifier;
66      }
67  
68      public void setVendorHeaderGeneratedIdentifier(Integer vendorHeaderGeneratedIdentifier) {
69          this.vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier;
70      }
71  
72      public String getVendorTypeCode() {
73  
74          return vendorTypeCode;
75      }
76  
77      public void setVendorTypeCode(String vendorTypeCode) {
78          this.vendorTypeCode = vendorTypeCode;
79      }
80  
81      public String getVendorTaxNumber() {
82  
83          return vendorTaxNumber;
84      }
85  
86      public void setVendorTaxNumber(String vendorTaxNumber) {
87          this.vendorTaxNumber = vendorTaxNumber;
88      }
89  
90      public String getVendorTaxTypeCode() {
91  
92          return vendorTaxTypeCode;
93      }
94  
95      public void setVendorTaxTypeCode(String vendorTaxTypeCode) {
96          this.vendorTaxTypeCode = vendorTaxTypeCode;
97      }
98  
99      public String getVendorOwnershipCode() {
100 
101         return vendorOwnershipCode;
102     }
103 
104     public void setVendorOwnershipCode(String vendorOwnershipCode) {
105         this.vendorOwnershipCode = vendorOwnershipCode;
106     }
107 
108     public String getVendorOwnershipCategoryCode() {
109 
110         return vendorOwnershipCategoryCode;
111     }
112 
113     public void setVendorOwnershipCategoryCode(String vendorOwnershipCategoryCode) {
114         this.vendorOwnershipCategoryCode = vendorOwnershipCategoryCode;
115     }
116 
117     public Date getVendorFederalWithholdingTaxBeginningDate() {
118 
119         return vendorFederalWithholdingTaxBeginningDate;
120     }
121 
122     public void setVendorFederalWithholdingTaxBeginningDate(Date vendorFederalWithholdingTaxBeginningDate) {
123         this.vendorFederalWithholdingTaxBeginningDate = vendorFederalWithholdingTaxBeginningDate;
124     }
125 
126     public Date getVendorFederalWithholdingTaxEndDate() {
127 
128         return vendorFederalWithholdingTaxEndDate;
129     }
130 
131     public void setVendorFederalWithholdingTaxEndDate(Date vendorFederalWithholdingTaxEndDate) {
132         this.vendorFederalWithholdingTaxEndDate = vendorFederalWithholdingTaxEndDate;
133     }
134 
135     public Boolean getVendorW9ReceivedIndicator() {
136 
137         return vendorW9ReceivedIndicator;
138     }
139 
140     public void setVendorW9ReceivedIndicator(Boolean vendorW9ReceivedIndicator) {
141         this.vendorW9ReceivedIndicator = vendorW9ReceivedIndicator;
142     }
143 
144     public Boolean getVendorW8BenReceivedIndicator() {
145 
146         return vendorW8BenReceivedIndicator;
147     }
148 
149     public void setVendorW8BenReceivedIndicator(Boolean vendorW8BenReceivedIndicator) {
150         this.vendorW8BenReceivedIndicator = vendorW8BenReceivedIndicator;
151     }
152 
153     public VendorType getVendorType() {
154         // refresh because proxy doesn't work properly and vendor type sometimes is null
155         if (vendorType == null)
156             this.refreshReferenceObject("vendorType");
157         return vendorType;
158     }
159 
160     /**
161      * Sets the vendorType attribute.
162      * 
163      * @param vendorType The vendorType to set.
164      * @deprecated
165      */
166     public void setVendorType(VendorType vendorType) {
167         this.vendorType = vendorType;
168     }
169 
170     public OwnershipType getVendorOwnership() {
171 
172         return vendorOwnership;
173     }
174 
175     /**
176      * Sets the vendorOwnership attribute.
177      * 
178      * @param vendorOwnership The vendorOwnership to set.
179      * @deprecated
180      */
181     public void setVendorOwnership(OwnershipType vendorOwnership) {
182         this.vendorOwnership = vendorOwnership;
183     }
184 
185     public OwnershipCategory getVendorOwnershipCategory() {
186 
187         return vendorOwnershipCategory;
188     }
189 
190     /**
191      * Sets the vendorOwnershipCategory attribute.
192      * 
193      * @param vendorOwnershipCategory The vendorOwnershipCategory to set.
194      * @deprecated
195      */
196     public void setVendorOwnershipCategory(OwnershipCategory vendorOwnershipCategory) {
197         this.vendorOwnershipCategory = vendorOwnershipCategory;
198     }
199 
200     public Boolean getVendorDebarredIndicator() {
201 
202         return vendorDebarredIndicator;
203     }
204 
205     /**
206      * Sets the vendorDebarredIndicator attribute value.
207      * 
208      * @param vendorDebarredIndicator The vendorDebarredIndicator to set.
209      */
210     public void setVendorDebarredIndicator(Boolean vendorDebarredIndicator) {
211         this.vendorDebarredIndicator = vendorDebarredIndicator;
212     }
213 
214     public Boolean getVendorForeignIndicator() {
215 
216         return vendorForeignIndicator;
217     }
218 
219     /**
220      * Sets the vendorForeignIndicator attribute value.
221      * 
222      * @param vendorForeignIndicator The vendorForeignIndicator to set.
223      */
224     public void setVendorForeignIndicator(Boolean vendorForeignIndicator) {
225         this.vendorForeignIndicator = vendorForeignIndicator;
226     }
227 
228     public List<VendorSupplierDiversity> getVendorSupplierDiversities() {
229 
230         return vendorSupplierDiversities;
231     }
232 
233     public void setVendorSupplierDiversities(List<VendorSupplierDiversity> vendorSupplierDiversities) {
234         this.vendorSupplierDiversities = vendorSupplierDiversities;
235     }
236 
237     /**
238      * Used by the Spring Framework to correctly retrieve the vendor supplier diversities as a single
239      * attribute. The vendorSupplierDiversities is a collection of diversities, and without this method, 
240      * there was no way to get a single attribute for it.
241      * 
242      * @return the vendor supplier diversities as a single attribute
243      */
244     public String getVendorSupplierDiversitiesAsString() {
245         StringBuilder sb = new StringBuilder("vendorSupplierDiversities=[");
246 
247         boolean first = true;
248         for (VendorSupplierDiversity vsd : vendorSupplierDiversities) {
249             if(vsd.isActive()){
250             if (!first) {
251                 sb.append(", ");
252             } else {
253                 first = false;
254             }
255                 sb.append(vsd.getVendorSupplierDiversity().getVendorSupplierDiversityDescription().toString());
256             }
257         }
258         sb.append(']');
259 
260         return sb.toString();
261     }
262 
263     public List<VendorTaxChange> getVendorTaxChanges() {
264 
265         return vendorTaxChanges;
266     }
267 
268     public void setVendorTaxChanges(List<VendorTaxChange> vendorTaxChanges) {
269         this.vendorTaxChanges = vendorTaxChanges;
270     }
271 
272     /**
273      * This method is a predicate to test equality of all the persisted attributes of an instance of this class, including member
274      * collections. This is used to determine whether to route
275      * 
276      * @param vh Another VendorHeader object
277      * @return True if all non-derived attributes of the given object are equal to this one's
278      */
279     public boolean isEqualForRouting(Object toCompare) {
280         LOG.debug("Entering isEqualForRouting.");
281         if (!(toCompare instanceof VendorHeader)) {
282             return false;
283         }
284         else {
285             VendorHeader vh = (VendorHeader) toCompare;
286             return new EqualsBuilder().append(this.getVendorTypeCode(), vh.getVendorTypeCode()).append(this.getVendorTaxNumber(), vh.getVendorTaxNumber()).append(this.getVendorOwnershipCode(), vh.getVendorOwnershipCode()).append(this.getVendorOwnershipCategoryCode(), vh.getVendorOwnershipCategoryCode()).append(this.getVendorFederalWithholdingTaxBeginningDate(), vh.getVendorFederalWithholdingTaxBeginningDate()).append(this.getVendorFederalWithholdingTaxEndDate(), vh.getVendorFederalWithholdingTaxEndDate()).append(this.getVendorW9ReceivedIndicator(), vh.getVendorW9ReceivedIndicator()).append(this.getVendorW8BenReceivedIndicator(), vh.getVendorW8BenReceivedIndicator()).append(this.getVendorDebarredIndicator(), vh.getVendorDebarredIndicator()).append(this.getVendorForeignIndicator(), vh.getVendorForeignIndicator()).isEquals();
287         }
288     }
289 
290     /**
291      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
292      */
293     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
294         LinkedHashMap<String, String> m = new LinkedHashMap<String, String>();
295         if (this.vendorHeaderGeneratedIdentifier != null) {
296             m.put("vendorHeaderGeneratedIdentifier", this.vendorHeaderGeneratedIdentifier.toString());
297         }
298         return m;
299     }
300 }