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    package org.kuali.kfs.coa.businessobject;
017    
018    import java.sql.Date;
019    import java.util.LinkedHashMap;
020    
021    import org.apache.commons.lang.StringUtils;
022    import org.kuali.kfs.sys.context.SpringContext;
023    import org.kuali.rice.kew.doctype.bo.DocumentTypeEBO;
024    import org.kuali.rice.kew.service.impl.KEWModuleService;
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.KualiDecimal;
030    
031    /**
032     * 
033     */
034    public class AccountDelegate extends PersistableBusinessObjectBase implements Inactivateable {
035    
036        private static final long serialVersionUID = 6883162275377881235L;
037    
038        /**
039         * Default no-arg constructor.
040         */
041        public AccountDelegate() {
042        }
043    
044        private String chartOfAccountsCode;
045        private String accountNumber;
046        private String financialDocumentTypeCode;
047        private String accountDelegateSystemId;
048        private KualiDecimal finDocApprovalFromThisAmt;
049        private boolean accountsDelegatePrmrtIndicator;
050        private boolean active;
051        private Date accountDelegateStartDate;
052        private KualiDecimal finDocApprovalToThisAmount;
053    
054        private Chart chart;
055        private Account account;
056        private transient DocumentTypeEBO financialSystemDocumentTypeCode;
057        private Person accountDelegate;
058    
059        /**
060         * Gets the accountNumber attribute.
061         * 
062         * @return Returns the accountNumber.
063         */
064        public String getAccountNumber() {
065            return accountNumber;
066        }
067    
068        /**
069         * Sets the accountNumber attribute value.
070         * 
071         * @param accountNumber The accountNumber to set.
072         */
073        public void setAccountNumber(String accountNumber) {
074            this.accountNumber = accountNumber;
075        }
076    
077        /**
078         * Gets the chartOfAccountsCode attribute.
079         * 
080         * @return Returns the chartOfAccountsCode.
081         */
082        public String getChartOfAccountsCode() {
083            return chartOfAccountsCode;
084        }
085    
086        /**
087         * Sets the chartOfAccountsCode attribute value.
088         * 
089         * @param chartOfAccountsCode The chartOfAccountsCode to set.
090         */
091        public void setChartOfAccountsCode(String chartOfAccountsCode) {
092            this.chartOfAccountsCode = chartOfAccountsCode;
093        }
094    
095        /**
096         * Gets the financialDocumentTypeCode attribute.
097         * 
098         * @return Returns the financialDocumentTypeCode
099         */
100        public String getFinancialDocumentTypeCode() {
101            return financialDocumentTypeCode;
102        }
103    
104        /**
105         * Sets the financialDocumentTypeCode attribute.
106         * 
107         * @param financialDocumentTypeCode The financialDocumentTypeCode to set.
108         */
109        public void setFinancialDocumentTypeCode(String financialDocumentTypeCode) {
110            this.financialDocumentTypeCode = financialDocumentTypeCode;
111        }
112    
113        /**
114         * Gets the accountDelegateSystemId attribute.
115         * 
116         * @return Returns the accountDelegateSystemId.
117         */
118        public String getAccountDelegateSystemId() {
119            return accountDelegateSystemId;
120        }
121    
122        /**
123         * Sets the accountDelegateSystemId attribute value.
124         * 
125         * @param accountDelegateSystemId The accountDelegateSystemId to set.
126         */
127        public void setAccountDelegateSystemId(String accountDelegateSystemId) {
128            this.accountDelegateSystemId = accountDelegateSystemId;
129        }
130    
131        /**
132         * Gets the finDocApprovalFromThisAmt attribute.
133         * 
134         * @return Returns the finDocApprovalFromThisAmt
135         */
136        public KualiDecimal getFinDocApprovalFromThisAmt() {
137            return finDocApprovalFromThisAmt;
138        }
139    
140        /**
141         * Sets the finDocApprovalFromThisAmt attribute.
142         * 
143         * @param finDocApprovalFromThisAmt The finDocApprovalFromThisAmt to set.
144         */
145        public void setFinDocApprovalFromThisAmt(KualiDecimal finDocApprovalFromThisAmt) {
146            this.finDocApprovalFromThisAmt = finDocApprovalFromThisAmt;
147        }
148    
149        /**
150         * Gets the accountsDelegatePrmrtIndicator attribute.
151         * 
152         * @return Returns the accountsDelegatePrmrtIndicator
153         */
154        public boolean isAccountsDelegatePrmrtIndicator() {
155            return accountsDelegatePrmrtIndicator;
156        }
157    
158        /**
159         * Sets the accountsDelegatePrmrtIndicator attribute.
160         * 
161         * @param accountsDelegatePrmrtIndicator The accountsDelegatePrmrtIndicator to set.
162         * @deprecated
163         */
164        public void setAccountsDelegatePrmrtIndicator(boolean accountsDelegatePrmrtIndicator) {
165            this.accountsDelegatePrmrtIndicator = accountsDelegatePrmrtIndicator;
166        }
167    
168        /**
169         * Gets the active attribute.
170         * 
171         * @return Returns the active
172         */
173        public boolean isActive() {
174            return active;
175        }
176    
177        /**
178         * Sets the active attribute.
179         * 
180         * @param active The active to set.
181         * @deprecated
182         */
183        public void setActive(boolean active) {
184            this.active = active;
185        }
186    
187        /**
188         * Gets the accountDelegateStartDate attribute.
189         * 
190         * @return Returns the accountDelegateStartDate
191         */
192        public Date getAccountDelegateStartDate() {
193            return accountDelegateStartDate;
194        }
195    
196        /**
197         * Sets the accountDelegateStartDate attribute.
198         * 
199         * @param accountDelegateStartDate The accountDelegateStartDate to set.
200         */
201        public void setAccountDelegateStartDate(Date accountDelegateStartDate) {
202            this.accountDelegateStartDate = accountDelegateStartDate;
203        }
204    
205        /**
206         * Gets the finDocApprovalToThisAmount attribute.
207         * 
208         * @return Returns the finDocApprovalToThisAmount
209         */
210        public KualiDecimal getFinDocApprovalToThisAmount() {
211            return finDocApprovalToThisAmount;
212        }
213    
214        /**
215         * Sets the finDocApprovalToThisAmount attribute.
216         * 
217         * @param finDocApprovalToThisAmount The finDocApprovalToThisAmount to set.
218         */
219        public void setFinDocApprovalToThisAmount(KualiDecimal finDocApprovalToThisAmount) {
220            this.finDocApprovalToThisAmount = finDocApprovalToThisAmount;
221        }
222    
223        /**
224         * Gets the account attribute.
225         * 
226         * @return Returns the account
227         */
228        public Account getAccount() {
229            return account;
230        }
231    
232        /**
233         * Sets the account attribute.
234         * 
235         * @param account The account to set.
236         * @deprecated
237         */
238        public void setAccount(Account account) {
239            this.account = account;
240        }
241    
242        /**
243         * Gets the financialSystemDocumentTypeCode attribute. 
244         * @return Returns the financialSystemDocumentTypeCode.
245         */
246        public DocumentTypeEBO getFinancialSystemDocumentTypeCode() {
247            return financialSystemDocumentTypeCode = SpringContext.getBean(KEWModuleService.class).retrieveExternalizableBusinessObjectIfNecessary(this, financialSystemDocumentTypeCode, "financialSystemDocumentTypeCode");
248        }
249    
250        public Person getAccountDelegate() {
251            accountDelegate = SpringContext.getBean(PersonService.class).updatePersonIfNecessary(accountDelegateSystemId, accountDelegate);
252            return accountDelegate;
253        }
254    
255        /**
256         * Sets the accountDelegate attribute value.
257         * 
258         * @param accountDelegate The accountDelegate to set.
259         */
260        public void setAccountDelegate(Person accountDelegate) {
261            this.accountDelegate = accountDelegate;
262        }
263    
264        /**
265         * This method (a hack by any other name...) returns a string so that an Account Delegate can have a link to view its own
266         * inquiry page after a look up
267         * 
268         * @return the String "View Account Delegate"
269         */
270        public String getAccountDelegateViewer() {
271            return "View Account Delegate";
272        }
273    
274        /**
275         * Gets the chart attribute.
276         * 
277         * @return Returns the chart.
278         */
279        public Chart getChart() {
280            return chart;
281        }
282    
283        /**
284         * Sets the chart attribute value.
285         * 
286         * @param chart The chart to set.
287         */
288        public void setChart(Chart chart) {
289            this.chart = chart;
290        }
291    
292        /**
293         * @see java.lang.Object#equals(java.lang.Object)
294         */
295        public boolean equals(Object obj) {
296            if (obj != null) {
297                if (this.getClass().equals(obj.getClass())) {
298                    AccountDelegate other = (AccountDelegate) obj;
299                    if (StringUtils.equalsIgnoreCase(this.chartOfAccountsCode, other.chartOfAccountsCode)) {
300                        if (StringUtils.equalsIgnoreCase(this.accountNumber, other.accountNumber)) {
301                            if (StringUtils.equalsIgnoreCase(this.financialDocumentTypeCode, other.financialDocumentTypeCode)) {
302                                if (StringUtils.equalsIgnoreCase(this.accountDelegateSystemId, other.accountDelegateSystemId)) {
303                                    return true;
304                                }
305                            }
306                        }
307                    }
308                }
309            }
310            return false;
311        }
312    
313        /**
314         * @see java.lang.Object#hashCode()
315         */
316        public int hashCode() {
317            return toStringBuilder(toStringMapper()).hashCode();
318        }
319    
320        /**
321         * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
322         */
323        protected LinkedHashMap toStringMapper() {
324            LinkedHashMap m = new LinkedHashMap();
325    
326            m.put("chartCode", this.chartOfAccountsCode);
327            m.put("accountNumber", this.accountNumber);
328            m.put("documentTypeCode", this.financialDocumentTypeCode);
329            m.put("accountDelegateSystemId", this.accountDelegateSystemId);
330    
331            return m;
332        }
333    }
334