001/* 002 * Copyright 2007 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 017package org.kuali.ole.sys.businessobject; 018 019import java.util.HashMap; 020import java.util.Map; 021 022import org.apache.commons.lang.StringUtils; 023import org.kuali.ole.sys.context.SpringContext; 024import org.kuali.rice.core.api.mo.common.active.MutableInactivatable; 025import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; 026import org.kuali.rice.krad.service.KualiModuleService; 027import org.kuali.rice.krad.service.ModuleService; 028import org.kuali.rice.location.api.LocationConstants; 029import org.kuali.rice.location.framework.campus.CampusEbo; 030 031/** 032 * 033 */ 034public class Room extends PersistableBusinessObjectBase implements MutableInactivatable { 035 036 protected String campusCode; 037 protected String buildingCode; 038 protected String buildingRoomNumber; 039 protected String buildingRoomType; 040 protected String buildingRoomDepartment; 041 protected String buildingRoomDescription; 042 protected boolean active; 043 044 protected CampusEbo campus; 045 protected Building building; 046 047 /** 048 * Default constructor. 049 */ 050 public Room() { 051 052 } 053 054 /** 055 * Gets the campusCode attribute. 056 * 057 * @return Returns the campusCode 058 */ 059 public String getCampusCode() { 060 return campusCode; 061 } 062 063 /** 064 * Sets the campusCode attribute. 065 * 066 * @param campusCode The campusCode to set. 067 */ 068 public void setCampusCode(String campusCode) { 069 this.campusCode = campusCode; 070 } 071 072 073 /** 074 * Gets the buildingCode attribute. 075 * 076 * @return Returns the buildingCode 077 */ 078 public String getBuildingCode() { 079 return buildingCode; 080 } 081 082 /** 083 * Sets the buildingCode attribute. 084 * 085 * @param buildingCode The buildingCode to set. 086 */ 087 public void setBuildingCode(String buildingCode) { 088 this.buildingCode = buildingCode; 089 } 090 091 092 /** 093 * Gets the buildingRoomNumber attribute. 094 * 095 * @return Returns the buildingRoomNumber 096 */ 097 public String getBuildingRoomNumber() { 098 return buildingRoomNumber; 099 } 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}