View Javadoc
1   /*
2    * Copyright 2007 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  
17  package org.kuali.ole.sys.businessobject;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  import org.apache.commons.lang.StringUtils;
23  import org.kuali.ole.sys.context.SpringContext;
24  import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
25  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
26  import org.kuali.rice.krad.service.KualiModuleService;
27  import org.kuali.rice.krad.service.ModuleService;
28  import org.kuali.rice.location.api.LocationConstants;
29  import org.kuali.rice.location.framework.campus.CampusEbo;
30  
31  /**
32   * 
33   */
34  public class Room extends PersistableBusinessObjectBase implements MutableInactivatable {
35  
36      protected String campusCode;
37      protected String buildingCode;
38      protected String buildingRoomNumber;
39      protected String buildingRoomType;
40      protected String buildingRoomDepartment;
41      protected String buildingRoomDescription;
42      protected boolean active;
43  
44      protected CampusEbo campus;
45      protected Building building;
46  
47      /**
48       * Default constructor.
49       */
50      public Room() {
51  
52      }
53  
54      /**
55       * Gets the campusCode attribute.
56       * 
57       * @return Returns the campusCode
58       */
59      public String getCampusCode() {
60          return campusCode;
61      }
62  
63      /**
64       * Sets the campusCode attribute.
65       * 
66       * @param campusCode The campusCode to set.
67       */
68      public void setCampusCode(String campusCode) {
69          this.campusCode = campusCode;
70      }
71  
72  
73      /**
74       * Gets the buildingCode attribute.
75       * 
76       * @return Returns the buildingCode
77       */
78      public String getBuildingCode() {
79          return buildingCode;
80      }
81  
82      /**
83       * Sets the buildingCode attribute.
84       * 
85       * @param buildingCode The buildingCode to set.
86       */
87      public void setBuildingCode(String buildingCode) {
88          this.buildingCode = buildingCode;
89      }
90  
91  
92      /**
93       * Gets the buildingRoomNumber attribute.
94       * 
95       * @return Returns the buildingRoomNumber
96       */
97      public String getBuildingRoomNumber() {
98          return buildingRoomNumber;
99      }
100 
101     /**
102      * Sets the buildingRoomNumber attribute.
103      * 
104      * @param buildingRoomNumber The buildingRoomNumber to set.
105      */
106     public void setBuildingRoomNumber(String buildingRoomNumber) {
107         this.buildingRoomNumber = buildingRoomNumber;
108     }
109 
110 
111     /**
112      * Gets the buildingRoomType attribute.
113      * 
114      * @return Returns the buildingRoomType
115      */
116     public String getBuildingRoomType() {
117         return buildingRoomType;
118     }
119 
120     /**
121      * Sets the buildingRoomType attribute.
122      * 
123      * @param buildingRoomType The buildingRoomType to set.
124      */
125     public void setBuildingRoomType(String buildingRoomType) {
126         this.buildingRoomType = buildingRoomType;
127     }
128 
129 
130     /**
131      * Gets the buildingRoomDepartment attribute.
132      * 
133      * @return Returns the buildingRoomDepartment
134      */
135     public String getBuildingRoomDepartment() {
136         return buildingRoomDepartment;
137     }
138 
139     /**
140      * Sets the buildingRoomDepartment attribute.
141      * 
142      * @param buildingRoomDepartment The buildingRoomDepartment to set.
143      */
144     public void setBuildingRoomDepartment(String buildingRoomDepartment) {
145         this.buildingRoomDepartment = buildingRoomDepartment;
146     }
147 
148 
149     /**
150      * Gets the buildingRoomDescription attribute.
151      * 
152      * @return Returns the buildingRoomDescription
153      */
154     public String getBuildingRoomDescription() {
155         return buildingRoomDescription;
156     }
157 
158     /**
159      * Sets the buildingRoomDescription attribute.
160      * 
161      * @param buildingRoomDescription The buildingRoomDescription to set.
162      */
163     public void setBuildingRoomDescription(String buildingRoomDescription) {
164         this.buildingRoomDescription = buildingRoomDescription;
165     }
166 
167 
168     /**
169      * Gets the campus attribute.
170      * 
171      * @return Returns the campus
172      */
173     public CampusEbo getCampus() {
174         if ( StringUtils.isBlank(campusCode) ) {
175             campus = null;
176         } else {
177             if ( campus == null || !StringUtils.equals( campus.getCode(),campusCode) ) {
178                 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CampusEbo.class);
179                 if ( moduleService != null ) {
180                     Map<String,Object> keys = new HashMap<String, Object>(1);
181                     keys.put(LocationConstants.PrimaryKeyConstants.CODE, campusCode);
182                     campus = moduleService.getExternalizableBusinessObject(CampusEbo.class, keys);
183                 } else {
184                     throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
185                 }
186             }
187         }
188         return campus;
189     }
190 
191     /**
192      * Sets the campus attribute.
193      * 
194      * @param campus The campus to set.
195      * @deprecated
196      */
197     public void setCampus(CampusEbo campus) {
198         this.campus = campus;
199     }
200 
201     /**
202      * Gets the building attribute.
203      * 
204      * @return Returns the building
205      */
206     public Building getBuilding() {
207         return building;
208     }
209 
210     /**
211      * Sets the building attribute.
212      * 
213      * @param building The building to set.
214      * @deprecated
215      */
216     public void setBuilding(Building building) {
217         this.building = building;
218     }
219 
220     /**
221      * Gets the active attribute.
222      * 
223      * @return Returns the active
224      * 
225      */
226     @Override
227     public boolean isActive() {
228         return active;
229     }
230 
231     /**
232      * Sets the active attribute.
233      * 
234      * @param active The active to set.
235      * 
236      */
237     @Override
238     public void setActive(boolean active) {
239         this.active = active;
240     }
241 }