View Javadoc
1   /*
2    * Copyright 2006 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.module.purap.businessobject;
18  
19  import org.apache.commons.lang.StringUtils;
20  import org.kuali.ole.module.purap.document.PurchaseOrderDocument;
21  import org.kuali.ole.sys.context.SpringContext;
22  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
23  import org.kuali.rice.krad.service.KualiModuleService;
24  import org.kuali.rice.krad.service.ModuleService;
25  import org.kuali.rice.krad.util.ObjectUtils;
26  import org.kuali.rice.location.api.LocationConstants;
27  import org.kuali.rice.location.framework.country.CountryEbo;
28  
29  import java.sql.Date;
30  import java.sql.Timestamp;
31  import java.util.HashMap;
32  import java.util.LinkedHashMap;
33  import java.util.Map;
34  
35  /**
36   * Purchase Order Vendor Quote Business Object.
37   */
38  public class PurchaseOrderVendorQuote extends PersistableBusinessObjectBase {
39  
40      private String documentNumber;
41      private Integer purchaseOrderVendorQuoteIdentifier;
42      private Integer vendorHeaderGeneratedIdentifier;
43      private Integer vendorDetailAssignedIdentifier;
44      private String vendorName;
45      private String vendorLine1Address;
46      private String vendorLine2Address;
47      private String vendorCityName;
48      private String vendorStateCode;
49      private String vendorPostalCode;
50      private String vendorPhoneNumber;
51      private String vendorFaxNumber;
52      private String vendorEmailAddress;
53      private String vendorAttentionName;
54      private String purchaseOrderQuoteTransmitTypeCode;
55      private Timestamp purchaseOrderQuoteTransmitTimestamp;
56      private Date purchaseOrderQuotePriceExpirationDate;
57      private String purchaseOrderQuoteStatusCode;
58      private Timestamp purchaseOrderQuoteAwardTimestamp;
59      private String purchaseOrderQuoteRankNumber;
60      private String vendorCountryCode;
61      private String vendorAddressInternationalProvinceName;
62      private boolean isTransmitPrintDisplayed = false;
63  
64      private PurchaseOrderDocument purchaseOrder;
65      private PurchaseOrderQuoteStatus purchaseOrderQuoteStatus;
66      private CountryEbo vendorCountry;
67  
68      //non-persisted variables
69      protected boolean isPdfDisplayedToUserOnce;
70  
71      /**
72       * Default constructor.
73       */
74      public PurchaseOrderVendorQuote() {
75  
76      }
77  
78      public String getDocumentNumber() {
79          return documentNumber;
80      }
81  
82      public void setDocumentNumber(String documentNumber) {
83          this.documentNumber = documentNumber;
84      }
85  
86      public Integer getPurchaseOrderVendorQuoteIdentifier() {
87          return purchaseOrderVendorQuoteIdentifier;
88      }
89  
90      /**
91       * Gets the vendorCountryCode attribute.
92       *
93       * @return Returns the vendorCountryCode.
94       */
95      public CountryEbo getVendorCountry() {
96          if (StringUtils.isBlank(vendorCountryCode)) {
97              vendorCountry = null;
98          } else {
99              if (vendorCountry == null || !StringUtils.equals(vendorCountry.getCode(), vendorCountryCode)) {
100                 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CountryEbo.class);
101                 if (moduleService != null) {
102                     Map<String, Object> keys = new HashMap<String, Object>(1);
103                     keys.put(LocationConstants.PrimaryKeyConstants.CODE, vendorCountryCode);
104                     vendorCountry = moduleService.getExternalizableBusinessObject(CountryEbo.class, keys);
105                 } else {
106                     throw new RuntimeException("CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed.");
107                 }
108             }
109         }
110 
111         return vendorCountry;
112     }
113 
114     public void setVendorCountry(CountryEbo vendorCountry) {
115         this.vendorCountry = vendorCountry;
116     }
117 
118     public void setPurchaseOrderVendorQuoteIdentifier(Integer purchaseOrderVendorQuoteIdentifier) {
119         this.purchaseOrderVendorQuoteIdentifier = purchaseOrderVendorQuoteIdentifier;
120     }
121 
122     public Integer getVendorHeaderGeneratedIdentifier() {
123         return vendorHeaderGeneratedIdentifier;
124     }
125 
126     public void setVendorHeaderGeneratedIdentifier(Integer vendorHeaderGeneratedIdentifier) {
127         this.vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier;
128     }
129 
130     public Integer getVendorDetailAssignedIdentifier() {
131         return vendorDetailAssignedIdentifier;
132     }
133 
134     public void setVendorDetailAssignedIdentifier(Integer vendorDetailAssignedIdentifier) {
135         this.vendorDetailAssignedIdentifier = vendorDetailAssignedIdentifier;
136     }
137 
138     public String getVendorAddressInternationalProvinceName() {
139         return vendorAddressInternationalProvinceName;
140     }
141 
142     public void setVendorAddressInternationalProvinceName(String vendorAddressInternationalProvinceName) {
143         this.vendorAddressInternationalProvinceName = vendorAddressInternationalProvinceName;
144     }
145 
146     public String getVendorNumber() {
147         String vendorNumber = "";
148         if (ObjectUtils.isNotNull(this.vendorHeaderGeneratedIdentifier)) {
149             vendorNumber = this.vendorHeaderGeneratedIdentifier.toString();
150         }
151         if (ObjectUtils.isNotNull(this.vendorDetailAssignedIdentifier)) {
152             vendorNumber += "-" + this.vendorDetailAssignedIdentifier.toString();
153         }
154         return vendorNumber;
155     }
156 
157     public void setVendorNumber(String vendorNumber) {
158         // do nothing
159     }
160 
161     public String getVendorName() {
162         return vendorName;
163     }
164 
165     public void setVendorName(String vendorName) {
166         this.vendorName = vendorName;
167     }
168 
169     public String getVendorLine1Address() {
170         return vendorLine1Address;
171     }
172 
173     public void setVendorLine1Address(String vendorLine1Address) {
174         this.vendorLine1Address = vendorLine1Address;
175     }
176 
177     public String getVendorLine2Address() {
178         return vendorLine2Address;
179     }
180 
181     public void setVendorLine2Address(String vendorLine2Address) {
182         this.vendorLine2Address = vendorLine2Address;
183     }
184 
185     public String getVendorCityName() {
186         return vendorCityName;
187     }
188 
189     public void setVendorCityName(String vendorCityName) {
190         this.vendorCityName = vendorCityName;
191     }
192 
193     public String getVendorStateCode() {
194         return vendorStateCode;
195     }
196 
197     public void setVendorStateCode(String vendorStateCode) {
198         this.vendorStateCode = vendorStateCode;
199     }
200 
201     public String getVendorPostalCode() {
202         return vendorPostalCode;
203     }
204 
205     public void setVendorPostalCode(String vendorPostalCode) {
206         this.vendorPostalCode = vendorPostalCode;
207     }
208 
209     public String getVendorPhoneNumber() {
210         return vendorPhoneNumber;
211     }
212 
213     public void setVendorPhoneNumber(String vendorPhoneNumber) {
214         this.vendorPhoneNumber = vendorPhoneNumber;
215     }
216 
217     public String getVendorFaxNumber() {
218         return vendorFaxNumber;
219     }
220 
221     public void setVendorFaxNumber(String vendorFaxNumber) {
222         this.vendorFaxNumber = vendorFaxNumber;
223     }
224 
225     public String getVendorEmailAddress() {
226         return vendorEmailAddress;
227     }
228 
229     public void setVendorEmailAddress(String vendorEmailAddress) {
230         this.vendorEmailAddress = vendorEmailAddress;
231     }
232 
233     public String getVendorAttentionName() {
234         return vendorAttentionName;
235     }
236 
237     public void setVendorAttentionName(String vendorAttentionName) {
238         this.vendorAttentionName = vendorAttentionName;
239     }
240 
241     public String getPurchaseOrderQuoteTransmitTypeCode() {
242         return purchaseOrderQuoteTransmitTypeCode;
243     }
244 
245     public void setPurchaseOrderQuoteTransmitTypeCode(String purchaseOrderQuoteTransmitTypeCode) {
246         this.purchaseOrderQuoteTransmitTypeCode = purchaseOrderQuoteTransmitTypeCode;
247     }
248 
249     public Timestamp getPurchaseOrderQuoteTransmitTimestamp() {
250         return purchaseOrderQuoteTransmitTimestamp;
251     }
252 
253     public void setPurchaseOrderQuoteTransmitTimestamp(Timestamp purchaseOrderQuoteTransmitTimestamp) {
254         this.purchaseOrderQuoteTransmitTimestamp = purchaseOrderQuoteTransmitTimestamp;
255     }
256 
257     public Date getPurchaseOrderQuotePriceExpirationDate() {
258         return purchaseOrderQuotePriceExpirationDate;
259     }
260 
261     public void setPurchaseOrderQuotePriceExpirationDate(Date purchaseOrderQuotePriceExpirationDate) {
262         this.purchaseOrderQuotePriceExpirationDate = purchaseOrderQuotePriceExpirationDate;
263     }
264 
265     public String getPurchaseOrderQuoteStatusCode() {
266         return purchaseOrderQuoteStatusCode;
267     }
268 
269     public void setPurchaseOrderQuoteStatusCode(String purchaseOrderQuoteStatusCode) {
270         this.purchaseOrderQuoteStatusCode = purchaseOrderQuoteStatusCode;
271     }
272 
273     public Timestamp getPurchaseOrderQuoteAwardTimestamp() {
274         return purchaseOrderQuoteAwardTimestamp;
275     }
276 
277     public void setPurchaseOrderQuoteAwardTimestamp(Timestamp purchaseOrderQuoteAwardTimestamp) {
278         this.purchaseOrderQuoteAwardTimestamp = purchaseOrderQuoteAwardTimestamp;
279     }
280 
281     public String getPurchaseOrderQuoteRankNumber() {
282         return purchaseOrderQuoteRankNumber;
283     }
284 
285     public void setPurchaseOrderQuoteRankNumber(String purchaseOrderQuoteRankNumber) {
286         this.purchaseOrderQuoteRankNumber = purchaseOrderQuoteRankNumber;
287     }
288 
289     public PurchaseOrderDocument getPurchaseOrder() {
290         return purchaseOrder;
291     }
292 
293     /**
294      * Sets the purchaseOrder attribute.
295      *
296      * @param purchaseOrder The purchaseOrder to set.
297      * @deprecated
298      */
299     public void setPurchaseOrder(PurchaseOrderDocument purchaseOrder) {
300         this.purchaseOrder = purchaseOrder;
301     }
302 
303     public PurchaseOrderQuoteStatus getPurchaseOrderQuoteStatus() {
304         return purchaseOrderQuoteStatus;
305     }
306 
307     /**
308      * Sets the purchaseOrderQuoteStatus attribute.
309      *
310      * @param purchaseOrderQuoteStatus The purchaseOrderQuoteStatus to set.
311      * @deprecated
312      */
313     public void setPurchaseOrderQuoteStatus(PurchaseOrderQuoteStatus purchaseOrderQuoteStatus) {
314         this.purchaseOrderQuoteStatus = purchaseOrderQuoteStatus;
315     }
316 
317     public String getVendorCountryCode() {
318         return vendorCountryCode;
319     }
320 
321     public void setVendorCountryCode(String vendorCountryCode) {
322         this.vendorCountryCode = vendorCountryCode;
323     }
324 
325     public boolean isTransmitPrintDisplayed() {
326         return isTransmitPrintDisplayed;
327     }
328 
329     public void setTransmitPrintDisplayed(boolean isTransmitPrintDisplayed) {
330         this.isTransmitPrintDisplayed = isTransmitPrintDisplayed;
331     }
332 
333     /**
334      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
335      */
336     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
337         LinkedHashMap m = new LinkedHashMap();
338         m.put("documentNumber", this.documentNumber);
339         if (this.purchaseOrderVendorQuoteIdentifier != null) {
340             m.put("purchaseOrderVendorQuoteIdentifier", this.purchaseOrderVendorQuoteIdentifier.toString());
341         }
342         return m;
343     }
344 
345     /**
346      * Method to determine if the the pdf has already been displayed to the user
347      * one time. If false, its set to true and locks this out.
348      *
349      * @return
350      */
351     public boolean isPdfDisplayedToUserOnce() {
352         boolean valueToReturn = isPdfDisplayedToUserOnce;
353 
354         //if not displayed, we will return false, but subsequent calls will return true.
355         if (valueToReturn == false) {
356             isPdfDisplayedToUserOnce = true;
357         }
358 
359         return valueToReturn;
360     }
361 
362     public void setPdfDisplayedToUserOnce(boolean isPdfDisplayedToUserOnce) {
363         this.isPdfDisplayedToUserOnce = isPdfDisplayedToUserOnce;
364     }
365 
366 }