001package org.kuali.ole.describe.service; 002 003import org.kuali.incubator.SolrRequestReponseHandler; 004 005import java.util.List; 006 007/** 008 * DiscoveryHelperService is the service class to access Discovery services 009 */ 010public class DiscoveryHelperService { 011 private final String queryString = "DocType:bibliographic AND instanceIdentifier:"; 012 private final String bibQueryString = "DocType:bibliographic AND uniqueId:"; 013 SolrRequestReponseHandler solrRequestReponseHandler; 014 015 /** 016 * Returns the Response List based on the queryField and Value from the SolrRequestReponseHandler class. 017 * 018 * @param queryField 019 * @param value 020 * @return Returns the Response. 021 */ 022 public List getResponseFromSOLR(String queryField, String value) { 023 String queryString = queryField + ":" + value; 024 return getSolrRequestReponseHandler().retriveResults(queryString); 025 } 026 027 /** 028 * Returns the List of BibInformation records based on the instanceUUID. 029 * 030 * @param instanceUUID 031 * @return Returns BibInformation 032 */ 033 public List getBibInformationFromInsatnceId(String instanceUUID) { 034 return getSolrRequestReponseHandler().retriveResults(queryString + instanceUUID); 035 } 036 037 /** 038 * Returns the List of BibInformation records based on the BibUUID. 039 * 040 * @param bibUUID 041 * @return Returns BibInformation 042 */ 043 public List getBibInformationFromBibId(String bibUUID) { 044 return getSolrRequestReponseHandler().retriveResults(bibQueryString + bibUUID); 045 } 046 047 048 /** 049 * Returns the new instance of SolrRequestReponseHandler provided there should not be any existing instance,Otherwise returns existing instance. 050 * 051 * @return Returns the SolrRequestReponseHandler 052 */ 053 public SolrRequestReponseHandler getSolrRequestReponseHandler() { 054 if (null == solrRequestReponseHandler) { 055 solrRequestReponseHandler = new SolrRequestReponseHandler(); 056 } 057 return solrRequestReponseHandler; 058 } 059 060 /** 061 * Sets the SolrRequestReponseHandler attribute value. 062 * 063 * @param solrRequestReponseHandler 064 */ 065 public void setSolrRequestReponseHandler(SolrRequestReponseHandler solrRequestReponseHandler) { 066 this.solrRequestReponseHandler = solrRequestReponseHandler; 067 } 068}