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 import org.kuali.ole.sys.OLEConstants;
24 import org.kuali.ole.sys.OLEKeyConstants;
25 import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
26 import org.kuali.rice.coreservice.api.parameter.Parameter;
27 import org.kuali.rice.coreservice.api.parameter.ParameterKey;
28
29 import java.util.ArrayList;
30 import java.util.List;
31
32 public class OleSelectDocumentServiceImpl implements OleSelectDocumentService {
33 private static transient OlePatronRecordHandler olePatronRecordHandler;
34
35 @Override
36 public List<OLERequestorPatronDocument> getPatronDocumentListFromWebService() {
37 List<OLERequestorPatronDocument> olePatronDocumentList = new ArrayList<OLERequestorPatronDocument>();
38 OlePatronDocuments olePatronDocument = getPatronObjectsFromWebService();
39 if (olePatronDocument.getOlePatronDocuments() != null) {
40 for (int olePatron = 0; olePatron < olePatronDocument.getOlePatronDocuments().size(); olePatron++) {
41 olePatronDocumentList.add(olePatronDocument.getOlePatronDocuments().get(olePatron));
42 }
43 }
44 return olePatronDocumentList;
45 }
46
47 private OlePatronDocuments getPatronObjectsFromWebService() {
48 OlePatronDocuments olePatronDocuments = new OlePatronDocuments();
49
50 OlePatronWebServiceImpl olePatronWebService = new OlePatronWebServiceImpl();
51 String patronRecords = olePatronWebService.getPatronRecords();
52 olePatronDocuments = getOlePatronRecordHandler().retrievePatronFromXML(patronRecords);
53 return olePatronDocuments;
54 }
55
56 @Override
57 public String getPatronName(List<OLERequestorPatronDocument> olePatronDocumentList, String requestorId) {
58 StringBuffer patronName = new StringBuffer();
59 for (OLERequestorPatronDocument olePatronDocument : olePatronDocumentList) {
60 if (requestorId != null) {
61 if (requestorId.equalsIgnoreCase(olePatronDocument.getOlePatronId())) {
62 patronName.append(olePatronDocument.getLastName());
63 patronName.append(", ");
64 patronName.append(olePatronDocument.getFirstName());
65 }
66 }
67 }
68 return patronName.toString();
69 }
70
71 public OlePatronRecordHandler getOlePatronRecordHandler() {
72 if (null == olePatronRecordHandler) {
73 olePatronRecordHandler = new OlePatronRecordHandler();
74 }
75 return olePatronRecordHandler;
76 }
77
78 public String getSelectParameterValue(String parameterName){
79 ParameterKey parameterKey = ParameterKey.create(org.kuali.ole.OLEConstants.APPL_ID, org.kuali.ole.OLEConstants.SELECT_NMSPC, org.kuali.ole.OLEConstants.SELECT_CMPNT,parameterName);
80 Parameter parameter = CoreServiceApiServiceLocator.getParameterRepositoryService().getParameter(parameterKey);
81 return parameter!=null?parameter.getValue():null;
82 }
83
84
85 public void setOlePatronRecordHandler(OlePatronRecordHandler olePatronRecordHandler) {
86 this.olePatronRecordHandler = olePatronRecordHandler;
87 }
88 }