View Javadoc

1   /**
2    * Copyright 2004-2012 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.kfs.coa.businessobject;
17  
18  import java.util.LinkedHashMap;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.apache.log4j.Logger;
22  import org.kuali.rice.core.api.mo.common.active.Inactivatable;
23  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
24  
25  /**
26   * 
27   */
28  public class Organization extends PersistableBusinessObjectBase implements Inactivatable {
29      private static final Logger LOG = Logger.getLogger(Organization.class);
30  
31      private static final long serialVersionUID = 121873645110037203L;
32  
33      /**
34       * Default no-arg constructor.
35       */
36  
37      private String organizationCode;
38      private String organizationName;
39      private Chart chartOfAccounts;
40      private boolean active;
41      
42      // fields for mixed anonymous keys
43      private String chartOfAccountsCode;
44  
45      /**
46       * Gets the organizationCode attribute.
47       * 
48       * @return Returns the organizationCode
49       */
50      public String getOrganizationCode() {
51          return organizationCode;
52      }
53  
54      /**
55       * Sets the organizationCode attribute.
56       * 
57       * @param organizationCode The organizationCode to set.
58       */
59      public void setOrganizationCode(String organizationCode) {
60          this.organizationCode = organizationCode;
61      }
62  
63      /**
64       * Gets the organizationName attribute.
65       * 
66       * @return Returns the organizationName
67       */
68      public String getOrganizationName() {
69          return organizationName;
70      }
71  
72      /**
73       * Sets the organizationName attribute.
74       * 
75       * @param organizationName The organizationName to set.
76       */
77      public void setOrganizationName(String organizationName) {
78          this.organizationName = organizationName;
79      }
80  
81      
82  
83      /**
84       * Gets the chartOfAccounts attribute.
85       * 
86       * @return Returns the chartOfAccounts
87       */
88      public Chart getChartOfAccounts() {
89          return chartOfAccounts;
90      }
91  
92      /**
93       * Sets the chartOfAccounts attribute.
94       * 
95       * @param chartOfAccounts The chartOfAccounts to set.
96       * @deprecated
97       */
98      public void setChartOfAccounts(Chart chartOfAccounts) {
99          this.chartOfAccounts = chartOfAccounts;
100     }
101 
102     /**
103      * Gets the chartOfAccountsCode attribute.
104      * 
105      * @return Returns the chartOfAccountsCode.
106      */
107     public String getChartOfAccountsCode() {
108         return chartOfAccountsCode;
109     }
110 
111     /**
112      * Sets the chartOfAccountsCode attribute value.
113      * 
114      * @param chartOfAccountsCode The chartOfAccountsCode to set.
115      */
116     public void setChartOfAccountsCode(String chartOfAccountsCode) {
117         this.chartOfAccountsCode = chartOfAccountsCode;
118     }
119 
120     
121     /**
122      * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
123      */
124     protected LinkedHashMap toStringMapper() {
125         LinkedHashMap m = new LinkedHashMap();
126 
127         m.put("chartOfAccountsCode", this.chartOfAccountsCode);
128         m.put("organizationCode", this.organizationCode);
129 
130         return m;
131     }
132 
133     /**
134    
135 
136     public String getOrganizationReviewHierarchy() {
137 
138         Properties params = new Properties();
139         params.put("methodToCall", "start");
140         params.put("docFormKey", "");
141         params.put("lookupableImplServiceName", "RuleBaseValuesLookupableImplService");
142         params.put("fin_coa_cd", this.chartOfAccountsCode);
143         params.put("org_cd", this.organizationCode);
144         params.put("conversionFields", "");
145         params.put("returnLocation", "");
146         params.put("active_ind", "true");
147         params.put("ruleTemplateName", "KualiOrgReviewTemplate");
148 
149         return UrlFactory.parameterizeUrl(SpringContext.getBean(KualiConfigurationService.class).getPropertyString(KFSConstants.WORKFLOW_URL_KEY) + "/Lookup.do", params);
150     }
151 
152     /**
153      * Implementing equals so Org will behave reasonably in a hashed datastructure.
154      * 
155      * @see java.lang.Object#equals(java.lang.Object)
156      */
157     public boolean equals(Object obj) {
158         boolean equal = false;
159 
160         LOG.debug("Org equals");
161 
162         if (obj != null) {
163 
164             if (this == obj)
165                 return true;
166 
167             if (this.getClass().isAssignableFrom(obj.getClass())) {
168 
169                 Organization other = (Organization) obj;
170 
171                 LOG.debug("this: " + this);
172                 LOG.debug("other: " + other);
173 
174                 if (StringUtils.equals(this.getChartOfAccountsCode(), other.getChartOfAccountsCode())) {
175                     if (StringUtils.equals(this.getOrganizationCode(), other.getOrganizationCode())) {
176                         equal = true;
177                     }
178                 }
179             }
180         }
181 
182         return equal;
183     }
184 
185     /**
186      * @return Returns the code and description in format: xx - xxxxxxxxxxxxxxxx
187      */
188     public String getCodeAndDescription() {
189         String theString = getOrganizationCode() + "-" + getOrganizationName();
190         return theString;
191     }
192 
193     /**
194      * @see java.lang.Object#hashCode()
195      */
196     public int hashCode() {
197         String hashString = getChartOfAccountsCode() + "|" + getOrganizationCode();
198         return hashString.hashCode();
199     }
200 
201     public boolean isActive() {
202         return active;
203     }
204 
205     public void setActive(boolean active) {
206         this.active = active;
207     }
208 
209 }