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