001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.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/ecl1.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.module.chart.bo;
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.core.bo.GlobalBusinessObjectDetailBase;
026: import org.kuali.core.service.PersistenceStructureService;
027: import org.kuali.core.util.ObjectUtils;
028: import org.kuali.kfs.KFSPropertyConstants;
029: import org.kuali.kfs.context.SpringContext;
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
038: .getLogger(AccountGlobalDetail.class);
039:
040: private String chartOfAccountsCode;
041: private String accountNumber;
042:
043: // jkeller: made these transient to prevent post processor serialization errors
044: transient private Chart chartOfAccounts;
045: transient private Account account;
046:
047: /**
048: * Default constructor.
049: */
050: public AccountGlobalDetail() {
051:
052: }
053:
054: /**
055: * Returns a map of the keys<propName,value> based on the primary key names of the underlying BO and reflecting into this
056: * object.
057: */
058: public Map<String, Object> getPrimaryKeys() {
059: try {
060: List<String> keys = SpringContext.getBean(
061: PersistenceStructureService.class).getPrimaryKeys(
062: Account.class);
063: HashMap<String, Object> pks = new HashMap<String, Object>(
064: keys.size());
065: for (String key : keys) {
066: // attempt to read the property of the current object
067: // this requires that the field names match between the underlying BO object
068: // and this object
069: pks.put(key, ObjectUtils.getPropertyValue(this , key));
070: }
071: return pks;
072: } catch (Exception ex) {
073: LOG
074: .error(
075: "unable to get primary keys for global detail object",
076: ex);
077: }
078: return new HashMap<String, Object>(0);
079: }
080:
081: public AccountGlobalDetail(String chartOfAccountsCode,
082: String accountNumber) {
083: this .chartOfAccountsCode = chartOfAccountsCode;
084: this .accountNumber = accountNumber;
085: }
086:
087: /**
088: * Gets the chartOfAccountsCode attribute.
089: *
090: * @return Returns the chartOfAccountsCode
091: */
092: public String getChartOfAccountsCode() {
093: return chartOfAccountsCode;
094: }
095:
096: /**
097: * Sets the chartOfAccountsCode attribute.
098: *
099: * @param chartOfAccountsCode The chartOfAccountsCode to set.
100: */
101: public void setChartOfAccountsCode(String chartOfAccountsCode) {
102: this .chartOfAccountsCode = chartOfAccountsCode;
103: }
104:
105: /**
106: * Gets the accountNumber attribute.
107: *
108: * @return Returns the accountNumber
109: */
110: public String getAccountNumber() {
111: return accountNumber;
112: }
113:
114: /**
115: * Sets the accountNumber attribute.
116: *
117: * @param accountNumber The accountNumber to set.
118: */
119: public void setAccountNumber(String accountNumber) {
120: this .accountNumber = accountNumber;
121: }
122:
123: /**
124: * Gets the chartOfAccounts attribute.
125: *
126: * @return Returns the chartOfAccounts
127: */
128: public Chart getChartOfAccounts() {
129: return chartOfAccounts;
130: }
131:
132: /**
133: * Sets the chartOfAccounts attribute.
134: *
135: * @param chartOfAccounts The chartOfAccounts to set.
136: * @deprecated
137: */
138: public void setChartOfAccounts(Chart chartOfAccounts) {
139: this .chartOfAccounts = chartOfAccounts;
140: }
141:
142: /**
143: * Gets the account attribute.
144: *
145: * @return Returns the account
146: */
147: public Account getAccount() {
148: return account;
149: }
150:
151: /**
152: * Sets the account attribute.
153: *
154: * @param account The account to set.
155: * @deprecated
156: */
157: public void setAccount(Account account) {
158: this .account = account;
159: }
160:
161: /**
162: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
163: */
164: protected LinkedHashMap toStringMapper() {
165: LinkedHashMap m = new LinkedHashMap();
166: m
167: .put(KFSPropertyConstants.DOCUMENT_NUMBER,
168: getDocumentNumber());
169: m.put("chartOfAccountsCode", this .chartOfAccountsCode);
170: m.put("accountNumber", this.accountNumber);
171: return m;
172: }
173: }
|