001    /*
002     * Copyright 2011 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     */
016    package org.kuali.kfs.module.cam.businessobject;
017    
018    import java.util.HashMap;
019    import java.util.LinkedHashMap;
020    import java.util.List;
021    import java.util.Map;
022    
023    import org.apache.log4j.Logger;
024    import org.kuali.kfs.sys.businessobject.Building;
025    import org.kuali.kfs.sys.businessobject.Room;
026    import org.kuali.kfs.sys.context.SpringContext;
027    import org.kuali.rice.kns.bo.Campus;
028    import org.kuali.rice.kns.bo.GlobalBusinessObjectDetailBase;
029    import org.kuali.rice.kns.service.KualiModuleService;
030    import org.kuali.rice.kns.service.PersistenceStructureService;
031    import org.kuali.rice.kns.util.ObjectUtils;
032    
033    /**
034     * @author Kuali Nervous System Team (kualidev@oncourse.iu.edu)
035     */
036    
037    public class AssetLocationGlobalDetail extends GlobalBusinessObjectDetailBase {
038    
039        private static final Logger LOG = Logger.getLogger(AssetLocationGlobalDetail.class);
040        
041            private String documentNumber;
042            private Long capitalAssetNumber;
043            private String campusCode;
044            private String buildingCode;
045            private String buildingRoomNumber;
046            private String buildingSubRoomNumber;
047            private String campusTagNumber;
048    
049        private Asset asset;
050        private Campus campus;
051        private Building building;
052        private Room buildingRoom;
053        
054            /**
055             * Default constructor.
056             */
057            public AssetLocationGlobalDetail() {
058    
059            }
060    
061            /**
062             * Gets the documentNumber attribute.
063             * 
064             * @return Returns the documentNumber
065             * 
066             */
067            public String getDocumentNumber() { 
068                    return documentNumber;
069            }
070    
071            /**
072             * Sets the documentNumber attribute.
073             * 
074             * @param documentNumber The documentNumber to set.
075             * 
076             */
077            public void setDocumentNumber(String documentNumber) {
078                    this.documentNumber = documentNumber;
079            }
080    
081    
082            /**
083             * Gets the capitalAssetNumber attribute.
084             * 
085             * @return Returns the capitalAssetNumber
086             * 
087             */
088            public Long getCapitalAssetNumber() { 
089                    return capitalAssetNumber;
090            }
091    
092            /**
093             * Sets the capitalAssetNumber attribute.
094             * 
095             * @param capitalAssetNumber The capitalAssetNumber to set.
096             * 
097             */
098            public void setCapitalAssetNumber(Long capitalAssetNumber) {
099                    this.capitalAssetNumber = capitalAssetNumber;
100            }
101    
102    
103            /**
104             * Gets the campusCode attribute.
105             * 
106             * @return Returns the campusCode
107             * 
108             */
109            public String getCampusCode() { 
110                    return campusCode;
111            }
112    
113            /**
114             * Sets the campusCode attribute.
115             * 
116             * @param campusCode The campusCode to set.
117             * 
118             */
119            public void setCampusCode(String campusCode) {
120                    this.campusCode = campusCode;
121            }
122    
123    
124            /**
125             * Gets the buildingCode attribute.
126             * 
127             * @return Returns the buildingCode
128             * 
129             */
130            public String getBuildingCode() { 
131                    return buildingCode;
132            }
133    
134            /**
135             * Sets the buildingCode attribute.
136             * 
137             * @param buildingCode The buildingCode to set.
138             * 
139             */
140            public void setBuildingCode(String buildingCode) {
141                    this.buildingCode = buildingCode;
142            }
143    
144    
145            /**
146             * Gets the buildingRoomNumber attribute.
147             * 
148             * @return Returns the buildingRoomNumber
149             * 
150             */
151            public String getBuildingRoomNumber() { 
152                    return buildingRoomNumber;
153            }
154    
155            /**
156             * Sets the buildingRoomNumber attribute.
157             * 
158             * @param buildingRoomNumber The buildingRoomNumber to set.
159             * 
160             */
161            public void setBuildingRoomNumber(String buildingRoomNumber) {
162                    this.buildingRoomNumber = buildingRoomNumber;
163            }
164    
165    
166            /**
167             * Gets the buildingSubRoomNumber attribute.
168             * 
169             * @return Returns the buildingSubRoomNumber
170             * 
171             */
172            public String getBuildingSubRoomNumber() { 
173                    return buildingSubRoomNumber;
174            }
175    
176            /**
177             * Sets the buildingSubRoomNumber attribute.
178             * 
179             * @param buildingSubRoomNumber The buildingSubRoomNumber to set.
180             * 
181             */
182            public void setBuildingSubRoomNumber(String buildingSubRoomNumber) {
183                    this.buildingSubRoomNumber = buildingSubRoomNumber;
184            }
185    
186    
187            /**
188             * Gets the campusTagNumber attribute.
189             * 
190             * @return Returns the campusTagNumber
191             * 
192             */
193            public String getCampusTagNumber() { 
194                    return campusTagNumber;
195            }
196    
197            /**
198             * Sets the campusTagNumber attribute.
199             * 
200             * @param campusTagNumber The campusTagNumber to set.
201             * 
202             */
203            public void setCampusTagNumber(String campusTagNumber) {
204                    this.campusTagNumber = campusTagNumber;
205            }
206        
207            /**
208         * Gets the asset attribute. 
209         * @return Returns the asset.
210         */
211        public Asset getAsset() {
212            return asset;
213        }
214    
215        /**
216         * Sets the asset attribute value.
217         * @param asset The asset to set.
218         */
219        public void setAsset(Asset asset) {
220            this.asset = asset;
221        }
222    
223        /**
224             * Gets the campus attribute.
225             * 
226             * @return Returns the campus
227             * 
228             */
229            public Campus getCampus() { 
230            return campus = (Campus) SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(Campus.class).retrieveExternalizableBusinessObjectIfNecessary(this, campus, "campus");
231            }
232    
233            /**
234             * Sets the campus attribute.
235             * 
236             * @param campus The campus to set.
237             * @deprecated
238             */
239            public void setCampus(Campus campus) {
240                    this.campus = campus;
241            }
242    
243            /**
244         * Gets the building attribute. 
245         * @return Returns the building.
246         */
247        public Building getBuilding() {
248            return building;
249        }
250    
251        /**
252         * Sets the building attribute value.
253         * @param building The building to set.
254         * @deprecated
255         */
256        public void setBuilding(Building building) {
257            this.building = building;
258        }
259    
260        /**
261         * Gets the buildingRoom attribute. 
262         * @return Returns the buildingRoom.
263         */
264        public Room getBuildingRoom() {
265            return buildingRoom;
266        }
267    
268        /**
269         * Sets the buildingRoom attribute value.
270         * @param buildingRoom The buildingRoom to set.
271         * @deprecated
272         */
273        public void setBuildingRoom(Room buildingRoom) {
274            this.buildingRoom = buildingRoom;
275        }
276    
277        /**
278         * Returns a map of the keys<propName,value> based on the primary key names of the underlying BO and reflecting into this
279         * object.
280         */
281        public Map<String, Object> getPrimaryKeys() {
282            try {
283                List<String> keys = SpringContext.getBean(PersistenceStructureService.class).getPrimaryKeys(Asset.class);
284                HashMap<String, Object> pks = new HashMap<String, Object>(keys.size());
285                for (String key : keys) {
286                    // attempt to read the property of the current object
287                    // this requires that the field names match between the underlying BO object
288                    // and this object
289                    pks.put(key, ObjectUtils.getPropertyValue(this, key));
290                }
291                return pks;
292            }
293            catch (Exception ex) {
294                LOG.error("unable to get primary keys for global detail object", ex);
295            }
296            return new HashMap<String, Object>(0);
297        }
298        
299        /**
300             * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
301             */
302            protected LinkedHashMap toStringMapper() {
303                LinkedHashMap m = new LinkedHashMap();          
304            m.put("documentNumber", this.documentNumber);
305            if (this.capitalAssetNumber != null) {
306                m.put("capitalAssetNumber", this.capitalAssetNumber.toString());
307            }
308                return m;
309        }
310    }