001/*
002 * Copyright 2008 The Kuali Foundation
003 * 
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * 
008 * http://www.opensource.org/licenses/ecl2.php
009 * 
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.ole.fp.businessobject;
017
018import java.util.HashMap;
019import java.util.Map;
020
021import org.apache.commons.lang.StringUtils;
022import org.kuali.ole.sys.OLEPropertyConstants;
023import org.kuali.ole.sys.businessobject.Building;
024import org.kuali.ole.sys.businessobject.Room;
025import org.kuali.ole.sys.context.SpringContext;
026import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
027import org.kuali.rice.krad.service.KualiModuleService;
028import org.kuali.rice.krad.service.ModuleService;
029import org.kuali.rice.location.api.LocationConstants;
030import org.kuali.rice.location.framework.campus.CampusEbo;
031
032public class CapitalAssetInformationDetail extends PersistableBusinessObjectBase {
033
034    //primary key fields..
035    protected String documentNumber;
036    protected Integer capitalAssetLineNumber;
037    protected Integer itemLineNumber;
038    protected String campusCode;
039    protected String buildingCode;
040    protected String buildingRoomNumber;
041    protected String buildingSubRoomNumber;
042    protected String capitalAssetTagNumber;
043    protected String capitalAssetSerialNumber;
044 
045    protected CampusEbo campus;
046    protected Building building;
047    protected Room room;
048    protected CapitalAssetInformation capitalAssetInformation;
049        
050
051    /**
052     * Gets the documentNumber attribute.
053     * 
054     * @return Returns the documentNumber.
055     */
056    public String getDocumentNumber() {
057        return documentNumber;
058    }
059
060    /**
061     * Sets the documentNumber attribute value.
062     * 
063     * @param documentNumber The documentNumber to set.
064     */
065    public void setDocumentNumber(String documentNumber) {
066        this.documentNumber = documentNumber;
067    }
068
069    /**
070     * Gets the itemLineNumber attribute.
071     * 
072     * @return Returns the itemLineNumber.
073     */
074    public Integer getItemLineNumber() {
075        return itemLineNumber;
076    }
077
078    /**
079     * Sets the itemLineNumber attribute value.
080     * 
081     * @param itemLineNumber The itemLineNumber to set.
082     */
083    public void setItemLineNumber(Integer itemLineNumber) {
084        this.itemLineNumber = itemLineNumber;
085    }
086
087    /**
088     * Gets the campusCode attribute.
089     * 
090     * @return Returns the campusCode.
091     */
092    public String getCampusCode() {
093        return campusCode;
094    }
095
096    /**
097     * Sets the campusCode attribute value.
098     * 
099     * @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}