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  
19  import org.apache.commons.lang.StringUtils;
20  import org.kuali.ole.integration.purap.CapitalAssetLocation;
21  import org.kuali.ole.integration.purap.CapitalAssetSystem;
22  import org.kuali.ole.integration.purap.ItemCapitalAsset;
23  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
24  
25  import java.util.ArrayList;
26  import java.util.LinkedHashMap;
27  import java.util.List;
28  
29  public abstract class PurchasingCapitalAssetSystemBase extends PersistableBusinessObjectBase implements CapitalAssetSystem {
30  
31      private Integer capitalAssetSystemIdentifier;
32      private String capitalAssetSystemDescription;
33      private boolean capitalAssetNotReceivedCurrentFiscalYearIndicator;
34      private String capitalAssetTypeCode;
35      private String capitalAssetManufacturerName;
36      private String capitalAssetModelDescription;
37      private String capitalAssetNoteText;
38      private List<ItemCapitalAsset> itemCapitalAssets;
39      private List<CapitalAssetLocation> capitalAssetLocations;
40      private CapitalAssetLocation newPurchasingCapitalAssetLocationLine;
41      private Integer capitalAssetCountAssetNumber;
42  
43      public Integer getCapitalAssetCountAssetNumber() {
44          return capitalAssetCountAssetNumber;
45      }
46  
47      public void setCapitalAssetCountAssetNumber(Integer capitalAssetCountAssetNumber) {
48          this.capitalAssetCountAssetNumber = capitalAssetCountAssetNumber;
49      }
50  
51      public PurchasingCapitalAssetSystemBase() {
52          super();
53          itemCapitalAssets = new ArrayList();
54          capitalAssetLocations = new ArrayList();
55          this.setNewPurchasingCapitalAssetLocationLine(this.setupNewPurchasingCapitalAssetLocationLine());
56      }
57  
58      public String getCapitalAssetSystemDescription() {
59          //This is needed because bean:define would throw error if capitalAssetSystemDescription is empty.
60          if (StringUtils.isEmpty(capitalAssetSystemDescription)) {
61              capitalAssetSystemDescription = new String(" ");
62          }
63          return capitalAssetSystemDescription;
64      }
65  
66      public void setCapitalAssetSystemDescription(String capitalAssetSystemDescription) {
67          this.capitalAssetSystemDescription = capitalAssetSystemDescription;
68      }
69  
70      public boolean isCapitalAssetNotReceivedCurrentFiscalYearIndicator() {
71          return capitalAssetNotReceivedCurrentFiscalYearIndicator;
72      }
73  
74      public void setCapitalAssetNotReceivedCurrentFiscalYearIndicator(boolean capitalAssetNotReceivedCurrentFiscalYearIndicator) {
75          this.capitalAssetNotReceivedCurrentFiscalYearIndicator = capitalAssetNotReceivedCurrentFiscalYearIndicator;
76      }
77  
78      public String getCapitalAssetTypeCode() {
79          return capitalAssetTypeCode;
80      }
81  
82      public void setCapitalAssetTypeCode(String capitalAssetTypeCode) {
83          this.capitalAssetTypeCode = capitalAssetTypeCode;
84      }
85  
86      public String getCapitalAssetManufacturerName() {
87          return capitalAssetManufacturerName;
88      }
89  
90      public void setCapitalAssetManufacturerName(String capitalAssetManufacturerName) {
91          this.capitalAssetManufacturerName = capitalAssetManufacturerName;
92      }
93  
94      public String getCapitalAssetModelDescription() {
95          return capitalAssetModelDescription;
96      }
97  
98      public void setCapitalAssetModelDescription(String capitalAssetModelDescription) {
99          this.capitalAssetModelDescription = capitalAssetModelDescription;
100     }
101 
102     public List<ItemCapitalAsset> getItemCapitalAssets() {
103         return itemCapitalAssets;
104     }
105 
106     public void setItemCapitalAssets(List<ItemCapitalAsset> itemCapitalAssets) {
107         this.itemCapitalAssets = itemCapitalAssets;
108     }
109 
110     public List<CapitalAssetLocation> getCapitalAssetLocations() {
111         return capitalAssetLocations;
112     }
113 
114     public void setCapitalAssetLocations(List<CapitalAssetLocation> capitalAssetLocations) {
115         this.capitalAssetLocations = capitalAssetLocations;
116     }
117 
118     public Integer getCapitalAssetSystemIdentifier() {
119         return capitalAssetSystemIdentifier;
120     }
121 
122     public void setCapitalAssetSystemIdentifier(Integer capitalAssetSystemIdentifier) {
123         this.capitalAssetSystemIdentifier = capitalAssetSystemIdentifier;
124     }
125 
126     public String getCapitalAssetNoteText() {
127         //This is needed because bean:define would throw error if capitalAssetNoteText is empty.
128         if (StringUtils.isEmpty(capitalAssetNoteText)) {
129             capitalAssetNoteText = new String(" ");
130         }
131         return capitalAssetNoteText;
132     }
133 
134     public void setCapitalAssetNoteText(String capitalAssetNoteText) {
135         this.capitalAssetNoteText = capitalAssetNoteText;
136     }
137 
138     public boolean isEmpty() {
139         return !(StringUtils.isNotEmpty(capitalAssetNoteText) || StringUtils.isNotEmpty(capitalAssetSystemDescription) || StringUtils.isNotEmpty(capitalAssetManufacturerName) || StringUtils.isNotEmpty(this.capitalAssetModelDescription) || StringUtils.isNotEmpty(capitalAssetTypeCode));
140     }
141 
142     public abstract Class getItemCapitalAssetClass();
143 
144     public abstract Class getCapitalAssetLocationClass();
145 
146     //CAMS LOCATION   
147     public CapitalAssetLocation setupNewPurchasingCapitalAssetLocationLine() {
148         CapitalAssetLocation location = null;
149         try {
150             location = (CapitalAssetLocation) getCapitalAssetLocationClass().newInstance();
151         } catch (InstantiationException e) {
152             throw new RuntimeException("Unable to get class");
153         } catch (IllegalAccessException e) {
154             throw new RuntimeException("Unable to get class");
155         } catch (NullPointerException e) {
156             throw new RuntimeException("Can't instantiate Purchasing Account from base");
157         }
158 
159         return location;
160     }
161 
162     public void setNewPurchasingCapitalAssetLocationLine(CapitalAssetLocation newCapitalAssetLocationLine) {
163         this.newPurchasingCapitalAssetLocationLine = newCapitalAssetLocationLine;
164     }
165 
166     public CapitalAssetLocation getNewPurchasingCapitalAssetLocationLine() {
167         return newPurchasingCapitalAssetLocationLine;
168     }
169 
170     public CapitalAssetLocation getAndResetNewPurchasingCapitalAssetLocationLine() {
171         CapitalAssetLocation asset = getNewPurchasingCapitalAssetLocationLine();
172         setNewPurchasingCapitalAssetLocationLine(setupNewPurchasingCapitalAssetLocationLine());
173         return asset;
174     }
175 
176     public void resetNewPurchasingCapitalAssetLocationLine() {
177         setNewPurchasingCapitalAssetLocationLine(setupNewPurchasingCapitalAssetLocationLine());
178     }
179 
180     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
181         LinkedHashMap m = new LinkedHashMap();
182         if (this.capitalAssetSystemIdentifier != null) {
183             m.put("capitalAssetSystemIdentifier", this.capitalAssetSystemIdentifier.toString());
184         }
185         return m;
186     }
187 
188 }