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.fp.businessobject;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.kuali.ole.sys.OLEPropertyConstants;
23  import org.kuali.ole.sys.businessobject.Building;
24  import org.kuali.ole.sys.businessobject.Room;
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.service.ModuleService;
29  import org.kuali.rice.location.api.LocationConstants;
30  import org.kuali.rice.location.framework.campus.CampusEbo;
31  
32  public class CapitalAssetInformationDetail extends PersistableBusinessObjectBase {
33  
34      //primary key fields..
35      protected String documentNumber;
36      protected Integer capitalAssetLineNumber;
37      protected Integer itemLineNumber;
38      protected String campusCode;
39      protected String buildingCode;
40      protected String buildingRoomNumber;
41      protected String buildingSubRoomNumber;
42      protected String capitalAssetTagNumber;
43      protected String capitalAssetSerialNumber;
44   
45      protected CampusEbo campus;
46      protected Building building;
47      protected Room room;
48      protected CapitalAssetInformation capitalAssetInformation;
49          
50  
51      /**
52       * Gets the documentNumber attribute.
53       * 
54       * @return Returns the documentNumber.
55       */
56      public String getDocumentNumber() {
57          return documentNumber;
58      }
59  
60      /**
61       * Sets the documentNumber attribute value.
62       * 
63       * @param documentNumber The documentNumber to set.
64       */
65      public void setDocumentNumber(String documentNumber) {
66          this.documentNumber = documentNumber;
67      }
68  
69      /**
70       * Gets the itemLineNumber attribute.
71       * 
72       * @return Returns the itemLineNumber.
73       */
74      public Integer getItemLineNumber() {
75          return itemLineNumber;
76      }
77  
78      /**
79       * Sets the itemLineNumber attribute value.
80       * 
81       * @param itemLineNumber The itemLineNumber to set.
82       */
83      public void setItemLineNumber(Integer itemLineNumber) {
84          this.itemLineNumber = itemLineNumber;
85      }
86  
87      /**
88       * Gets the campusCode attribute.
89       * 
90       * @return Returns the campusCode.
91       */
92      public String getCampusCode() {
93          return campusCode;
94      }
95  
96      /**
97       * Sets the campusCode attribute value.
98       * 
99       * @param campusCode The campusCode to set.
100      */
101     public void setCampusCode(String campusCode) {
102         this.campusCode = campusCode;
103     }
104 
105     /**
106      * Gets the buildingCode attribute.
107      * 
108      * @return Returns the buildingCode.
109      */
110     public String getBuildingCode() {
111         return buildingCode;
112     }
113 
114     /**
115      * Sets the buildingCode attribute value.
116      * 
117      * @param buildingCode The buildingCode to set.
118      */
119     public void setBuildingCode(String buildingCode) {
120         this.buildingCode = buildingCode;
121     }
122 
123     /**
124      * Gets the buildingRoomNumber attribute.
125      * 
126      * @return Returns the buildingRoomNumber.
127      */
128     public String getBuildingRoomNumber() {
129         return buildingRoomNumber;
130     }
131 
132     /**
133      * Sets the buildingRoomNumber attribute value.
134      * 
135      * @param buildingRoomNumber The buildingRoomNumber to set.
136      */
137     public void setBuildingRoomNumber(String buildingRoomNumber) {
138         this.buildingRoomNumber = buildingRoomNumber;
139     }
140 
141     /**
142      * Gets the capitalAssetTagNumber attribute.
143      * 
144      * @return Returns the capitalAssetTagNumber.
145      */
146     public String getCapitalAssetTagNumber() {
147         return capitalAssetTagNumber;
148     }
149 
150     /**
151      * Sets the capitalAssetTagNumber attribute value.
152      * 
153      * @param capitalAssetTagNumber The capitalAssetTagNumber to set.
154      */
155     public void setCapitalAssetTagNumber(String capitalAssetTagNumber) {
156         this.capitalAssetTagNumber = capitalAssetTagNumber;
157     }
158 
159     /**
160      * Gets the capitalAssetSerialNumber attribute.
161      * 
162      * @return Returns the capitalAssetSerialNumber.
163      */
164     public String getCapitalAssetSerialNumber() {
165         return capitalAssetSerialNumber;
166     }
167 
168     /**
169      * Sets the capitalAssetSerialNumber attribute value.
170      * 
171      * @param capitalAssetSerialNumber The capitalAssetSerialNumber to set.
172      */
173     public void setCapitalAssetSerialNumber(String capitalAssetSerialNumber) {
174         this.capitalAssetSerialNumber = capitalAssetSerialNumber;
175     }
176 
177     /**
178      * Gets the campus attribute.
179      * 
180      * @return Returns the campus.
181      */
182     public CampusEbo getCampus() {
183         if ( StringUtils.isBlank(campusCode) ) {
184             campus = null;
185         } else {
186             if ( campus == null || !StringUtils.equals( campus.getCode(),campusCode) ) {
187                 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CampusEbo.class);
188                 if ( moduleService != null ) {
189                     Map<String,Object> keys = new HashMap<String, Object>(1);
190                     keys.put(LocationConstants.PrimaryKeyConstants.CODE, campusCode);
191                     campus = moduleService.getExternalizableBusinessObject(CampusEbo.class, keys);
192                 } else {
193                     throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
194                 }
195             }
196         }
197         
198         return campus;
199     }
200 
201     /**
202      * Sets the campus attribute value.
203      * 
204      * @param campus The campus to set.
205      */
206     public void setCampus(CampusEbo campus) {
207         this.campus = campus;
208     }
209 
210     /**
211      * Gets the building attribute.
212      * 
213      * @return Returns the building.
214      */
215     public Building getBuilding() {
216         return building;
217     }
218 
219     /**
220      * Sets the building attribute value.
221      * 
222      * @param building The building to set.
223      */
224     public void setBuilding(Building building) {
225         this.building = building;
226     }
227 
228     /**
229      * Gets the room attribute.
230      * 
231      * @return Returns the room.
232      */
233     public Room getRoom() {
234         return room;
235     }
236 
237     /**
238      * Sets the room attribute value.
239      * 
240      * @param room The room to set.
241      */
242     public void setRoom(Room room) {
243         this.room = room;
244     }
245 
246     /**
247      * Gets the capitalAssetInformation attribute.
248      * 
249      * @return Returns the capitalAssetInformation.
250      */
251     public CapitalAssetInformation getCapitalAssetInformation() {
252         return capitalAssetInformation;
253     }
254 
255     /**
256      * Sets the capitalAssetInformation attribute value.
257      * 
258      * @param capitalAssetInformation The capitalAssetInformation to set.
259      */
260     public void setCapitalAssetInformation(CapitalAssetInformation capitalAssetInformation) {
261         this.capitalAssetInformation = capitalAssetInformation;
262     }
263 
264     /**
265      * Gets the buildingSubRoomNumber attribute. 
266      * @return Returns the buildingSubRoomNumber.
267      */
268     public String getBuildingSubRoomNumber() {
269         return buildingSubRoomNumber;
270     }
271 
272     /**
273      * Sets the buildingSubRoomNumber attribute value.
274      * @param buildingSubRoomNumber The buildingSubRoomNumber to set.
275      */
276     public void setBuildingSubRoomNumber(String buildingSubRoomNumber) {
277         this.buildingSubRoomNumber = buildingSubRoomNumber;
278     }
279     
280     /**
281      * Gets the capitalAssetLineNumber attribute. 
282      * @return Returns the capitalAssetLineNumber.
283      */
284     public Integer getCapitalAssetLineNumber() {
285         return capitalAssetLineNumber;
286     }
287 
288     /**
289      * Sets the capitalAssetLineNumber attribute value.
290      * @param capitalAssetLineNumber The capitalAssetLineNumber to set.
291      */
292     public void setCapitalAssetLineNumber(Integer capitalAssetLineNumber) {
293         this.capitalAssetLineNumber = capitalAssetLineNumber;
294     }
295     
296     /**
297      * Returns a map with the primitive field names as the key and the primitive values as the map value.
298      * 
299      * @return Map a map with the primitive field names as the key and the primitive values as the map value.
300      */
301     public Map<String, Object> getValuesMap() {
302         Map<String, Object> simpleValues = new HashMap<String, Object>();
303 
304         simpleValues.put(OLEPropertyConstants.DOCUMENT_NUMBER, this.getDocumentNumber());
305         simpleValues.put(OLEPropertyConstants.CAPITAL_ASSET_LINE_NUMBER, this.getCapitalAssetLineNumber());
306         simpleValues.put(OLEPropertyConstants.ITEM_LINE_NUMBER, this.getItemLineNumber());
307         simpleValues.put(OLEPropertyConstants.CAMPUS_CODE, this.getCampusCode());
308         simpleValues.put(OLEPropertyConstants.BUILDING_CODE, this.getBuildingCode());
309         simpleValues.put(OLEPropertyConstants.BUILDING_ROOM_NUMBER, this.getBuildingRoomNumber());
310 
311         return simpleValues;
312     }
313 }