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  package org.kuali.ole.coa.businessobject;
17  
18  import java.lang.reflect.InvocationTargetException;
19  import java.util.LinkedHashMap;
20  
21  import org.apache.commons.beanutils.PropertyUtils;
22  import org.kuali.ole.sys.OLEConstants;
23  import org.kuali.ole.sys.OLEPropertyConstants;
24  import org.kuali.rice.krad.bo.GlobalBusinessObjectDetailBase;
25  
26  /**
27   * An organization which is related to a Global Organization Reversion Detail.
28   */
29  public class OrganizationReversionGlobalOrganization extends GlobalBusinessObjectDetailBase {
30      protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OrganizationReversionGlobalOrganization.class);
31      private String documentNumber;
32      private String chartOfAccountsCode;
33      private String organizationCode;
34  
35      private Chart chartOfAccounts;
36      private Organization organization;
37  
38      /**
39       * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
40       */
41      
42      protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
43          LinkedHashMap stringMapper = new LinkedHashMap();
44          stringMapper.put(OLEPropertyConstants.DOCUMENT_NUMBER, this.documentNumber);
45          stringMapper.put(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE, this.chartOfAccountsCode);
46          stringMapper.put(OLEPropertyConstants.ORGANIZATION_CODE, this.organizationCode);
47          return stringMapper;
48      }
49  
50      /**
51       * Constructs a OrganizationReversionGlobalOrganization
52       */
53      public OrganizationReversionGlobalOrganization() {
54          super();
55      }
56  
57      /**
58       * Gets the documentNumber attribute.
59       * 
60       * @return Returns the documentNumber.
61       */
62      public String getDocumentNumber() {
63          return documentNumber;
64      }
65  
66      /**
67       * Sets the documentNumber attribute value.
68       * 
69       * @param documentNumber The documentNumber to set.
70       */
71      public void setDocumentNumber(String documentNumber) {
72          this.documentNumber = documentNumber;
73      }
74  
75      /**
76       * Gets the chartOfAccounts attribute.
77       * 
78       * @return Returns the chartOfAccounts.
79       */
80      public Chart getChartOfAccounts() {
81          return chartOfAccounts;
82      }
83  
84      /**
85       * Sets the chartOfAccounts attribute value.
86       * 
87       * @param chartOfAccounts The chartOfAccounts to set.
88       * @deprecated
89       */
90      public void setChartOfAccounts(Chart chartOfAccounts) {
91          this.chartOfAccounts = chartOfAccounts;
92      }
93  
94      /**
95       * Gets the chartOfAccountsCode attribute.
96       * 
97       * @return Returns the chartOfAccountsCode.
98       */
99      public String getChartOfAccountsCode() {
100         return chartOfAccountsCode;
101     }
102 
103     /**
104      * Sets the chartOfAccountsCode attribute value.
105      * 
106      * @param chartOfAccountsCode The chartOfAccountsCode to set.
107      */
108     public void setChartOfAccountsCode(String chartOfAccountsCode) {
109         this.chartOfAccountsCode = chartOfAccountsCode;
110     }
111 
112     /**
113      * Gets the organization attribute.
114      * 
115      * @return Returns the organization.
116      */
117     public Organization getOrganization() {
118         return organization;
119     }
120 
121     /**
122      * Sets the organization attribute value.
123      * 
124      * @param organization The organization to set.
125      * @deprecated
126      */
127     public void setOrganization(Organization organization) {
128         this.organization = organization;
129     }
130 
131     /**
132      * Gets the organizationCode attribute.
133      * 
134      * @return Returns the organizationCode.
135      */
136     public String getOrganizationCode() {
137         return organizationCode;
138     }
139 
140     /**
141      * Sets the organizationCode attribute value.
142      * 
143      * @param organizationCode The organizationCode to set.
144      */
145     public void setOrganizationCode(String organizationCode) {
146         this.organizationCode = organizationCode;
147     }
148 
149     /**
150      * This utility method converts the name of a property into a string suitable for being part of a locking representation.
151      * 
152      * @param keyName the name of the property to convert to a locking representation
153      * @return a part of a locking representation
154      */
155     private String convertKeyToLockingRepresentation(String keyName) {
156         StringBuffer sb = new StringBuffer();
157         sb.append(keyName);
158         sb.append(OLEConstants.Maintenance.AFTER_FIELDNAME_DELIM);
159         String keyValue = "";
160         try {
161             Object keyValueObj = PropertyUtils.getProperty(this, keyName);
162             if (keyValueObj != null) {
163                 keyValue = keyValueObj.toString();
164             }
165         }
166         catch (IllegalAccessException iae) {
167             LOG.info("Illegal access exception while attempting to read property " + keyName, iae);
168         }
169         catch (InvocationTargetException ite) {
170             LOG.info("Illegal Target Exception while attempting to read property " + keyName, ite);
171         }
172         catch (NoSuchMethodException nsme) {
173             LOG.info("There is no such method to read property " + keyName + " in this class.", nsme);
174         }
175         finally {
176             sb.append(keyValue);
177         }
178         sb.append(OLEConstants.Maintenance.AFTER_VALUE_DELIM);
179         return sb.toString();
180     }
181 
182     /**
183      * @see java.lang.Object#hashCode()
184      */
185     @Override
186     public int hashCode() {
187         final int PRIME = 31;
188         int result = 1;
189         result = PRIME * result + ((this.getChartOfAccountsCode() == null) ? 0 : this.getChartOfAccountsCode().hashCode());
190         result = PRIME * result + ((this.getDocumentNumber() == null) ? 0 : this.getDocumentNumber().hashCode());
191         result = PRIME * result + ((this.getOrganizationCode() == null) ? 0 : this.getOrganizationCode().hashCode());
192         return result;
193     }
194 
195     /**
196      * @see java.lang.Object#equals(java.lang.Object)
197      */
198     @Override
199     public boolean equals(Object obj) {
200         if (this == obj)
201             return true;
202         if (obj == null)
203             return false;
204         if (getClass() != obj.getClass())
205             return false;
206         final OrganizationReversionGlobalOrganization other = (OrganizationReversionGlobalOrganization) obj;
207         if (this.getChartOfAccountsCode() == null) {
208             if (other.getChartOfAccountsCode() != null)
209                 return false;
210         }
211         else if (!this.getChartOfAccountsCode().equals(other.getChartOfAccountsCode()))
212             return false;
213         if (this.getDocumentNumber() == null) {
214             if (other.getDocumentNumber() != null)
215                 return false;
216         }
217         else if (!this.getDocumentNumber().equals(other.getDocumentNumber()))
218             return false;
219         if (this.getOrganizationCode() == null) {
220             if (other.getOrganizationCode() != null)
221                 return false;
222         }
223         else if (!this.getOrganizationCode().equals(other.getOrganizationCode()))
224             return false;
225         return true;
226     }
227 
228 }