1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.document.service.impl;
17
18 import org.kuali.ole.select.businessobject.OLERequestorPatronDocument;
19 import org.kuali.ole.select.businessobject.OlePatronDocuments;
20 import org.kuali.ole.select.businessobject.OlePatronRecordHandler;
21 import org.kuali.ole.select.document.service.OleSelectDocumentService;
22 import org.kuali.ole.service.impl.OlePatronWebServiceImpl;
23
24 import java.util.ArrayList;
25 import java.util.List;
26
27 public class OleSelectDocumentServiceImpl implements OleSelectDocumentService {
28 private static transient OlePatronRecordHandler olePatronRecordHandler;
29
30 @Override
31 public List<OLERequestorPatronDocument> getPatronDocumentListFromWebService() {
32 List<OLERequestorPatronDocument> olePatronDocumentList = new ArrayList<OLERequestorPatronDocument>();
33 OlePatronDocuments olePatronDocument = getPatronObjectsFromWebService();
34 if (olePatronDocument.getOlePatronDocuments() != null) {
35 for (int olePatron = 0; olePatron < olePatronDocument.getOlePatronDocuments().size(); olePatron++) {
36 olePatronDocumentList.add(olePatronDocument.getOlePatronDocuments().get(olePatron));
37 }
38 }
39 return olePatronDocumentList;
40 }
41
42 private OlePatronDocuments getPatronObjectsFromWebService() {
43 OlePatronDocuments olePatronDocuments = new OlePatronDocuments();
44
45 OlePatronWebServiceImpl olePatronWebService = new OlePatronWebServiceImpl();
46 String patronRecords = olePatronWebService.getPatronRecords();
47 olePatronDocuments = getOlePatronRecordHandler().retrievePatronFromXML(patronRecords);
48 return olePatronDocuments;
49 }
50
51 @Override
52 public String getPatronName(List<OLERequestorPatronDocument> olePatronDocumentList, String requestorId) {
53 StringBuffer patronName = new StringBuffer();
54 for (OLERequestorPatronDocument olePatronDocument : olePatronDocumentList) {
55 if (requestorId != null) {
56 if (requestorId.equalsIgnoreCase(olePatronDocument.getOlePatronId())) {
57 patronName.append(olePatronDocument.getLastName());
58 patronName.append(", ");
59 patronName.append(olePatronDocument.getFirstName());
60 }
61 }
62 }
63 return patronName.toString();
64 }
65
66 public OlePatronRecordHandler getOlePatronRecordHandler() {
67 if (null == olePatronRecordHandler) {
68 olePatronRecordHandler = new OlePatronRecordHandler();
69 }
70 return olePatronRecordHandler;
71 }
72
73 public void setOlePatronRecordHandler(OlePatronRecordHandler olePatronRecordHandler) {
74 this.olePatronRecordHandler = olePatronRecordHandler;
75 }
76 }