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.coa.businessobject;
018
019 import java.util.HashMap;
020 import java.util.LinkedHashMap;
021 import java.util.List;
022 import java.util.Map;
023
024 import org.apache.log4j.Logger;
025 import org.kuali.kfs.sys.KFSPropertyConstants;
026 import org.kuali.kfs.sys.context.SpringContext;
027 import org.kuali.rice.kns.bo.GlobalBusinessObjectDetailBase;
028 import org.kuali.rice.kns.service.PersistenceStructureService;
029 import org.kuali.rice.kns.util.ObjectUtils;
030
031 /**
032 * Business Object representing the account change details entity
033 */
034 public class AccountGlobalDetail extends GlobalBusinessObjectDetailBase {
035
036 private static final long serialVersionUID = -6329389744704772474L;
037 private static final Logger LOG = Logger.getLogger(AccountGlobalDetail.class);
038
039 private String chartOfAccountsCode;
040 private String accountNumber;
041
042 // jkeller: made these transient to prevent post processor serialization errors
043 transient private Chart chartOfAccounts;
044 transient private Account account;
045
046 /**
047 * Default constructor.
048 */
049 public AccountGlobalDetail() {
050
051 }
052
053 /**
054 * Returns a map of the keys<propName,value> based on the primary key names of the underlying BO and reflecting into this
055 * object.
056 */
057 public Map<String, Object> getPrimaryKeys() {
058 try {
059 List<String> keys = SpringContext.getBean(PersistenceStructureService.class).getPrimaryKeys(Account.class);
060 HashMap<String, Object> pks = new HashMap<String, Object>(keys.size());
061 for (String key : keys) {
062 // attempt to read the property of the current object
063 // this requires that the field names match between the underlying BO object
064 // and this object
065 pks.put(key, ObjectUtils.getPropertyValue(this, key));
066 }
067 return pks;
068 }
069 catch (Exception ex) {
070 LOG.error("unable to get primary keys for global detail object", ex);
071 }
072 return new HashMap<String, Object>(0);
073 }
074
075 public AccountGlobalDetail(String chartOfAccountsCode, String accountNumber) {
076 this.chartOfAccountsCode = chartOfAccountsCode;
077 this.accountNumber = accountNumber;
078 }
079
080 /**
081 * Gets the chartOfAccountsCode attribute.
082 *
083 * @return Returns the chartOfAccountsCode
084 */
085 public String getChartOfAccountsCode() {
086 return chartOfAccountsCode;
087 }
088
089 /**
090 * Sets the chartOfAccountsCode attribute.
091 *
092 * @param chartOfAccountsCode The chartOfAccountsCode to set.
093 */
094 public void setChartOfAccountsCode(String chartOfAccountsCode) {
095 this.chartOfAccountsCode = chartOfAccountsCode;
096 }
097
098
099 /**
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.kns.bo.BusinessObjectBase#toStringMapper()
157 */
158 protected LinkedHashMap toStringMapper() {
159 LinkedHashMap m = new LinkedHashMap();
160 m.put(KFSPropertyConstants.DOCUMENT_NUMBER, getDocumentNumber());
161 m.put("chartOfAccountsCode", this.chartOfAccountsCode);
162 m.put("accountNumber", this.accountNumber);
163 return m;
164 }
165 }