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.integration.cab.CapitalAssetBuilderAssetTransactionType;
20  import org.kuali.ole.integration.purap.CapitalAssetSystem;
21  import org.kuali.ole.integration.purap.ItemCapitalAsset;
22  import org.kuali.ole.module.purap.PurapConstants;
23  import org.kuali.ole.module.purap.PurapPropertyConstants;
24  import org.kuali.ole.module.purap.document.PurchasingDocument;
25  import org.kuali.ole.sys.context.SpringContext;
26  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
27  import org.kuali.rice.krad.service.KualiModuleService;
28  import org.kuali.rice.krad.util.ObjectUtils;
29  
30  import java.util.LinkedHashMap;
31  
32  public abstract class PurchasingCapitalAssetItemBase extends PersistableBusinessObjectBase implements PurchasingCapitalAssetItem {
33  
34      private Integer capitalAssetItemIdentifier;
35      private Integer itemIdentifier;
36      private String capitalAssetTransactionTypeCode;
37      private Integer capitalAssetSystemIdentifier;
38  
39      private CapitalAssetBuilderAssetTransactionType capitalAssetTransactionType;
40      private CapitalAssetSystem purchasingCapitalAssetSystem;
41      private PurchasingDocument purchasingDocument;
42      private PurchasingItem purchasingItem;
43      private ItemCapitalAsset newPurchasingItemCapitalAssetLine;
44  
45      public PurchasingCapitalAssetItemBase() {
46          super();
47          this.setNewPurchasingItemCapitalAssetLine(this.setupNewPurchasingItemCapitalAssetLine());
48      }
49  
50      public PurchasingCapitalAssetItemBase(PurchasingDocument pd) {
51          setPurchasingDocument(pd);
52      }
53  
54      public Integer getCapitalAssetItemIdentifier() {
55          return capitalAssetItemIdentifier;
56      }
57  
58      public void setCapitalAssetItemIdentifier(Integer capitalAssetItemIdentifier) {
59          this.capitalAssetItemIdentifier = capitalAssetItemIdentifier;
60      }
61  
62      public Integer getItemIdentifier() {
63          return itemIdentifier;
64      }
65  
66      public void setItemIdentifier(Integer itemIdentifier) {
67          this.itemIdentifier = itemIdentifier;
68      }
69  
70      public String getCapitalAssetTransactionTypeCode() {
71          return capitalAssetTransactionTypeCode;
72      }
73  
74      public void setCapitalAssetTransactionTypeCode(String capitalAssetTransactionTypeCode) {
75          this.capitalAssetTransactionTypeCode = capitalAssetTransactionTypeCode;
76      }
77  
78      public Integer getCapitalAssetSystemIdentifier() {
79          return capitalAssetSystemIdentifier;
80      }
81  
82      public void setCapitalAssetSystemIdentifier(Integer capitalAssetSystemIdentifier) {
83          this.capitalAssetSystemIdentifier = capitalAssetSystemIdentifier;
84      }
85  
86      public CapitalAssetBuilderAssetTransactionType getCapitalAssetTransactionType() {
87          return capitalAssetTransactionType = (CapitalAssetBuilderAssetTransactionType) SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CapitalAssetBuilderAssetTransactionType.class).retrieveExternalizableBusinessObjectIfNecessary(this, capitalAssetTransactionType, PurapPropertyConstants.ITEM_CAPITAL_ASSET_TRANSACTION_TYPE);
88      }
89  
90      public CapitalAssetSystem getPurchasingCapitalAssetSystem() {
91          return purchasingCapitalAssetSystem;
92      }
93  
94      public void setPurchasingCapitalAssetSystem(CapitalAssetSystem purchasingCapitalAssetSystem) {
95          this.purchasingCapitalAssetSystem = purchasingCapitalAssetSystem;
96      }
97  
98      public PurchasingDocument getPurchasingDocument() {
99          if (ObjectUtils.isNull(this.purchasingDocument)) {
100             this.refreshReferenceObject("purchasingDocument");
101         }
102 
103         return this.purchasingDocument;
104     }
105 
106     public void setPurchasingDocument(PurchasingDocument pd) {
107         this.purchasingDocument = pd;
108     }
109 
110     public PurchasingItem getPurchasingItem() {
111         PurchasingDocument pd = this.getPurchasingDocument();
112 
113         if ((pd != null) && (this.getItemIdentifier() != null)) {
114             return pd.getPurchasingItem(this.getItemIdentifier());
115         } else {
116             return null;
117         }
118     }
119 
120     public boolean isEmpty() {
121         if (this.getPurchasingDocument().getCapitalAssetSystemTypeCode().equals(PurapConstants.CapitalAssetSystemTypes.INDIVIDUAL)) {
122             return !(StringUtils.isNotEmpty(capitalAssetTransactionTypeCode) || !this.getPurchasingCapitalAssetSystem().isEmpty());
123         } else {
124             return !(StringUtils.isNotEmpty(capitalAssetTransactionTypeCode) || !this.getPurchasingDocument().getPurchasingCapitalAssetSystems().get(0).isEmpty());
125         }
126     }
127 
128     public void setNewPurchasingItemCapitalAssetLine(ItemCapitalAsset newItemCapitalAssetLine) {
129         this.newPurchasingItemCapitalAssetLine = newItemCapitalAssetLine;
130     }
131 
132     public ItemCapitalAsset getNewPurchasingItemCapitalAssetLine() {
133         return newPurchasingItemCapitalAssetLine;
134     }
135 
136     public ItemCapitalAsset getAndResetNewPurchasingItemCapitalAssetLine() {
137         ItemCapitalAsset asset = getNewPurchasingItemCapitalAssetLine();
138         setNewPurchasingItemCapitalAssetLine(setupNewPurchasingItemCapitalAssetLine());
139         return asset;
140     }
141 
142     public ItemCapitalAsset setupNewPurchasingItemCapitalAssetLine() {
143         ItemCapitalAsset asset = null;
144         return asset;
145     }
146 
147     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
148         LinkedHashMap m = new LinkedHashMap();
149         m.put("capitalAssetItemIdentifier", this.capitalAssetItemIdentifier);
150         return m;
151     }
152 
153 }