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