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
017 package org.kuali.kfs.module.cg.businessobject;
018
019 import java.util.LinkedHashMap;
020
021 import org.kuali.kfs.coa.businessobject.Account;
022 import org.kuali.kfs.coa.businessobject.Chart;
023 import org.kuali.kfs.integration.cg.ContractsAndGrantsAccountAwardInformation;
024 import org.kuali.kfs.sys.context.SpringContext;
025 import org.kuali.rice.kim.bo.Person;
026 import org.kuali.rice.kim.service.PersonService;
027 import org.kuali.rice.kns.bo.Inactivateable;
028 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
029 import org.kuali.rice.kns.util.ObjectUtils;
030
031 /**
032 * This class represents an association between an award and an account. It's like a reference to the account from the award. This
033 * way an award can maintain a collection of these references instead of owning accounts directly.
034 */
035 public class AwardAccount extends PersistableBusinessObjectBase implements CGProjectDirector, Inactivateable, ContractsAndGrantsAccountAwardInformation {
036
037 private Long proposalNumber;
038 private String chartOfAccountsCode;
039 private String accountNumber;
040 private String principalId;
041 private boolean active = true;
042
043 private Account account;
044 private Chart chartOfAccounts;
045 private Person projectDirector;
046 private Award award;
047
048 /**
049 * Default constructor.
050 */
051 public AwardAccount() {
052 // Struts needs this instance to populate the secondary key, principalName.
053 try {
054 projectDirector = (Person)SpringContext.getBean(PersonService.class).getPersonImplementationClass().newInstance();
055 } catch (Exception e) {}
056 }
057
058 /***
059 * @see org.kuali.kfs.integration.businessobject.cg.ContractsAndGrantsAccountAwardInformation#getProposalNumber()
060 */
061 public Long getProposalNumber() {
062 return proposalNumber;
063 }
064
065 /**
066 * Sets the proposalNumber attribute.
067 *
068 * @param proposalNumber The proposalNumber to set.
069 */
070 public void setProposalNumber(Long proposalNumber) {
071 this.proposalNumber = proposalNumber;
072 }
073
074
075 /***
076 * @see org.kuali.kfs.integration.businessobject.cg.ContractsAndGrantsAccountAwardInformation#getChartOfAccountsCode()
077 */
078 public String getChartOfAccountsCode() {
079 return chartOfAccountsCode;
080 }
081
082 /**
083 * Sets the chartOfAccountsCode attribute.
084 *
085 * @param chartOfAccountsCode The chartOfAccountsCode to set.
086 */
087 public void setChartOfAccountsCode(String chartOfAccountsCode) {
088 this.chartOfAccountsCode = chartOfAccountsCode;
089 }
090
091
092 /***
093 * @see org.kuali.kfs.integration.businessobject.cg.ContractsAndGrantsAccountAwardInformation#getAccountNumber()
094 */
095 public String getAccountNumber() {
096 return accountNumber;
097 }
098
099 /**
100 * Sets the accountNumber attribute.
101 *
102 * @param accountNumber The accountNumber to set.
103 */
104 public void setAccountNumber(String accountNumber) {
105 this.accountNumber = accountNumber;
106 }
107
108 /***
109 * @see org.kuali.kfs.integration.businessobject.cg.ContractsAndGrantsAccountAwardInformation#getPrincipalId()
110 */
111 public String getPrincipalId() {
112 return principalId;
113 }
114
115 /**
116 * Sets the principalId attribute.
117 *
118 * @param principalId The principalId to set.
119 */
120 public void setPrincipalId(String principalId) {
121 this.principalId = principalId;
122 }
123
124 /***
125 * @see org.kuali.kfs.integration.businessobject.cg.ContractsAndGrantsAccountAwardInformation#getAccount()
126 */
127 public Account getAccount() {
128 return account;
129 }
130
131 /**
132 * Sets the account attribute.
133 *
134 * @param account The account to set.
135 * @deprecated Setter is required by OJB, but should not be used to modify this attribute. This attribute is set on the initial
136 * creation of the object and should not be changed.
137 */
138 @Deprecated
139 public void setAccount(Account account) {
140 this.account = account;
141 }
142
143 /***
144 * @see org.kuali.kfs.integration.businessobject.cg.ContractsAndGrantsAccountAwardInformation#getChartOfAccounts()
145 */
146 public Chart getChartOfAccounts() {
147 return chartOfAccounts;
148 }
149
150 /**
151 * Sets the chartOfAccounts attribute.
152 *
153 * @param chartOfAccounts The chartOfAccounts to set.
154 * @deprecated Setter is required by OJB, but should not be used to modify this attribute. This attribute is set on the initial
155 * creation of the object and should not be changed.
156 */
157 @Deprecated
158 public void setChartOfAccounts(Chart chartOfAccounts) {
159 this.chartOfAccounts = chartOfAccounts;
160 }
161
162 /***
163 * @see org.kuali.kfs.integration.businessobject.cg.ContractsAndGrantsAccountAwardInformation#getProjectDirector()
164 */
165 public Person getProjectDirector() {
166 projectDirector = SpringContext.getBean(org.kuali.rice.kim.service.PersonService.class).updatePersonIfNecessary(principalId, projectDirector);
167 return projectDirector;
168 }
169
170 /**
171 * Sets the project director attribute
172 *
173 * @param projectDirector The projectDirector to set.
174 * @deprecated Setter is required by OJB, but should not be used to modify this attribute. This attribute is set on the initial
175 * creation of the object and should not be changed.
176 */
177 @Deprecated
178 public void setProjectDirector(Person projectDirector) {
179 this.projectDirector = projectDirector;
180 }
181
182 /**
183 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
184 */
185 @SuppressWarnings("unchecked")
186 @Override
187 protected LinkedHashMap toStringMapper() {
188 LinkedHashMap m = new LinkedHashMap();
189 if (this.proposalNumber != null) {
190 m.put("proposalNumber", this.proposalNumber.toString());
191 }
192 m.put("chartOfAccountsCode", this.chartOfAccountsCode);
193 m.put("accountNumber", this.accountNumber);
194 return m;
195 }
196
197 /***
198 * @see org.kuali.kfs.integration.businessobject.cg.ContractsAndGrantsAccountAwardInformation#getAward()
199 */
200 public Award getAward() {
201 return award;
202 }
203
204 /**
205 * This method sets the associated award to the value provided.
206 *
207 * @param award Value to be assigned to the associated Award object.
208 */
209 public void setAward(Award award) {
210 this.award = award;
211 }
212
213 /**
214 * @see org.kuali.rice.kns.bo.Inactivateable#isActive()
215 */
216 public boolean isActive() {
217 return active;
218 }
219
220 /**
221 * @see org.kuali.rice.kns.bo.Inactivateable#setActive(boolean)
222 */
223 public void setActive(boolean active) {
224 this.active = true;
225 }
226
227 /**
228 * @see org.kuali.kfs.integration.cg.ContractsAndGrantsAccountAwardInformation#getProjectDirectorName()
229 */
230 public String getProjectDirectorName() {
231 if (!ObjectUtils.isNull(projectDirector)) {
232 return projectDirector.getName();
233 }
234 return null;
235 }
236 }
237