View Javadoc
1   /*
2    * Copyright 2006-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  
17  package org.kuali.ole.vnd.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  import org.kuali.rice.location.framework.country.CountryEbo;
31  import org.kuali.rice.location.framework.state.StateEbo;
32  
33  /**
34   * Campus Parameter Business Object. Maintenance document for campus parameters.
35   */
36  public class CampusParameter extends PersistableBusinessObjectBase implements MutableInactivatable {
37  
38      protected String campusCode;
39      protected String campusPurchasingDirectorName;
40      protected String campusPurchasingDirectorTitle;
41      protected String campusAccountsPayableEmailAddress;
42      protected String purchasingInstitutionName;
43      protected String purchasingDepartmentName;
44      protected String purchasingDepartmentLine1Address;
45      protected String purchasingDepartmentLine2Address;
46      protected String purchasingDepartmentCityName;
47      protected String purchasingDepartmentStateCode;
48      protected String purchasingDepartmentZipCode;
49      protected String purchasingDepartmentCountryCode;
50      protected boolean active;
51  
52      protected CampusEbo campus;
53      protected StateEbo purchasingDepartmentState;
54      protected CountryEbo purchasingDepartmentCountry;
55  
56      public CampusEbo getCampus() {
57          if ( StringUtils.isBlank(campusCode) ) {
58              campus = null;
59          } else {
60              if ( campus == null || !StringUtils.equals( campus.getCode(),campusCode) ) {
61                  ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CampusEbo.class);
62                  if ( moduleService != null ) {
63                      Map<String,Object> keys = new HashMap<String, Object>(1);
64                      keys.put(LocationConstants.PrimaryKeyConstants.CODE, campusCode);
65                      campus = moduleService.getExternalizableBusinessObject(CampusEbo.class, keys);
66                  } else {
67                      throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
68                  }
69      }
70          }
71          return campus;
72      }
73  
74      @Deprecated
75      public void setCampus(CampusEbo campus) {
76          this.campus = campus;
77      }
78  
79      public String getCampusAccountsPayableEmailAddress() {
80          return campusAccountsPayableEmailAddress;
81      }
82  
83      public void setCampusAccountsPayableEmailAddress(String campusAccountsPayableEmailAddress) {
84          this.campusAccountsPayableEmailAddress = campusAccountsPayableEmailAddress;
85      }
86  
87      public String getCampusCode() {
88          return campusCode;
89      }
90  
91      public void setCampusCode(String campusCode) {
92          this.campusCode = campusCode;
93      }
94  
95      public String getCampusPurchasingDirectorName() {
96          return campusPurchasingDirectorName;
97      }
98  
99      public void setCampusPurchasingDirectorName(String campusPurchasingDirectorName) {
100         this.campusPurchasingDirectorName = campusPurchasingDirectorName;
101     }
102 
103     public String getCampusPurchasingDirectorTitle() {
104         return campusPurchasingDirectorTitle;
105     }
106 
107     public void setCampusPurchasingDirectorTitle(String campusPurchasingDirectorTitle) {
108         this.campusPurchasingDirectorTitle = campusPurchasingDirectorTitle;
109     }
110 
111     public String getPurchasingDepartmentCityName() {
112         return purchasingDepartmentCityName;
113     }
114 
115     public void setPurchasingDepartmentCityName(String purchasingDepartmentCityName) {
116         this.purchasingDepartmentCityName = purchasingDepartmentCityName;
117     }
118 
119     public CountryEbo getPurchasingDepartmentCountry() {
120         if ( StringUtils.isBlank(purchasingDepartmentCountryCode) ) {
121             purchasingDepartmentCountry = null;
122         } else {
123             if ( purchasingDepartmentCountry == null || !StringUtils.equals( purchasingDepartmentCountry.getCode(),purchasingDepartmentCountryCode) ) {
124                 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(CountryEbo.class);
125                 if ( moduleService != null ) {
126                     Map<String,Object> keys = new HashMap<String, Object>(1);
127                     keys.put(LocationConstants.PrimaryKeyConstants.CODE, purchasingDepartmentCountryCode);
128                     purchasingDepartmentCountry = moduleService.getExternalizableBusinessObject(CountryEbo.class, keys);
129                 } else {
130                     throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
131                 }
132             }
133         }
134         return purchasingDepartmentCountry;
135     }
136 
137     @Deprecated
138     public void setPurchasingDepartmentCountry(CountryEbo purchasingDepartmentCountry) {
139         this.purchasingDepartmentCountry = purchasingDepartmentCountry;
140     }
141 
142     public String getPurchasingDepartmentCountryCode() {
143         return purchasingDepartmentCountryCode;
144     }
145 
146     public void setPurchasingDepartmentCountryCode(String purchasingDepartmentCountryCode) {
147         this.purchasingDepartmentCountryCode = purchasingDepartmentCountryCode;
148     }
149 
150     public String getPurchasingDepartmentLine1Address() {
151         return purchasingDepartmentLine1Address;
152     }
153 
154     public void setPurchasingDepartmentLine1Address(String purchasingDepartmentLine1Address) {
155         this.purchasingDepartmentLine1Address = purchasingDepartmentLine1Address;
156     }
157 
158     public String getPurchasingDepartmentLine2Address() {
159         return purchasingDepartmentLine2Address;
160     }
161 
162     public void setPurchasingDepartmentLine2Address(String purchasingDepartmentLine2Address) {
163         this.purchasingDepartmentLine2Address = purchasingDepartmentLine2Address;
164     }
165 
166     public String getPurchasingDepartmentName() {
167         return purchasingDepartmentName;
168     }
169 
170     public void setPurchasingDepartmentName(String purchasingDepartmentName) {
171         this.purchasingDepartmentName = purchasingDepartmentName;
172     }
173 
174     public StateEbo getPurchasingDepartmentState() {
175         if ( StringUtils.isBlank(purchasingDepartmentStateCode) || StringUtils.isBlank(purchasingDepartmentCountryCode ) ) {
176             purchasingDepartmentState = null;
177         } else {
178             if ( purchasingDepartmentState == null || !StringUtils.equals( purchasingDepartmentState.getCode(),purchasingDepartmentStateCode) || !StringUtils.equals(purchasingDepartmentState.getCountryCode(), purchasingDepartmentCountryCode ) ) {
179                 ModuleService moduleService = SpringContext.getBean(KualiModuleService.class).getResponsibleModuleService(StateEbo.class);
180                 if ( moduleService != null ) {
181                     Map<String,Object> keys = new HashMap<String, Object>(2);
182                     keys.put(LocationConstants.PrimaryKeyConstants.COUNTRY_CODE, purchasingDepartmentCountryCode);
183                     keys.put(LocationConstants.PrimaryKeyConstants.CODE, purchasingDepartmentStateCode);
184                     purchasingDepartmentState = moduleService.getExternalizableBusinessObject(StateEbo.class, keys);
185                 } else {
186                     throw new RuntimeException( "CONFIGURATION ERROR: No responsible module found for EBO class.  Unable to proceed." );
187                 }
188             }
189         }
190         return purchasingDepartmentState;
191     }
192 
193     /**
194      * @deprecated
195      */
196     public void setPurchasingDepartmentState(StateEbo purchasingDepartmentState) {
197         this.purchasingDepartmentState = purchasingDepartmentState;
198     }
199 
200     public String getPurchasingDepartmentStateCode() {
201         return purchasingDepartmentStateCode;
202     }
203 
204     public void setPurchasingDepartmentStateCode(String purchasingDepartmentStateCode) {
205         this.purchasingDepartmentStateCode = purchasingDepartmentStateCode;
206     }
207 
208     public String getPurchasingDepartmentZipCode() {
209         return purchasingDepartmentZipCode;
210     }
211 
212     public void setPurchasingDepartmentZipCode(String purchasingDepartmentZipCode) {
213         this.purchasingDepartmentZipCode = purchasingDepartmentZipCode;
214     }
215 
216     public String getPurchasingInstitutionName() {
217         return purchasingInstitutionName;
218     }
219 
220     public void setPurchasingInstitutionName(String purchasingInstitutionName) {
221         this.purchasingInstitutionName = purchasingInstitutionName;
222     }
223 
224     @Override
225     public boolean isActive() {
226         return active;
227     }
228 
229     @Override
230     public void setActive(boolean active) {
231         this.active = active;
232     }
233 }