View Javadoc

1   package org.kuali.ole.serviceimpl;
2   
3   import org.kuali.ole.OleSRUConstants;
4   import org.kuali.ole.PropertyUtil;
5   import org.kuali.ole.bo.cql.CQLResponseBO;
6   import org.kuali.ole.bo.serachRetrieve.OleSRUBibDocument;
7   import org.kuali.ole.docstore.model.bo.WorkBibDocument;
8   import org.kuali.ole.docstore.model.bo.WorkHoldingsDocument;
9   import org.kuali.ole.docstore.model.bo.WorkInstanceDocument;
10  import org.kuali.ole.service.OleCQLQueryParserService;
11  import org.kuali.ole.service.OleDiagnosticsService;
12  import org.kuali.ole.service.OleSRUDataService;
13  import org.kuali.ole.service.OleSearchRetrieveOperationService;
14  
15  import java.util.List;
16  import java.util.Map;
17  
18  /**
19   * Created with IntelliJ IDEA.
20   * User: ?
21   * Date: 7/9/12
22   * Time: 6:50 PM
23   * To change this template use File | Settings | File Templates.
24   */
25  public class OleSearchRetrieveOperationServiceImpl implements OleSearchRetrieveOperationService {
26  
27      public OleSRUDataService oleSRUDataService;
28      public OleDiagnosticsService oleDiagnosticsService;
29      public OleCQLQueryParserService oleCQLQueryParserService;
30      public OleSearchRetrieveOperationServiceImpl()
31      {
32          oleSRUDataService=new OleSRUDataServiceImpl() ;
33          oleDiagnosticsService=new OleDiagnosticsServiceImpl();
34          oleCQLQueryParserService=new OleCQLQueryParserServiceImpl();
35      }
36  
37      /**
38       * it will return a OPAC response xml  ( overall xml )
39       * @param reqParamMap
40       * @param cqlParseBO
41       * @return OPAC xml response
42       */
43      public String getSearchRetriveResponse(Map reqParamMap,CQLResponseBO cqlParseBO){
44  
45         String solrQuery=getSolrQueryFromCQLParseBO(cqlParseBO);
46         if(solrQuery==null)
47             return oleDiagnosticsService.getDiagnosticResponse(PropertyUtil.getPropertyUtil().getProperty(OleSRUConstants.INVALID_QUERY_DIAGNOSTIC_MSG));
48  
49         List oleSRUBibIdList=  oleSRUDataService.getBibRecordsIdList(reqParamMap, solrQuery);
50         if(oleSRUBibIdList==null)
51             return oleDiagnosticsService.getDiagnosticResponse(PropertyUtil.getPropertyUtil().getProperty(OleSRUConstants.SERVER_DIAGNOSTIC_MSG));
52         String opacXML=   oleSRUDataService.getOPACXMLSearchRetrieveResponse(oleSRUBibIdList,reqParamMap);
53         String styleSheet = (String)reqParamMap.get(OleSRUConstants.STYLE_SHEET);
54          if(styleSheet!=null) {
55              opacXML = opacXML.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>","<?xml version=\"1.0\" encoding=\"UTF-8\"?> \n <?xml-stylesheet type=\"text/xsl\" href=\""+styleSheet+"\"?>");
56          }
57         System.out.println("opac xml response ---->  "+opacXML);
58         return opacXML;
59      }
60  
61  
62      /**.
63       * this will get the proper query from the oleCQLQueryParserService
64       * @param cqlResponseBO object
65       * @return query as a string
66       */
67      public String getSolrQueryFromCQLParseBO(CQLResponseBO cqlResponseBO){
68          String solrQuery=null;
69          solrQuery=oleCQLQueryParserService.getSolrQueryFromCQLBO(cqlResponseBO);
70          System.out.println("solr Query ------> "+solrQuery);
71          return solrQuery;
72      }
73  
74  
75  }