001 /*
002 * Copyright 2011 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
017 package org.kuali.kfs.coa.businessobject;
018
019 import java.sql.Date;
020 import java.util.LinkedHashMap;
021
022 import org.apache.commons.lang.StringUtils;
023 import org.kuali.kfs.sys.KFSPropertyConstants;
024 import org.kuali.kfs.sys.context.SpringContext;
025 import org.kuali.rice.kew.doctype.bo.DocumentTypeEBO;
026 import org.kuali.rice.kew.service.impl.KEWModuleService;
027 import org.kuali.rice.kim.bo.Person;
028 import org.kuali.rice.kim.service.PersonService;
029 import org.kuali.rice.kns.bo.GlobalBusinessObjectDetailBase;
030 import org.kuali.rice.kns.util.KualiDecimal;
031 import org.kuali.rice.kns.util.ObjectUtils;
032
033 /**
034 *
035 */
036 public class AccountDelegateGlobalDetail extends GlobalBusinessObjectDetailBase {
037
038 private static final long serialVersionUID = -8089154029664644867L;
039
040 private String accountDelegateUniversalId;
041 private String financialDocumentTypeCode;
042 private KualiDecimal approvalFromThisAmount;
043 private KualiDecimal approvalToThisAmount;
044 private boolean accountDelegatePrimaryRoutingIndicator;
045 private Date accountDelegateStartDate;
046
047 private Person accountDelegate;
048 private transient DocumentTypeEBO financialSystemDocumentTypeCode;
049
050 /**
051 * Default constructor.
052 */
053 public AccountDelegateGlobalDetail() {
054 super();
055 }
056
057 public AccountDelegateGlobalDetail(AccountDelegateModelDetail model) {
058 accountDelegatePrimaryRoutingIndicator = model.getAccountDelegatePrimaryRoutingIndicator();
059 accountDelegateStartDate = model.getAccountDelegateStartDate();
060 accountDelegateUniversalId = model.getAccountDelegateUniversalId();
061 approvalFromThisAmount = model.getApprovalFromThisAmount();
062 approvalToThisAmount = model.getApprovalToThisAmount();
063 financialDocumentTypeCode = model.getFinancialDocumentTypeCode();
064 }
065
066 /**
067 * Gets the financialSystemDocumentTypeCode attribute.
068 * @return Returns the financialSystemDocumentTypeCode.
069 */
070 public DocumentTypeEBO getFinancialSystemDocumentTypeCode() {
071 return financialSystemDocumentTypeCode = SpringContext.getBean(KEWModuleService.class).retrieveExternalizableBusinessObjectIfNecessary(this, financialSystemDocumentTypeCode, "financialSystemDocumentTypeCode");
072 }
073
074 /**
075 * Gets the accountDelegateUniversalId attribute.
076 *
077 * @return Returns the accountDelegateUniversalId
078 */
079 public String getAccountDelegateUniversalId() {
080 return accountDelegateUniversalId;
081 }
082
083 /**
084 * Sets the accountDelegateUniversalId attribute.
085 *
086 * @param accountDelegateUniversalId The accountDelegateUniversalId to set.
087 */
088 public void setAccountDelegateUniversalId(String accountDelegateUniversalId) {
089 this.accountDelegateUniversalId = accountDelegateUniversalId;
090 }
091
092 /**
093 * Gets the financialDocumentTypeCode attribute.
094 *
095 * @return Returns the financialDocumentTypeCode
096 */
097 public String getFinancialDocumentTypeCode() {
098 return financialDocumentTypeCode;
099 }
100
101 /**
102 * Sets the financialDocumentTypeCode attribute.
103 *
104 * @param financialDocumentTypeCode The financialDocumentTypeCode to set.
105 */
106 public void setFinancialDocumentTypeCode(String financialDocumentTypeCode) {
107 this.financialDocumentTypeCode = financialDocumentTypeCode;
108 }
109
110
111 /**
112 * Gets the approvalFromThisAmount attribute.
113 *
114 * @return Returns the approvalFromThisAmount
115 */
116 public KualiDecimal getApprovalFromThisAmount() {
117 return approvalFromThisAmount;
118 }
119
120 /**
121 * Sets the approvalFromThisAmount attribute.
122 *
123 * @param approvalFromThisAmount The approvalFromThisAmount to set.
124 */
125 public void setApprovalFromThisAmount(KualiDecimal approvalFromThisAmount) {
126 this.approvalFromThisAmount = approvalFromThisAmount;
127 }
128
129
130 /**
131 * Gets the approvalToThisAmount attribute.
132 *
133 * @return Returns the approvalToThisAmount
134 */
135 public KualiDecimal getApprovalToThisAmount() {
136 return approvalToThisAmount;
137 }
138
139 /**
140 * Sets the approvalToThisAmount attribute.
141 *
142 * @param approvalToThisAmount The approvalToThisAmount to set.
143 */
144 public void setApprovalToThisAmount(KualiDecimal approvalToThisAmount) {
145 this.approvalToThisAmount = approvalToThisAmount;
146 }
147
148
149 /**
150 * Gets the accountDelegatePrimaryRoutingIndicator attribute.
151 *
152 * @return Returns the accountDelegatePrimaryRoutingIndicator
153 */
154 public boolean getAccountDelegatePrimaryRoutingIndicator() {
155 return accountDelegatePrimaryRoutingIndicator;
156 }
157
158 /**
159 * Sets the accountDelegatePrimaryRoutingIndicator attribute.
160 *
161 * @param accountDelegatePrimaryRoutingIndicator The accountDelegatePrimaryRoutingIndicator to set.
162 * @deprecated
163 */
164 public void setAccountDelegatePrimaryRoutingIndicator(boolean accountDelegatePrimaryRoutingIndicator) {
165 this.accountDelegatePrimaryRoutingIndicator = accountDelegatePrimaryRoutingIndicator;
166 }
167
168
169 /**
170 * Gets the accountDelegateStartDate attribute.
171 *
172 * @return Returns the accountDelegateStartDate
173 */
174 public Date getAccountDelegateStartDate() {
175 return accountDelegateStartDate;
176 }
177
178 /**
179 * Sets the accountDelegateStartDate attribute.
180 *
181 * @param accountDelegateStartDate The accountDelegateStartDate to set.
182 */
183 public void setAccountDelegateStartDate(Date accountDelegateStartDate) {
184 this.accountDelegateStartDate = accountDelegateStartDate;
185 }
186
187 public Person getAccountDelegate() {
188 accountDelegate = SpringContext.getBean(PersonService.class).updatePersonIfNecessary(accountDelegateUniversalId, accountDelegate);
189 return accountDelegate;
190 }
191
192 /**
193 * @param accountDelegate The accountDelegate to set.
194 * @deprecated
195 */
196 public void setAccountDelegate(Person accountDelegate) {
197 this.accountDelegate = accountDelegate;
198 }
199
200 /**
201 * @see java.lang.Object#equals(java.lang.Object)
202 */
203 public boolean equals(Object obj) {
204 if (obj != null) {
205 if (this.getClass().equals(obj.getClass())) {
206 AccountDelegateGlobalDetail other = (AccountDelegateGlobalDetail) obj;
207 if (StringUtils.equalsIgnoreCase(getDocumentNumber(), other.getDocumentNumber())) {
208 if (StringUtils.equalsIgnoreCase(this.financialDocumentTypeCode, other.financialDocumentTypeCode)) {
209 if (this.accountDelegatePrimaryRoutingIndicator == other.accountDelegatePrimaryRoutingIndicator) {
210 if (StringUtils.equalsIgnoreCase(this.accountDelegateUniversalId, other.accountDelegateUniversalId)) {
211 return true;
212 }
213 }
214 }
215 }
216 }
217 }
218 return false;
219 }
220
221 /**
222 * @see java.lang.Object#hashCode()
223 */
224 public int hashCode() {
225 return toStringBuilder(toStringMapper()).hashCode();
226 }
227
228 /**
229 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
230 */
231 protected LinkedHashMap toStringMapper() {
232 LinkedHashMap m = new LinkedHashMap();
233 m.put(KFSPropertyConstants.DOCUMENT_NUMBER, getDocumentNumber());
234 m.put("accountDelegateUniversalId", this.accountDelegateUniversalId);
235 m.put("financialDocumentTypeCode", this.financialDocumentTypeCode);
236 return m;
237 }
238 }
239