View Javadoc
1   /*
2    * Copyright 2007 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.coa.businessobject;
18  
19  import java.util.HashMap;
20  import java.util.LinkedHashMap;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.apache.log4j.Logger;
25  import org.kuali.ole.sys.OLEPropertyConstants;
26  import org.kuali.ole.sys.context.SpringContext;
27  import org.kuali.rice.krad.bo.GlobalBusinessObjectDetailBase;
28  import org.kuali.rice.krad.service.PersistenceStructureService;
29  import org.kuali.rice.krad.util.ObjectUtils;
30  
31  /**
32   * Business Object representing the account change details entity
33   */
34  public class AccountGlobalDetail extends GlobalBusinessObjectDetailBase {
35  
36      private static final long serialVersionUID = -6329389744704772474L;
37      private static final Logger LOG = Logger.getLogger(AccountGlobalDetail.class);
38  
39      private String chartOfAccountsCode;
40      private String accountNumber;
41  
42      // jkeller: made these transient to prevent post processor serialization errors
43      transient private Chart chartOfAccounts;
44      transient private Account account;
45  
46      /**
47       * Default constructor.
48       */
49      public AccountGlobalDetail() {
50  
51      }
52  
53      /**
54       * Returns a map of the keys<propName,value> based on the primary key names of the underlying BO and reflecting into this
55       * object.
56       */
57      public Map<String, Object> getPrimaryKeys() {
58          try {
59              List<String> keys = SpringContext.getBean(PersistenceStructureService.class).getPrimaryKeys(Account.class);
60              HashMap<String, Object> pks = new HashMap<String, Object>(keys.size());
61              for (String key : keys) {
62                  // attempt to read the property of the current object
63                  // this requires that the field names match between the underlying BO object
64                  // and this object
65                  pks.put(key, ObjectUtils.getPropertyValue(this, key));
66              }
67              return pks;
68          }
69          catch (Exception ex) {
70              LOG.error("unable to get primary keys for global detail object", ex);
71          }
72          return new HashMap<String, Object>(0);
73      }
74  
75      public AccountGlobalDetail(String chartOfAccountsCode, String accountNumber) {
76          this.chartOfAccountsCode = chartOfAccountsCode;
77          this.accountNumber = accountNumber;
78      }
79  
80      /**
81       * Gets the chartOfAccountsCode attribute.
82       * 
83       * @return Returns the chartOfAccountsCode
84       */
85      public String getChartOfAccountsCode() {
86          return chartOfAccountsCode;
87      }
88  
89      /**
90       * Sets the chartOfAccountsCode attribute.
91       * 
92       * @param chartOfAccountsCode The chartOfAccountsCode to set.
93       */
94      public void setChartOfAccountsCode(String chartOfAccountsCode) {
95          this.chartOfAccountsCode = chartOfAccountsCode;
96      }
97  
98  
99      /**
100      * Gets the accountNumber attribute.
101      * 
102      * @return Returns the accountNumber
103      */
104     public String getAccountNumber() {
105         return accountNumber;
106     }
107 
108     /**
109      * Sets the accountNumber attribute.
110      * 
111      * @param accountNumber The accountNumber to set.
112      */
113     public void setAccountNumber(String accountNumber) {
114         this.accountNumber = accountNumber;
115     }
116 
117     /**
118      * Gets the chartOfAccounts attribute.
119      * 
120      * @return Returns the chartOfAccounts
121      */
122     public Chart getChartOfAccounts() {
123         return chartOfAccounts;
124     }
125 
126     /**
127      * Sets the chartOfAccounts attribute.
128      * 
129      * @param chartOfAccounts The chartOfAccounts to set.
130      * @deprecated
131      */
132     public void setChartOfAccounts(Chart chartOfAccounts) {
133         this.chartOfAccounts = chartOfAccounts;
134     }
135 
136     /**
137      * Gets the account attribute.
138      * 
139      * @return Returns the account
140      */
141     public Account getAccount() {
142         return account;
143     }
144 
145     /**
146      * Sets the account attribute.
147      * 
148      * @param account The account to set.
149      * @deprecated
150      */
151     public void setAccount(Account account) {
152         this.account = account;
153     }
154 
155     /**
156      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
157      */
158     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
159         LinkedHashMap m = new LinkedHashMap();
160         m.put(OLEPropertyConstants.DOCUMENT_NUMBER, getDocumentNumber());
161         m.put("chartOfAccountsCode", this.chartOfAccountsCode);
162         m.put("accountNumber", this.accountNumber);
163         return m;
164     }
165 }