1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.select.service.impl;
17
18 import org.kuali.ole.select.OleSelectConstant;
19 import org.kuali.ole.select.businessobject.BibInfoBean;
20 import org.kuali.ole.select.service.BibInfoWrapperService;
21 import org.kuali.ole.select.service.DocStoreService;
22 import org.kuali.ole.sys.context.SpringContext;
23
24 import java.util.HashMap;
25
26 public class DocStoreServiceImpl implements DocStoreService {
27 protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocStoreServiceImpl.class);
28 private BibInfoBean bibInfoBean;
29 private BibInfoWrapperService bibInfoWrapperService;
30 private BibInfoServiceImpl bibInfoServiceImpl;
31
32 private BibInfoBean getBibInfoBean() {
33 bibInfoBean = new BibInfoBean();
34 return bibInfoBean;
35 }
36
37 public String search(String title, String author, String typeOfStandardNumber, String standardNumber) throws Exception {
38 String response = null;
39 BibInfoBean bibInfoBean = getBibInfoBean();
40 HashMap dataMap = new HashMap();
41 bibInfoBean = buildBibInfoBean(title, author, typeOfStandardNumber, standardNumber);
42 BibInfoWrapperService docStore = getBibInfoWrapperService();
43 response = docStore.getDocSearchResponse(bibInfoBean);
44 if (LOG.isDebugEnabled())
45 LOG.debug("docstore search response------------->" + response);
46 return response;
47 }
48
49 public String ingest(String title, String author, String typeOfStandardNumber, String standardNumber) throws Exception {
50 String response = null;
51 BibInfoBean bibInfoBean = getBibInfoBean();
52 HashMap dataMap = new HashMap();
53 bibInfoBean = buildBibInfoBean(title, author, typeOfStandardNumber, standardNumber);
54 BibInfoWrapperService docStore = getBibInfoWrapperService();
55 String xmlString = docStore.generateXMLStringForIngest(bibInfoBean, dataMap);
56 dataMap.put(OleSelectConstant.DOCSTORE_REQUEST_XMLSTRING, xmlString);
57 response = docStore.getDocStoreResponse(dataMap);
58 if (LOG.isDebugEnabled())
59 LOG.debug("docstore ingest response------------->" + response);
60 return response;
61 }
62
63 public String save(String bibMarcXmlString) throws Exception {
64 BibInfoBean bibInfoBean = getBibInfoBean();
65 bibInfoBean.setDocStoreOperation(OleSelectConstant.DOCSTORE_OPERATION_WEBFORM);
66 HashMap<String, String> dataMap = new HashMap<String, String>();
67 dataMap.put(OleSelectConstant.BIB_MARC_XMLSTRING, bibMarcXmlString);
68 BibInfoWrapperService docStore = getBibInfoWrapperService();
69 String titleId = docStore.generateXMLStringForIngest(bibInfoBean, dataMap);
70 return titleId;
71 }
72
73 private BibInfoBean buildBibInfoBean(String title, String author, String typeOfStandardNumber, String standardNumber) throws Exception {
74 bibInfoBean.setTitle(title);
75 bibInfoBean.setAuthor(author);
76 bibInfoBean.setTypeOfStandardNumber(typeOfStandardNumber);
77 bibInfoBean.setStandardNumber(standardNumber);
78 return bibInfoBean;
79 }
80
81 private BibInfoWrapperService getBibInfoWrapperService() {
82 if (null == bibInfoWrapperService) {
83 bibInfoWrapperService = SpringContext.getBean(BibInfoWrapperServiceImpl.class);
84 }
85 return bibInfoWrapperService;
86 }
87 }