1 package org.kuali.ole.service.impl;
2
3 import org.kuali.ole.ingest.OlePatronRecordHandler;
4 import org.kuali.ole.deliver.bo.OlePatronDocument;
5 import org.kuali.ole.deliver.bo.OlePatronDocuments;
6 import org.kuali.ole.service.OlePatronWebService;
7 import org.kuali.rice.krad.service.BusinessObjectService;
8 import org.kuali.rice.krad.service.KRADServiceLocator;
9
10 import java.util.ArrayList;
11 import java.util.Collection;
12 import java.util.List;
13
14
15
16
17
18
19
20
21 public class OlePatronWebServiceImpl implements OlePatronWebService {
22
23 private BusinessObjectService businessObjectService;
24 private OlePatronRecordHandler olePatronRecordHandler;
25
26
27
28
29
30
31 protected BusinessObjectService getBusinessObjectService() {
32 if (businessObjectService == null) {
33 businessObjectService = KRADServiceLocator.getBusinessObjectService();
34 }
35 return businessObjectService;
36 }
37
38 public OlePatronRecordHandler getOlePatronRecordHandler() {
39 if (null == olePatronRecordHandler) {
40 olePatronRecordHandler = new OlePatronRecordHandler();
41 }
42 return olePatronRecordHandler;
43 }
44
45
46
47
48
49 public void setOlePatronRecordHandler(OlePatronRecordHandler olePatronRecordHandler) {
50 this.olePatronRecordHandler = olePatronRecordHandler;
51 }
52
53 @Override
54 public String getPatronRecords() {
55
56 String patronXML = new String();
57 StringBuffer patronRecords = new StringBuffer();
58 OlePatronDocuments olePatronDocuments = new OlePatronDocuments();
59
60 List<OlePatronDocument> olePatronDocumentList = new ArrayList<OlePatronDocument>();
61 Collection<OlePatronDocument> olePatronDocumentRecords = getBusinessObjectService().findAll(OlePatronDocument.class);
62 for (OlePatronDocument olePatronDocument : olePatronDocumentRecords) {
63 olePatronDocument.setFirstName(olePatronDocument.getEntity().getNames().get(0).getFirstName());
64 olePatronDocument.setLastName(olePatronDocument.getEntity().getNames().get(0).getLastName());
65 olePatronDocument.setBorrowerType(olePatronDocument.getOleBorrowerType().getBorrowerTypeName());
66 olePatronDocumentList.add(olePatronDocument);
67 olePatronDocuments.setOlePatronDocuments(olePatronDocumentList);
68 }
69 patronXML = getOlePatronRecordHandler().generatePatronXML(olePatronDocuments);
70 return patronXML;
71 }
72
73 }