Package org.wijiscommons.ssaf.schema.search

Examples of org.wijiscommons.ssaf.schema.search.SearchRequest


  public Document search(String solrLocation, Document document)
    throws SSAFSolrException
  {
   
    // Validate incoming XML
    SearchRequest searchRequest = validateXML(document);
   
    // Get SearchItems
    SearchItems searchItems = searchRequest.getSearchItems();
   
    // Construct searchItemList Object
    List<SearchItem> searchItemList = searchItems.getSearchItem();
   
   
    if (searchItemList != null) {
       
            Integer startOffSet =
                searchRequest.getPresentationControlParameters()
                        .getRequestedStartOffset().intValue();
            Integer endOffset =
                searchRequest.getPresentationControlParameters()
                        .getRequestedEndOffset().intValue();

            int rows = endOffset - startOffSet + 1;
            if (rows > this.getMaxSearchResultRecords())
            {
                rows = this.getMaxSearchResultRecords();
            }
           
            List<Sort> sortList = searchRequest.getPresentationControlParameters().getSort();
   
    // Get QueryString
            String queryString = constructQueryString(searchItemList);
            log.debug("Query String: " + queryString);
     
      if (StringUtils.isNotBlank(queryString))
            {
        // Get PointerLocations

                SolrDocumentList solrSearchResult =
                    executeQuery(solrLocation, queryString, startOffSet,
rows + 1, sortList );
               
                int recordCount = solrSearchResult.size();

                SearchResult searchResult = new SearchResult();
               
                PresentationControlParameters presentationControlParameters =
                    new PresentationControlParameters();
               
                if (recordCount == (rows + 1))
                {
                    presentationControlParameters.setMoreRecordsAvailable(true);
                    solrSearchResult.remove(recordCount - 1);
                    recordCount = recordCount - 1;
                }
               
                if (solrSearchResult.size() > 0)
                {
                    List<String> pointerLocations =
                        getPointerLocations(solrSearchResult);

                    // Get Pointers
                    Pointers pointers = getPointers(pointerLocations);

                    searchResult.setPointers(pointers);
                }
                else
                {
                    searchResult.setEmpty(new Empty());
                }
       
        // Set SearchResults
        searchResult.setSearchItems(searchItems);
       
        presentationControlParameters.setReturnedRecordCount(BigInteger
                        .valueOf(recordCount));
                presentationControlParameters.setTotalRecordCount(BigInteger
                        .valueOf(solrSearchResult.getNumFound()));
                presentationControlParameters
                        .setRequestedStartOffset(BigInteger
                                .valueOf(startOffSet));
        presentationControlParameters.setRequestedEndOffset(BigInteger
                        .valueOf(endOffset));

                presentationControlParameters.getSort().addAll(
                    searchRequest.getPresentationControlParameters().getSort() );
        searchResult
                        .setPresentationControlParameters(presentationControlParameters);
        // Return Document
                return marshal(searchResult);
      } else {
View Full Code Here


   * @return
   * @throws SSAFSolrException
   */
  private SearchRequest validateXML(Document document) throws SSAFSolrException
  {
    SearchRequest searchRequest = null;
    try {
       
        Unmarshaller unmarshaller = jaxbFactory.getUnmarshaller();
            searchRequest = (SearchRequest) unmarshaller.unmarshal(document);

View Full Code Here

      , Integer start, Integer rows)
    throws SSAFSolrException
  {
   
    // Validate incoming XML
    SearchRequest searchRequest = validateXML(document);
   
    // Get SearchItems
    SearchItems searchItems = searchRequest.getSearchItems();
   
    // Construct searchItemList Object
    List<SearchItem> searchItemList = searchItems.getSearchItem();
   
    StringBuffer queryString = null;
View Full Code Here

   * @return
   * @throws SSAFSolrException
   */
  private SearchRequest validateXML(Document document) throws SSAFSolrException
  {
    SearchRequest searchRequest = null;
    try {
            // create a JAXBContext capable of handling classes generated into
            // the org.wijiscommons.ssaf.schema package
            JAXBContext jc = JAXBContext.newInstance( "org.wijiscommons.ssaf.schema.search" );
           
View Full Code Here

TOP

Related Classes of org.wijiscommons.ssaf.schema.search.SearchRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.