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: package org.kuali.module.chart.bo;
017:
018: import java.lang.reflect.InvocationTargetException;
019: import java.util.LinkedHashMap;
020:
021: import org.apache.commons.beanutils.PropertyUtils;
022: import org.kuali.core.bo.GlobalBusinessObjectDetailBase;
023: import org.kuali.kfs.KFSConstants;
024: import org.kuali.kfs.KFSPropertyConstants;
025:
026: /**
027: * An organization which is related to a Global Organization Reversion Detail.
028: */
029: public class OrganizationReversionGlobalOrganization extends
030: GlobalBusinessObjectDetailBase {
031: protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
032: .getLogger(OrganizationReversionGlobalOrganization.class);
033: private String documentNumber;
034: private String chartOfAccountsCode;
035: private String organizationCode;
036:
037: private Chart chartOfAccounts;
038: private Org organization;
039:
040: /**
041: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
042: */
043: @Override
044: protected LinkedHashMap toStringMapper() {
045: LinkedHashMap stringMapper = new LinkedHashMap();
046: stringMapper.put(KFSPropertyConstants.DOCUMENT_NUMBER,
047: this .documentNumber);
048: stringMapper.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE,
049: this .chartOfAccountsCode);
050: stringMapper.put(KFSPropertyConstants.ORGANIZATION_CODE,
051: this .organizationCode);
052: return stringMapper;
053: }
054:
055: /**
056: * Constructs a OrganizationReversionGlobalOrganization
057: */
058: public OrganizationReversionGlobalOrganization() {
059: super ();
060: }
061:
062: /**
063: * Gets the documentNumber attribute.
064: *
065: * @return Returns the documentNumber.
066: */
067: public String getDocumentNumber() {
068: return documentNumber;
069: }
070:
071: /**
072: * Sets the documentNumber attribute value.
073: *
074: * @param documentNumber The documentNumber to set.
075: */
076: public void setDocumentNumber(String documentNumber) {
077: this .documentNumber = documentNumber;
078: }
079:
080: /**
081: * Gets the chartOfAccounts attribute.
082: *
083: * @return Returns the chartOfAccounts.
084: */
085: public Chart getChartOfAccounts() {
086: return chartOfAccounts;
087: }
088:
089: /**
090: * Sets the chartOfAccounts attribute value.
091: *
092: * @param chartOfAccounts The chartOfAccounts to set.
093: * @deprecated
094: */
095: public void setChartOfAccounts(Chart chartOfAccounts) {
096: this .chartOfAccounts = chartOfAccounts;
097: }
098:
099: /**
100: * Gets the chartOfAccountsCode attribute.
101: *
102: * @return Returns the chartOfAccountsCode.
103: */
104: public String getChartOfAccountsCode() {
105: return chartOfAccountsCode;
106: }
107:
108: /**
109: * Sets the chartOfAccountsCode attribute value.
110: *
111: * @param chartOfAccountsCode The chartOfAccountsCode to set.
112: */
113: public void setChartOfAccountsCode(String chartOfAccountsCode) {
114: this .chartOfAccountsCode = chartOfAccountsCode;
115: }
116:
117: /**
118: * Gets the organization attribute.
119: *
120: * @return Returns the organization.
121: */
122: public Org getOrganization() {
123: return organization;
124: }
125:
126: /**
127: * Sets the organization attribute value.
128: *
129: * @param organization The organization to set.
130: * @deprecated
131: */
132: public void setOrganization(Org organization) {
133: this .organization = organization;
134: }
135:
136: /**
137: * Gets the organizationCode attribute.
138: *
139: * @return Returns the organizationCode.
140: */
141: public String getOrganizationCode() {
142: return organizationCode;
143: }
144:
145: /**
146: * Sets the organizationCode attribute value.
147: *
148: * @param organizationCode The organizationCode to set.
149: */
150: public void setOrganizationCode(String organizationCode) {
151: this .organizationCode = organizationCode;
152: }
153:
154: /**
155: * This utility method converts the name of a property into a string suitable for being part of a locking representation.
156: *
157: * @param keyName the name of the property to convert to a locking representation
158: * @return a part of a locking representation
159: */
160: private String convertKeyToLockingRepresentation(String keyName) {
161: StringBuffer sb = new StringBuffer();
162: sb.append(keyName);
163: sb.append(KFSConstants.Maintenance.AFTER_FIELDNAME_DELIM);
164: String keyValue = "";
165: try {
166: Object keyValueObj = PropertyUtils.getProperty(this ,
167: keyName);
168: if (keyValueObj != null) {
169: keyValue = keyValueObj.toString();
170: }
171: } catch (IllegalAccessException iae) {
172: LOG.info(
173: "Illegal access exception while attempting to read property "
174: + keyName, iae);
175: } catch (InvocationTargetException ite) {
176: LOG.info(
177: "Illegal Target Exception while attempting to read property "
178: + keyName, ite);
179: } catch (NoSuchMethodException nsme) {
180: LOG.info("There is no such method to read property "
181: + keyName + " in this class.", nsme);
182: } finally {
183: sb.append(keyValue);
184: }
185: sb.append(KFSConstants.Maintenance.AFTER_VALUE_DELIM);
186: return sb.toString();
187: }
188:
189: /**
190: * @see java.lang.Object#hashCode()
191: */
192: @Override
193: public int hashCode() {
194: final int PRIME = 31;
195: int result = 1;
196: result = PRIME
197: * result
198: + ((this .getChartOfAccountsCode() == null) ? 0 : this
199: .getChartOfAccountsCode().hashCode());
200: result = PRIME
201: * result
202: + ((this .getDocumentNumber() == null) ? 0 : this
203: .getDocumentNumber().hashCode());
204: result = PRIME
205: * result
206: + ((this .getOrganizationCode() == null) ? 0 : this
207: .getOrganizationCode().hashCode());
208: return result;
209: }
210:
211: /**
212: * @see java.lang.Object#equals(java.lang.Object)
213: */
214: @Override
215: public boolean equals(Object obj) {
216: if (this == obj)
217: return true;
218: if (obj == null)
219: return false;
220: if (getClass() != obj.getClass())
221: return false;
222: final OrganizationReversionGlobalOrganization other = (OrganizationReversionGlobalOrganization) obj;
223: if (this .getChartOfAccountsCode() == null) {
224: if (other.getChartOfAccountsCode() != null)
225: return false;
226: } else if (!this .getChartOfAccountsCode().equals(
227: other.getChartOfAccountsCode()))
228: return false;
229: if (this .getDocumentNumber() == null) {
230: if (other.getDocumentNumber() != null)
231: return false;
232: } else if (!this .getDocumentNumber().equals(
233: other.getDocumentNumber()))
234: return false;
235: if (this .getOrganizationCode() == null) {
236: if (other.getOrganizationCode() != null)
237: return false;
238: } else if (!this .getOrganizationCode().equals(
239: other.getOrganizationCode()))
240: return false;
241: return true;
242: }
243:
244: }
|