001 /**
002 * Copyright 2004-2013 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 package org.kuali.kfs.coa.businessobject;
017
018 import java.util.LinkedHashMap;
019
020 import org.apache.commons.lang.StringUtils;
021 import org.apache.log4j.Logger;
022 import org.kuali.rice.core.api.mo.common.active.Inactivatable;
023 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
024
025 /**
026 *
027 */
028 public class Organization extends PersistableBusinessObjectBase implements Inactivatable {
029 private static final Logger LOG = Logger.getLogger(Organization.class);
030
031 private static final long serialVersionUID = 121873645110037203L;
032
033 /**
034 * Default no-arg constructor.
035 */
036
037 private String organizationCode;
038 private String organizationName;
039 private Chart chartOfAccounts;
040 private boolean active;
041
042 // fields for mixed anonymous keys
043 private String chartOfAccountsCode;
044
045 /**
046 * Gets the organizationCode attribute.
047 *
048 * @return Returns the organizationCode
049 */
050 public String getOrganizationCode() {
051 return organizationCode;
052 }
053
054 /**
055 * Sets the organizationCode attribute.
056 *
057 * @param organizationCode The organizationCode to set.
058 */
059 public void setOrganizationCode(String organizationCode) {
060 this.organizationCode = organizationCode;
061 }
062
063 /**
064 * Gets the organizationName attribute.
065 *
066 * @return Returns the organizationName
067 */
068 public String getOrganizationName() {
069 return organizationName;
070 }
071
072 /**
073 * Sets the organizationName attribute.
074 *
075 * @param organizationName The organizationName to set.
076 */
077 public void setOrganizationName(String organizationName) {
078 this.organizationName = organizationName;
079 }
080
081
082
083 /**
084 * Gets the chartOfAccounts attribute.
085 *
086 * @return Returns the chartOfAccounts
087 */
088 public Chart getChartOfAccounts() {
089 return chartOfAccounts;
090 }
091
092 /**
093 * Sets the chartOfAccounts attribute.
094 *
095 * @param chartOfAccounts The chartOfAccounts to set.
096 * @deprecated
097 */
098 public void setChartOfAccounts(Chart chartOfAccounts) {
099 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 }