View Javadoc
1   /*
2    * Copyright 2006 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.module.cg.businessobject;
18  
19  import java.util.LinkedHashMap;
20  
21  import org.kuali.ole.coa.businessobject.Account;
22  import org.kuali.ole.coa.businessobject.Chart;
23  import org.kuali.ole.integration.cg.ContractsAndGrantsAccountAwardInformation;
24  import org.kuali.ole.sys.context.SpringContext;
25  import org.kuali.rice.core.api.mo.common.active.MutableInactivatable;
26  import org.kuali.rice.kim.api.identity.Person;
27  import org.kuali.rice.kim.api.identity.PersonService;
28  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
29  import org.kuali.rice.krad.util.ObjectUtils;
30  
31  /**
32   * This class represents an association between an award and an account. It's like a reference to the account from the award. This
33   * way an award can maintain a collection of these references instead of owning accounts directly.
34   */
35  public class AwardAccount extends PersistableBusinessObjectBase implements CGProjectDirector, MutableInactivatable, ContractsAndGrantsAccountAwardInformation {
36      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AwardAccount.class);
37      
38      protected Long proposalNumber;
39      protected String chartOfAccountsCode;
40      protected String accountNumber;
41      protected String principalId;
42      protected boolean active = true;
43  
44      protected Account account;
45      protected Chart chartOfAccounts;
46      protected Person projectDirector;
47      protected Award award;
48  
49      /**
50       * Default constructor.
51       */
52      public AwardAccount() {
53          // Struts needs this instance to populate the secondary key, principalName.
54          if ( SpringContext.isInitialized() ) {
55              try {
56                  projectDirector = (Person)SpringContext.getBean(PersonService.class).getPersonImplementationClass().newInstance();
57              }
58              catch (Exception ex) {
59                  LOG.error( "Unable to create a template person object.", ex );
60              }
61          }
62      }
63  
64      /***
65       * @see org.kuali.ole.integration.businessobject.cg.ContractsAndGrantsAccountAwardInformation#getProposalNumber()
66       */
67      public Long getProposalNumber() {
68          return proposalNumber;
69      }
70  
71      /**
72       * Sets the proposalNumber attribute.
73       * 
74       * @param proposalNumber The proposalNumber to set.
75       */
76      public void setProposalNumber(Long proposalNumber) {
77          this.proposalNumber = proposalNumber;
78      }
79  
80  
81      /***
82       * @see org.kuali.ole.integration.businessobject.cg.ContractsAndGrantsAccountAwardInformation#getChartOfAccountsCode()
83       */
84      public String getChartOfAccountsCode() {
85          return chartOfAccountsCode;
86      }
87  
88      /**
89       * Sets the chartOfAccountsCode attribute.
90       * 
91       * @param chartOfAccountsCode The chartOfAccountsCode to set.
92       */
93      public void setChartOfAccountsCode(String chartOfAccountsCode) {
94          this.chartOfAccountsCode = chartOfAccountsCode;
95      }
96  
97  
98      /***
99       * @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