View Javadoc
1   /*
2    * Copyright 2008-2009 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.fp.businessobject;
17  
18  import java.util.ArrayList;
19  import java.util.HashMap;
20  import java.util.LinkedHashMap;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.apache.commons.lang.StringUtils;
25  import org.kuali.ole.integration.cam.CapitalAssetManagementAsset;
26  import org.kuali.ole.integration.cam.CapitalAssetManagementAssetType;
27  import org.kuali.ole.sys.OLEPropertyConstants;
28  import org.kuali.ole.sys.context.SpringContext;
29  import org.kuali.ole.vnd.businessobject.VendorDetail;
30  import org.kuali.rice.core.api.util.type.KualiDecimal;
31  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
32  import org.kuali.rice.krad.service.KualiModuleService;
33  import org.kuali.rice.krad.util.ObjectUtils;
34  
35  public class CapitalAssetInformation extends PersistableBusinessObjectBase {
36  
37      //primary key fields..
38      private String documentNumber;
39      private Integer capitalAssetLineNumber;
40      
41      private Integer vendorHeaderGeneratedIdentifier;
42      private Integer vendorDetailAssignedIdentifier;
43      private String vendorName;
44      private Long capitalAssetNumber;
45      private Integer capitalAssetQuantity;
46      private String capitalAssetTypeCode;
47      private String capitalAssetManufacturerName;
48      private String capitalAssetDescription;
49      private String capitalAssetManufacturerModelNumber;
50      private KualiDecimal capitalAssetLineAmount;
51      private String capitalAssetActionIndicator;
52      private boolean capitalAssetProcessedIndicator;
53      private String distributionAmountCode;
54      
55      private CapitalAssetManagementAsset capitalAssetManagementAsset;
56      private CapitalAssetManagementAssetType capitalAssetManagementAssetType;
57      private List<CapitalAssetInformationDetail> capitalAssetInformationDetails;
58      private List<CapitalAssetAccountsGroupDetails> capitalAssetAccountsGroupDetails;
59  
60      private VendorDetail vendorDetail;
61  
62      /**
63       * Constructs a CapitalAssetInformation.java.
64       */
65      public CapitalAssetInformation() {
66          super();
67          setCapitalAssetLineAmount(KualiDecimal.ZERO);
68          capitalAssetInformationDetails = new ArrayList<CapitalAssetInformationDetail>();
69          capitalAssetAccountsGroupDetails = new ArrayList<CapitalAssetAccountsGroupDetails>();
70      }
71  
72      protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
73          LinkedHashMap m = new LinkedHashMap();
74          m.put(OLEPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
75          m.put(OLEPropertyConstants.CAPITAL_ASSET_LINE_NUMBER, this.getCapitalAssetLineNumber());
76          
77          return m;
78      }
79  
80      public String getCapitalAssetDescription() {
81          return capitalAssetDescription;
82      }
83  
84      public void setCapitalAssetDescription(String capitalAssetDescription) {
85          this.capitalAssetDescription = capitalAssetDescription;
86      }
87  
88      public String getCapitalAssetManufacturerModelNumber() {
89          return capitalAssetManufacturerModelNumber;
90      }
91  
92      public void setCapitalAssetManufacturerModelNumber(String capitalAssetManufacturerModelNumber) {
93          this.capitalAssetManufacturerModelNumber = capitalAssetManufacturerModelNumber;
94      }
95  
96      public String getCapitalAssetManufacturerName() {
97          return capitalAssetManufacturerName;
98      }
99  
100     public void setCapitalAssetManufacturerName(String capitalAssetManufacturerName) {
101         this.capitalAssetManufacturerName = capitalAssetManufacturerName;
102     }
103 
104     public Long getCapitalAssetNumber() {
105         return capitalAssetNumber;
106     }
107 
108     public void setCapitalAssetNumber(Long capitalAssetNumber) {
109         this.capitalAssetNumber = capitalAssetNumber;
110     }
111 
112     public Integer getCapitalAssetQuantity() {
113         // Return capitalAssetQuantity first if it already set. Otherwise, return the size of details. If the order is reversed, the
114         // user input of quantity may be overridden.
115         if (this.capitalAssetQuantity != null) {
116             return this.capitalAssetQuantity;
117         }
118 
119         if (ObjectUtils.isNotNull(capitalAssetInformationDetails) && !capitalAssetInformationDetails.isEmpty()) {
120             return capitalAssetInformationDetails.size();
121         }
122         
123         return null;
124     }
125 
126     public void setCapitalAssetQuantity(Integer capitalAssetQuantity) {
127         this.capitalAssetQuantity = capitalAssetQuantity;
128     }
129 
130 
131     public String getCapitalAssetTypeCode() {
132         return capitalAssetTypeCode;
133     }
134 
135     public void setCapitalAssetTypeCode(String capitalAssetTypeCode) {
136         this.capitalAssetTypeCode = capitalAssetTypeCode;
137     }
138 
139     public String getDocumentNumber() {
140         return documentNumber;
141     }
142 
143     public void setDocumentNumber(String documentNumber) {
144         this.documentNumber = documentNumber;
145     }
146 
147     public Integer getVendorDetailAssignedIdentifier() {
148         return vendorDetailAssignedIdentifier;
149     }
150 
151     public void setVendorDetailAssignedIdentifier(Integer vendorDetailedAssignedIdentifier) {
152         this.vendorDetailAssignedIdentifier = vendorDetailedAssignedIdentifier;
153     }
154 
155     public Integer getVendorHeaderGeneratedIdentifier() {
156         return vendorHeaderGeneratedIdentifier;
157     }
158 
159     public void setVendorHeaderGeneratedIdentifier(Integer vendorHeaderGeneratedIdentifier) {
160         this.vendorHeaderGeneratedIdentifier = vendorHeaderGeneratedIdentifier;
161     }
162 
163     /**
164      * Gets the capitalAssetManagementAsset attribute.
165      * 
166      * @return Returns the capitalAssetManagementAsset.
167      */
168     public CapitalAssetManagementAsset getCapitalAssetManagementAsset() {
169         capitalAssetManagementAsset = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CapitalAssetManagementAsset.class).retrieveExternalizableBusinessObjectIfNecessary(this, capitalAssetManagementAsset, OLEPropertyConstants.CAPITAL_ASSET_MANAGEMENT_ASSET);
170         return capitalAssetManagementAsset;
171     }
172 
173     /**
174      * Sets the capitalAssetManagementAsset attribute value.
175      * 
176      * @param capitalAssetManagementAsset The capitalAssetManagementAsset to set.
177      */
178     public void setCapitalAssetManagementAsset(CapitalAssetManagementAsset capitalAssetManagementAsset) {
179         this.capitalAssetManagementAsset = capitalAssetManagementAsset;
180     }
181 
182     /**
183      * Gets the capitalAssetManagementAssetType attribute.
184      * 
185      * @return Returns the capitalAssetManagementAssetType.
186      */
187     public CapitalAssetManagementAssetType getCapitalAssetManagementAssetType() {
188         capitalAssetManagementAssetType = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CapitalAssetManagementAssetType.class).retrieveExternalizableBusinessObjectIfNecessary(this, capitalAssetManagementAssetType, OLEPropertyConstants.CAPITAL_ASSET_MANAGEMENT_ASSET_TYPE);
189         return capitalAssetManagementAssetType;
190     }
191 
192     /**
193      * Sets the capitalAssetManagementAssetType attribute value.
194      * 
195      * @param capitalAssetManagementAssetType The capitalAssetManagementAssetType to set.
196      */
197     @Deprecated
198     public void setCapitalAssetManagementAssetType(CapitalAssetManagementAssetType capitalAssetManagementAssetType) {
199         this.capitalAssetManagementAssetType = capitalAssetManagementAssetType;
200     }
201 
202     /**
203      * Gets the vendorDetail attribute.
204      * 
205      * @return Returns the vendorDetail.
206      */
207     public VendorDetail getVendorDetail() {
208         return vendorDetail;
209     }
210 
211     /**
212      * Sets the vendorDetail attribute value.
213      * 
214      * @param vendorDetail The vendorDetail to set.
215      */
216     @Deprecated
217     public void setVendorDetail(VendorDetail vendorDetail) {
218         this.vendorDetail = vendorDetail;
219     }
220     
221     /**
222      * Returns a map with the primitive field names as the key and the primitive values as the map value.
223      * 
224      * @return Map a map with the primitive field names as the key and the primitive values as the map value.
225      */
226     public Map<String, Object> getValuesMap() {
227         Map<String, Object> simpleValues = new HashMap<String, Object>();
228 
229         simpleValues.put(OLEPropertyConstants.DOCUMENT_NUMBER, this.getDocumentNumber());
230         simpleValues.put(OLEPropertyConstants.VENDOR_HEADER_GENERATED_ID, this.getVendorHeaderGeneratedIdentifier());
231         simpleValues.put(OLEPropertyConstants.VENDOR_DETAIL_ASSIGNED_ID, this.getVendorDetailAssignedIdentifier());
232         simpleValues.put(OLEPropertyConstants.VENDOR_NAME, this.getVendorName());
233         simpleValues.put(OLEPropertyConstants.CAPITAL_ASSET_NUMBER, this.getCapitalAssetNumber());
234         simpleValues.put(OLEPropertyConstants.CAPITAL_ASSET_TYPE_CODE, this.getCapitalAssetTypeCode());
235         simpleValues.put(OLEPropertyConstants.CAPITAL_ASSET_LINE_AMOUNT, this.getCapitalAssetLineAmount());
236         simpleValues.put(OLEPropertyConstants.CAPITAL_ASSET_LINE_NUMBER, this.getCapitalAssetLineNumber());
237         simpleValues.put(OLEPropertyConstants.CAPITAL_ASSET_ACTION_INDICATOR, this.getCapitalAssetActionIndicator());
238         simpleValues.put(OLEPropertyConstants.CAPITAL_ASSET_QUANTITY, this.getCapitalAssetQuantity());
239         simpleValues.put(OLEPropertyConstants.CAPITAL_ASSET_PROCESSED_IND, this.isCapitalAssetProcessedIndicator());
240         simpleValues.put(OLEPropertyConstants.CPTLAST_DST_AMT_CD, this.getDistributionAmountCode());
241         return simpleValues;
242     }
243 
244     /**
245      * Gets the vendorName attribute.
246      * 
247      * @return Returns the vendorName.
248      */
249     public String getVendorName() {
250         if (ObjectUtils.isNotNull(vendorDetail)) {
251             vendorName = vendorDetail.getVendorName();
252         }
253         else if (StringUtils.isNotBlank(vendorName) && vendorName.indexOf(" > ") > 0){
254                 vendorName = vendorName.substring(vendorName.indexOf(" > ") + 2, vendorName.length());
255         }
256 
257         return vendorName;
258     }
259 
260     /**
261      * Sets the vendorName attribute value.
262      * 
263      * @param vendorName The vendorName to set.
264      */
265     public void setVendorName(String vendorName) {
266         this.vendorName = vendorName;
267     }
268 
269     /**
270      * Gets the capitalAssetAccountsGroupDetails attribute.
271      * 
272      * @return Returns the capitalAssetAccountsGroupDetails
273      */
274     public List<CapitalAssetAccountsGroupDetails> getCapitalAssetAccountsGroupDetails() {
275         return capitalAssetAccountsGroupDetails;
276     }
277 
278     /**	
279      * Sets the capitalAssetAccountsGroupDetails attribute.
280      * 
281      * @param capitalAssetAccountsGroupDetails The capitalAssetAccountsGroupDetails to set.
282      */
283     public void setCapitalAssetAccountsGroupDetails(List<CapitalAssetAccountsGroupDetails> capitalAssetAccountsGroupDetails) {
284         this.capitalAssetAccountsGroupDetails = capitalAssetAccountsGroupDetails;
285     }
286 
287     /**
288      * Gets the capitalAssetInformationDetails attribute.
289      * 
290      * @return Returns the capitalAssetInformationDetails.
291      */
292     public List<CapitalAssetInformationDetail> getCapitalAssetInformationDetails() {
293         return capitalAssetInformationDetails;
294     }
295 
296     /**
297      * Sets the capitalAssetInformationDetails attribute value.
298      * 
299      * @param capitalAssetInformationDetails The capitalAssetInformationDetails to set.
300      */
301     public void setCapitalAssetInformationDetails(List<CapitalAssetInformationDetail> capitalAssetInformationDetails) {
302         this.capitalAssetInformationDetails = capitalAssetInformationDetails;
303     }
304 
305     /**
306      * Gets the capitalAssetLineNumber attribute. 
307      * @return Returns the capitalAssetLineNumber.
308      */
309     public Integer getCapitalAssetLineNumber() {
310         return capitalAssetLineNumber;
311     }
312 
313     /**
314      * Sets the capitalAssetLineNumber attribute value.
315      * @param capitalAssetLineNumber The capitalAssetLineNumber to set.
316      */
317     public void setCapitalAssetLineNumber(Integer capitalAssetLineNumber) {
318         this.capitalAssetLineNumber = capitalAssetLineNumber;
319     }
320     
321     /**
322      * @return Returns the capitalAssetLineAmount.
323      */
324     public KualiDecimal getCapitalAssetLineAmount() {
325         if (ObjectUtils.isNull(capitalAssetLineAmount)) {
326             return KualiDecimal.ZERO;
327         }
328         else {
329             return capitalAssetLineAmount;
330         }
331     }
332 
333     /**
334      * @param capitalAssetLineAmount The capitalAssetLineAmount to set.
335      */
336     public void setCapitalAssetLineAmount(KualiDecimal capitalAssetLineAmount) {
337         if (ObjectUtils.isNull(capitalAssetLineAmount)) {
338             this.capitalAssetLineAmount = KualiDecimal.ZERO;
339         }
340         else {
341             this.capitalAssetLineAmount = capitalAssetLineAmount;
342         }
343 
344         this.capitalAssetLineAmount = capitalAssetLineAmount;
345     }
346     
347     
348     /**
349      * Gets the capitalAssetActionIndicator attribute.
350      * 
351      * @return Returns the capitalAssetActionIndicator
352      */
353     
354     public String getCapitalAssetActionIndicator() {
355         return capitalAssetActionIndicator;
356     }
357 
358     /** 
359      * Sets the capitalAssetActionIndicator attribute.
360      * 
361      * @param capitalAssetActionIndicator The capitalAssetActionIndicator to set.
362      */
363     public void setCapitalAssetActionIndicator(String capitalAssetActionIndicator) {
364         this.capitalAssetActionIndicator = capitalAssetActionIndicator;
365     }
366 
367     /**
368      * Gets the capitalAssetProcessedIndicator attribute.
369      * 
370      * @return Returns the capitalAssetProcessedIndicator
371      */
372     
373     public boolean isCapitalAssetProcessedIndicator() {
374         return capitalAssetProcessedIndicator;
375     }
376 
377     /** 
378      * Sets the capitalAssetProcessedIndicator attribute.
379      * 
380      * @param capitalAssetProcessedIndicator The capitalAssetProcessedIndicator to set.
381      */
382     public void setCapitalAssetProcessedIndicator(boolean capitalAssetProcessedIndicator) {
383         this.capitalAssetProcessedIndicator = capitalAssetProcessedIndicator;
384     }
385     
386     /**
387      * Gets the distributionAmountCode attribute.
388      * 
389      * @return Returns the distributionAmountCode
390      */
391     
392     public String getDistributionAmountCode() {
393         return distributionAmountCode;
394     }
395 
396     /** 
397      * Sets the distributionAmountCode attribute.
398      * 
399      * @param distributionAmountCode The distributionAmountCode to set.
400      */
401     public void setDistributionAmountCode(String distributionAmountCode) {
402         this.distributionAmountCode = distributionAmountCode;
403     }
404 }