1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.businessobject;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.select.OleSelectConstant;
20 import org.kuali.ole.select.lookup.DocData;
21 import org.kuali.ole.sys.context.SpringContext;
22 import org.kuali.rice.kew.api.document.Document;
23 import org.kuali.rice.kew.api.document.attribute.DocumentAttribute;
24 import org.kuali.rice.kew.api.document.search.DocumentSearchResult;
25 import org.kuali.rice.kim.api.identity.PersonService;
26 import org.kuali.rice.krad.bo.BusinessObjectBase;
27
28 import java.lang.reflect.Method;
29 import java.util.Date;
30 import java.util.List;
31
32
33
34
35 public class OleAcquisitionSearchResult extends BusinessObjectBase {
36
37 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OleAcquisitionSearchResult.class);
38
39 private String organizationDocumentNumber;
40 private String financialDocumentTypeCode;
41 private String documentDescription;
42 private String applicationDocumentStatus;
43 private String initiator;
44 private Date dateCreated;
45 private String purapDocumentIdentifier;
46 private String itemTitleId;
47 private String title;
48 private String author;
49 private String publisher;
50 private String isbn;
51 private String localIdentifier;
52 private PersonService personService;
53
54
55
56
57
58
59 public String getOrganizationDocumentNumber() {
60 return organizationDocumentNumber;
61 }
62
63
64
65
66
67
68 public void setOrganizationDocumentNumber(String organizationDocumentNumber) {
69 this.organizationDocumentNumber = organizationDocumentNumber;
70 }
71
72
73
74
75
76
77 public String getFinancialDocumentTypeCode() {
78 return financialDocumentTypeCode;
79 }
80
81 public String getLocalIdentifier() {
82 return localIdentifier;
83 }
84
85 public void setLocalIdentifier(String localIdentifier) {
86 this.localIdentifier = localIdentifier;
87 }
88
89
90
91
92
93
94 public void setFinancialDocumentTypeCode(String financialDocumentTypeCode) {
95 this.financialDocumentTypeCode = financialDocumentTypeCode;
96 }
97
98
99
100
101
102
103 public String getDocumentDescription() {
104 return documentDescription;
105 }
106
107
108
109
110
111
112 public void setDocumentDescription(String documentDescription) {
113 this.documentDescription = documentDescription;
114 }
115
116
117
118
119
120
121 public String getApplicationDocumentStatus() {
122 return applicationDocumentStatus;
123 }
124
125
126
127
128
129
130 public void setApplicationDocumentStatus(String applicationDocumentStatus) {
131 this.applicationDocumentStatus = applicationDocumentStatus;
132 }
133
134
135
136
137
138
139 public String getInitiator() {
140 return initiator;
141 }
142
143
144
145
146
147
148 public void setInitiator(String initiator) {
149 this.initiator = initiator;
150 }
151
152
153
154
155
156
157 public Date getDateCreated() {
158 return dateCreated;
159 }
160
161
162
163
164
165
166 public void setDateCreated(Date dateCreated) {
167 this.dateCreated = dateCreated;
168 }
169
170
171
172
173
174
175 public String getPurapDocumentIdentifier() {
176 return purapDocumentIdentifier;
177 }
178
179
180
181
182
183
184 public void setPurapDocumentIdentifier(String purapDocumentIdentifier) {
185 this.purapDocumentIdentifier = purapDocumentIdentifier;
186 }
187
188
189
190
191
192
193 public String getItemTitleId() {
194 return itemTitleId;
195 }
196
197
198
199
200
201
202 public void setItemTitleId(String itemTitleId) {
203 this.itemTitleId = itemTitleId;
204 }
205
206
207
208
209
210
211 public String getTitle() {
212 return title;
213 }
214
215
216
217
218
219
220 public void setTitle(String title) {
221 this.title = title;
222 }
223
224
225
226
227
228
229 public String getAuthor() {
230 return author;
231 }
232
233
234
235
236
237
238 public void setAuthor(String author) {
239 this.author = author;
240 }
241
242
243
244
245
246
247 public String getPublisher() {
248 return publisher;
249 }
250
251
252
253
254
255
256 public void setPublisher(String publisher) {
257 this.publisher = publisher;
258 }
259
260
261
262
263
264
265
266 public String getIsbn() {
267 return isbn;
268 }
269
270
271
272
273
274
275 public void setIsbn(String isbn) {
276 this.isbn = isbn;
277 }
278
279
280
281
282
283
284
285
286
287 public void setResultDetails(boolean isBibSearch, DocumentSearchResult searchResult, List<DocData> docDatas) {
288 if (LOG.isDebugEnabled()) {
289 LOG.info("Inside setResultDetails method of OleAcquisitionSearchResult");
290 }
291 Document document = searchResult.getDocument();
292 List<DocumentAttribute> documentAttributes = searchResult.getDocumentAttributes();
293 for (DocumentAttribute docAttribute : documentAttributes) {
294 String name = docAttribute.getName();
295 if (OleSelectConstant.AcquisitionsSearch.RESULT_FIELDS.contains(name)) {
296 if (name.equals(OleSelectConstant.AcquisitionsSearch.PO_ID)) {
297 name = OleSelectConstant.AcquisitionsSearch.ACQ_PO_NUMBER;
298 }
299 Method getMethod;
300 try {
301 getMethod = getSetMethod(OleAcquisitionSearchResult.class, name, new Class[]{String.class});
302 getMethod.invoke(this, docAttribute.getValue().toString());
303 } catch (Exception ex) {
304 ex.printStackTrace();
305 }
306 }
307 this.setApplicationDocumentStatus(document.getApplicationDocumentStatus());
308 this.setOrganizationDocumentNumber(document.getDocumentId());
309 this.setFinancialDocumentTypeCode(document.getDocumentTypeName());
310 this.setInitiator((SpringContext.getBean(PersonService.class)).getPerson(document.getInitiatorPrincipalId()).getPrincipalName());
311 this.setDateCreated(document.getDateCreated().toDate());
312 }
313 if (isBibSearch && docDatas.size() > 0) {
314 for (DocData docData : docDatas) {
315 if (itemTitleId != null && this.itemTitleId.equals(docData.getUniqueId())) {
316 this.setTitle(docData.getTitle());
317 this.setAuthor(docData.getAuthor());
318 this.setPublisher(docData.getPublisher());
319 this.setIsbn(docData.getIsbn());
320 this.setLocalIdentifier(docData.getLocalIdentifier());
321 }
322 }
323 }
324 if (LOG.isDebugEnabled()) {
325 LOG.info("Leaving setResultDetails method of OleAcquisitionSearchResult");
326 }
327 }
328
329
330
331
332
333
334
335
336
337
338 private Method getSetMethod(Class targetClass, String attr, Class[] objectAttributes) throws Exception {
339 Method method = targetClass.getMethod("set" + StringUtils.capitalize(attr), objectAttributes);
340 return method;
341 }
342
343 @Override
344 public void refresh() {
345
346
347 }
348
349 }