View Javadoc
1   /*
2    * Copyright 2008 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  package org.kuali.ole.module.purap.businessobject;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.ole.module.purap.PurapPropertyConstants;
20  import org.kuali.ole.sys.businessobject.UnitOfMeasure;
21  import org.kuali.rice.core.api.util.type.KualiDecimal;
22  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
23  import org.kuali.rice.krad.util.ObjectUtils;
24  
25  import java.util.LinkedHashMap;
26  
27  /**
28   * This class...
29   */
30  public abstract class ReceivingItemBase extends PersistableBusinessObjectBase implements PurapEnterableItem, ReceivingItem {
31  
32      private Integer receivingItemIdentifier;
33      private String documentNumber;
34      private Integer purchaseOrderIdentifier;
35      private Integer itemLineNumber;
36      private String itemTypeCode;
37      private String itemUnitOfMeasureCode;
38      private String itemCatalogNumber;
39      private String itemDescription;
40      private KualiDecimal itemReceivedTotalQuantity;
41      private KualiDecimal itemReturnedTotalQuantity;
42      private KualiDecimal itemDamagedTotalQuantity;
43      private String itemReasonAddedCode;
44      protected KualiDecimal itemOriginalReceivedTotalQuantity;
45      protected KualiDecimal itemOriginalReturnedTotalQuantity;
46      protected KualiDecimal itemOriginalDamagedTotalQuantity;
47  
48      private ItemReasonAdded itemReasonAdded;
49      private ItemType itemType;
50      private UnitOfMeasure itemUnitOfMeasure;
51  
52  
53      /**
54       * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
55       */
56      protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
57          LinkedHashMap m = new LinkedHashMap();
58          if (this.receivingItemIdentifier != null) {
59              m.put("receivingItemIdentifier", this.receivingItemIdentifier.toString());
60          }
61          return m;
62      }
63  
64      public boolean isConsideredEntered() {
65          //if all are not null then return true
66          return !((ObjectUtils.isNull(this.getItemReceivedTotalQuantity()) || this.getItemReceivedTotalQuantity().isZero()) &&
67                  (ObjectUtils.isNull(this.getItemDamagedTotalQuantity()) || this.getItemDamagedTotalQuantity().isZero()) &&
68                  (ObjectUtils.isNull(this.getItemReturnedTotalQuantity()) || this.getItemReturnedTotalQuantity().isZero()));
69      }
70  
71      public Integer getReceivingItemIdentifier() {
72          return receivingItemIdentifier;
73      }
74  
75      public void setReceivingItemIdentifier(Integer receivingItemIdentifier) {
76          this.receivingItemIdentifier = receivingItemIdentifier;
77      }
78  
79      public String getDocumentNumber() {
80          return documentNumber;
81      }
82  
83      public void setDocumentNumber(String documentNumber) {
84          this.documentNumber = documentNumber;
85      }
86  
87      public Integer getPurchaseOrderIdentifier() {
88          return purchaseOrderIdentifier;
89      }
90  
91      public void setPurchaseOrderIdentifier(Integer purchaseOrderIdentifier) {
92          this.purchaseOrderIdentifier = purchaseOrderIdentifier;
93      }
94  
95      public Integer getItemLineNumber() {
96          return itemLineNumber;
97      }
98  
99      public void setItemLineNumber(Integer itemLineNumber) {
100         this.itemLineNumber = itemLineNumber;
101     }
102 
103     public String getItemTypeCode() {
104         return itemTypeCode;
105     }
106 
107     public void setItemTypeCode(String itemTypeCode) {
108         this.itemTypeCode = itemTypeCode;
109     }
110 
111     public String getItemUnitOfMeasureCode() {
112         return itemUnitOfMeasureCode;
113     }
114 
115     public void setItemUnitOfMeasureCode(String itemUnitOfMeasureCode) {
116         this.itemUnitOfMeasureCode = (StringUtils.isNotBlank(itemUnitOfMeasureCode) ? itemUnitOfMeasureCode.toUpperCase() : itemUnitOfMeasureCode);
117     }
118 
119     public String getItemCatalogNumber() {
120         return itemCatalogNumber;
121     }
122 
123     public void setItemCatalogNumber(String itemCatalogNumber) {
124         this.itemCatalogNumber = itemCatalogNumber;
125     }
126 
127     public String getItemDescription() {
128         return itemDescription;
129     }
130 
131     public void setItemDescription(String itemDescription) {
132         this.itemDescription = itemDescription;
133     }
134 
135     public KualiDecimal getItemReceivedTotalQuantity() {
136         return itemReceivedTotalQuantity;
137     }
138 
139     public void setItemReceivedTotalQuantity(KualiDecimal itemReceivedTotalQuantity) {
140         this.itemReceivedTotalQuantity = itemReceivedTotalQuantity;
141     }
142 
143     public KualiDecimal getItemReturnedTotalQuantity() {
144         return itemReturnedTotalQuantity;
145     }
146 
147     public void setItemReturnedTotalQuantity(KualiDecimal itemReturnedTotalQuantity) {
148         this.itemReturnedTotalQuantity = itemReturnedTotalQuantity;
149     }
150 
151     public KualiDecimal getItemDamagedTotalQuantity() {
152         return itemDamagedTotalQuantity;
153     }
154 
155     public void setItemDamagedTotalQuantity(KualiDecimal itemDamagedTotalQuantity) {
156         this.itemDamagedTotalQuantity = itemDamagedTotalQuantity;
157     }
158 
159     public String getItemReasonAddedCode() {
160         return itemReasonAddedCode;
161     }
162 
163     public void setItemReasonAddedCode(String itemReasonAddedCode) {
164         this.itemReasonAddedCode = itemReasonAddedCode;
165     }
166 
167     /**
168      * Gets the itemType attribute.
169      *
170      * @return Returns the itemType.
171      */
172     public ItemType getItemType() {
173         if (ObjectUtils.isNull(itemType)) {
174             refreshReferenceObject(PurapPropertyConstants.ITEM_TYPE);
175         }
176         return itemType;
177     }
178 
179     /**
180      * Sets the itemType attribute value.
181      *
182      * @param itemType The itemType to set.
183      * @deprecated
184      */
185     public void setItemType(ItemType itemType) {
186         this.itemType = itemType;
187     }
188 
189     public KualiDecimal getItemOriginalReceivedTotalQuantity() {
190         return itemOriginalReceivedTotalQuantity;
191     }
192 
193     public void setItemOriginalReceivedTotalQuantity(KualiDecimal itemOriginalReceivedTotalQuantity) {
194         this.itemOriginalReceivedTotalQuantity = itemOriginalReceivedTotalQuantity;
195     }
196 
197     public KualiDecimal getItemOriginalReturnedTotalQuantity() {
198         return itemOriginalReturnedTotalQuantity;
199     }
200 
201     public void setItemOriginalReturnedTotalQuantity(KualiDecimal itemOriginalReturnedTotalQuantity) {
202         this.itemOriginalReturnedTotalQuantity = itemOriginalReturnedTotalQuantity;
203     }
204 
205     public KualiDecimal getItemOriginalDamagedTotalQuantity() {
206         return itemOriginalDamagedTotalQuantity;
207     }
208 
209     public void setItemOriginalDamagedTotalQuantity(KualiDecimal itemOriginalDamagedTotalQuantity) {
210         this.itemOriginalDamagedTotalQuantity = itemOriginalDamagedTotalQuantity;
211     }
212 
213     public ItemReasonAdded getItemReasonAdded() {
214         if (itemReasonAdded != null) {
215             return itemReasonAdded;
216         } else if (itemReasonAddedCode != null) {
217             refreshReferenceObject(PurapPropertyConstants.ITEM_REASON_ADDED);
218         }
219         return itemReasonAdded;
220     }
221 
222     public void setItemReasonAdded(ItemReasonAdded itemReasonAdded) {
223         this.itemReasonAdded = itemReasonAdded;
224     }
225 
226     public UnitOfMeasure getItemUnitOfMeasure() {
227         if (ObjectUtils.isNull(itemUnitOfMeasure) || (!itemUnitOfMeasure.getItemUnitOfMeasureCode().equalsIgnoreCase(getItemUnitOfMeasureCode()))) {
228             refreshReferenceObject(PurapPropertyConstants.ITEM_UNIT_OF_MEASURE);
229         }
230         return itemUnitOfMeasure;
231     }
232 
233     public void setItemUnitOfMeasure(UnitOfMeasure itemUnitOfMeasure) {
234         this.itemUnitOfMeasure = itemUnitOfMeasure;
235     }
236 
237 }