1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.ole.coa.businessobject;
18
19 import java.sql.Date;
20 import java.util.Arrays;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.ole.sys.OLEPropertyConstants;
24 import org.kuali.ole.sys.ObjectUtil;
25 import org.kuali.ole.sys.context.SpringContext;
26 import org.kuali.rice.core.api.util.type.KualiDecimal;
27 import org.kuali.rice.kew.api.doctype.DocumentTypeService;
28 import org.kuali.rice.kew.doctype.bo.DocumentType;
29 import org.kuali.rice.kew.doctype.bo.DocumentTypeEBO;
30 import org.kuali.rice.kim.api.identity.Person;
31 import org.kuali.rice.kim.api.identity.PersonService;
32 import org.kuali.rice.krad.bo.GlobalBusinessObjectDetailBase;
33
34
35
36
37 public class AccountDelegateGlobalDetail extends GlobalBusinessObjectDetailBase {
38
39 private static final long serialVersionUID = -8089154029664644867L;
40
41 private String accountDelegateUniversalId;
42 private String financialDocumentTypeCode;
43 private KualiDecimal approvalFromThisAmount;
44 private KualiDecimal approvalToThisAmount;
45 private boolean accountDelegatePrimaryRoutingIndicator;
46 private Date accountDelegateStartDate;
47
48 private Person accountDelegate;
49 private transient DocumentTypeEBO financialSystemDocumentTypeCode;
50
51
52
53
54 public AccountDelegateGlobalDetail() {
55 super();
56 }
57
58 public AccountDelegateGlobalDetail(AccountDelegateModelDetail model) {
59 accountDelegatePrimaryRoutingIndicator = model.getAccountDelegatePrimaryRoutingIndicator();
60 accountDelegateStartDate = model.getAccountDelegateStartDate();
61 accountDelegateUniversalId = model.getAccountDelegateUniversalId();
62 approvalFromThisAmount = model.getApprovalFromThisAmount();
63 approvalToThisAmount = model.getApprovalToThisAmount();
64 financialDocumentTypeCode = model.getFinancialDocumentTypeCode();
65 }
66
67
68
69
70
71 public DocumentTypeEBO getFinancialSystemDocumentTypeCode() {
72 if ( StringUtils.isBlank( financialDocumentTypeCode ) ) {
73 financialSystemDocumentTypeCode = null;
74 } else {
75 if ( financialSystemDocumentTypeCode == null || !StringUtils.equals(financialDocumentTypeCode, financialSystemDocumentTypeCode.getName() ) ) {
76 org.kuali.rice.kew.api.doctype.DocumentType temp = SpringContext.getBean(DocumentTypeService.class).getDocumentTypeByName(financialDocumentTypeCode);
77 if ( temp != null ) {
78 financialSystemDocumentTypeCode = DocumentType.from( temp );
79 } else {
80 financialSystemDocumentTypeCode = null;
81 }
82 }
83 }
84 return financialSystemDocumentTypeCode;
85 }
86
87
88
89
90
91
92 public String getAccountDelegateUniversalId() {
93 return accountDelegateUniversalId;
94 }
95
96
97
98
99
100
101 public void setAccountDelegateUniversalId(String accountDelegateUniversalId) {
102 this.accountDelegateUniversalId = accountDelegateUniversalId;
103 }
104
105
106
107
108
109
110 public String getFinancialDocumentTypeCode() {
111 return financialDocumentTypeCode;
112 }
113
114
115
116
117
118
119 public void setFinancialDocumentTypeCode(String financialDocumentTypeCode) {
120 this.financialDocumentTypeCode = financialDocumentTypeCode;
121 }
122
123
124
125
126
127
128
129 public KualiDecimal getApprovalFromThisAmount() {
130 return approvalFromThisAmount;
131 }
132
133
134
135
136
137
138 public void setApprovalFromThisAmount(KualiDecimal approvalFromThisAmount) {
139 this.approvalFromThisAmount = approvalFromThisAmount;
140 }
141
142
143
144
145
146
147
148 public KualiDecimal getApprovalToThisAmount() {
149 return approvalToThisAmount;
150 }
151
152
153
154
155
156
157 public void setApprovalToThisAmount(KualiDecimal approvalToThisAmount) {
158 this.approvalToThisAmount = approvalToThisAmount;
159 }
160
161
162
163
164
165
166
167 public boolean getAccountDelegatePrimaryRoutingIndicator() {
168 return accountDelegatePrimaryRoutingIndicator;
169 }
170
171
172
173
174
175
176
177 public void setAccountDelegatePrimaryRoutingIndicator(boolean accountDelegatePrimaryRoutingIndicator) {
178 this.accountDelegatePrimaryRoutingIndicator = accountDelegatePrimaryRoutingIndicator;
179 }
180
181
182
183
184
185
186
187 public Date getAccountDelegateStartDate() {
188 return accountDelegateStartDate;
189 }
190
191
192
193
194
195
196 public void setAccountDelegateStartDate(Date accountDelegateStartDate) {
197 this.accountDelegateStartDate = accountDelegateStartDate;
198 }
199
200 public Person getAccountDelegate() {
201 accountDelegate = SpringContext.getBean(PersonService.class).updatePersonIfNecessary(accountDelegateUniversalId, accountDelegate);
202 return accountDelegate;
203 }
204
205
206
207
208
209 public void setAccountDelegate(Person accountDelegate) {
210 this.accountDelegate = accountDelegate;
211 }
212
213
214
215
216 @Override
217 public boolean equals(Object obj) {
218 if (obj != null) {
219 if (this.getClass().equals(obj.getClass())) {
220 AccountDelegateGlobalDetail other = (AccountDelegateGlobalDetail) obj;
221 if (StringUtils.equalsIgnoreCase(getDocumentNumber(), other.getDocumentNumber())) {
222 if (StringUtils.equalsIgnoreCase(this.financialDocumentTypeCode, other.financialDocumentTypeCode)) {
223 if (this.accountDelegatePrimaryRoutingIndicator == other.accountDelegatePrimaryRoutingIndicator) {
224 if (StringUtils.equalsIgnoreCase(this.accountDelegateUniversalId, other.accountDelegateUniversalId)) {
225 return true;
226 }
227 }
228 }
229 }
230 }
231 }
232 return false;
233 }
234
235
236
237
238 @Override
239 public int hashCode() {
240 return ObjectUtil.generateHashCode(this, Arrays.asList(OLEPropertyConstants.DOCUMENT_NUMBER,"financialDocumentTypeCode", "accountDelegatePrimaryRoutingIndicator", "accountDelegateUniversalId" ));
241 }
242
243 }
244