Package com.esri.gpt.catalog.search

Examples of com.esri.gpt.catalog.search.SearchResult


    status.setStartTimestamp(new Timestamp(System.currentTimeMillis()));
  
    if (this.isTimeUp()) {
      throw new Exception("This thread has been stopped");
    }
    SearchResult result = new SearchResult();
    SearchCriteria criteria = this.getSearchContext().getSearchCriteria();
    ASearchEngine engine = this.getSearchEngine();
    engine.setRequestDefinition(new SearchRequestDefinition(criteria, result));
    engine.setHitsOnly(true);
    engine.setConnectionTimeoutMs(this.getMaxSearchTime());
    engine.setResponseTimeout(this.getMaxSearchTime());

    if (LOG.isLoggable(Level.FINER)) {
      LOG.finer("Starting SEARCH IN thread id= " + this.getId() + ", rid="
          + this.getRID());
    }
    if (this.rid.equalsIgnoreCase("local")) {
      GetRecordsGenerator grg = new GetRecordsGenerator(rc);
      if (engine.getHitsOnly()) {
        grg.setResultType("HITS");
      }
      String cswRequest = grg.generateCswRequest(query);
      SearchEngineCSW csw = (SearchEngineCSW) engine;
      if (this.isTimeUp()) {
        throw new Exception("This threads time is up");
      }
      csw.doSearch(cswRequest);
    } else {
      if (this.isTimeUp()) {
        throw new Exception("This threads time is up");
      }
      engine.doSearch();
    }
    if (LOG.isLoggable(Level.FINER)) {
      LOG.finer("ENDING SEARCH IN thread id= " + this.getId() + ", rid="
          + this.getRID());
    }
    status.setHitCount(result.getMaxQueryHits());
    this.getSearchStatus().setEndTimestamp(
        new Timestamp(System.currentTimeMillis()));
    this.writeStatus(SearchStatus.STATUSTYPE_COMPLETED);
   
  } catch (Exception e) {
View Full Code Here


* Gets the search result.
* @return the search result (never null)
*/
public SearchResult getSearchResult() {
  if(searchResult == null) {
    this.setSearchResult(new SearchResult());
  }
  return this.searchResult;
}
View Full Code Here

      id = URLDecoder.decode(tmp,"UTF-8");
    }
   
    // create search dao
    SearchCriteria criteria = new SearchCriteria();
    SearchResult result = new SearchResult();
    ASearchEngine dao =
      rid.length()==0?
      SearchEngineFactory.createSearchEngine(criteria, result, context,
          msgBroker):
      SearchEngineFactory.createSearchEngine(criteria, result, context, rid,
View Full Code Here

    if("".equals(harvestID)) {
      engine = super.getSearchDao();
    } else {
   
      engine = SearchEngineFactory.createSearchEngine(
          new SearchCriteria(), new SearchResult(),
          this.extractRequestContext(), harvestID,
          this.getContextBroker().extractMessageBroker());
    }
    response = Val.chkStr(engine.getMetadataUrl(uuid));
   
View Full Code Here

 
  SearchContext context = this.getSearchContext();
  Map<String, Object> mapRid2Engine =
    SearchEngineFactory.createSearchEngines(
      context.getSearchCriteria(),
      new SearchResult(),
      this.searchContext.getRequestContext(),
       context.getRIDs(),
      context.getMessageBroker(),
      null, null);
 
View Full Code Here

        if (callback != null) {
          printWriter.print(")");
        }

      } else {
        SearchResult result = executeQuery1(request, context, msgBroker, query);
        if (feedWriter instanceof FeedWriter2) {
          ((FeedWriter2) feedWriter).write(result);
        } else if (feedWriter instanceof HtmlAdvancedWriter) {
          ((HtmlAdvancedWriter) feedWriter).write(result);
        } else {
          feedWriter.write(new SearchResultRecordsAdapter(result.getRecords()));
        }
      }
    } catch (Exception e) {
      getLogger().log(Level.SEVERE, "Error executing query.", e);
      if (feedWriter instanceof FeedWriter2) {
View Full Code Here

          RestQuery query) throws SearchException {

    // make the search engine
    ASearchEngine engine = null;
    SearchCriteria criteria = this.toSearchCriteria(request, context, query);
    SearchResult result = new SearchResult();
    String rid = Val.chkStr(query.getRepositoryId());
    RestQueryServlet.ResponseFormat format = getResponseFormat(request, query);

    boolean isJavascriptEnabled =
            Val.chkBool(request.getParameter("isJavascriptEnabled"), false);
    if (format.toString().toLowerCase().startsWith("searchpage")
            || isJavascriptEnabled == true) {

      if (format.toString().toLowerCase().startsWith("searchpage")) {
        @SuppressWarnings("unchecked")
        Map<String, String> extraArgs = (Map<String, String>) context
                .getObjectMap().get(EXTRA_REST_ARGS_MAP);
        if (extraArgs != null) {
          if (extraArgs.get(PARAM_KEY_SHOW_RELATIVE_URLS) == null) {
            extraArgs.put(PARAM_KEY_SHOW_RELATIVE_URLS, "true");
          }
          extraArgs.put(PARAM_KEY_IS_JSFREQUEST, "true");
        }
      }
      context.setViewerExecutesJavascript(true);
    } else {
      context.setViewerExecutesJavascript(false);
    }
    ResourceLinkBuilder rBuild = ResourceLinkBuilder.newBuilder(context,
            request, messageBroker);



    // handle a request against the local repository
    if ((rid.length() == 0) || rid.equalsIgnoreCase("local")) {

      // generate the CSW request string
      String cswRequest = "";
      try {
        GetRecordsGenerator grg = new GetRecordsGenerator(context);
        cswRequest = grg.generateCswRequest(query);
      } catch (Exception e) {
        throw new SearchException(e);
      }

      // execute the query
      engine = SearchEngineFactory.createSearchEngine(criteria, result, context, messageBroker);
      SearchEngineCSW csw = (SearchEngineCSW) engine;
      csw.setResourceLinkBuilder(rBuild);
      csw.doSearch(cswRequest);

      // handle a request against a remote repository
    } else {

      // create the criteria, execute the query
      int iSearchTime = Val.chkInt(request.getParameter("maxSearchTimeMilliSec"), -1);
      engine = SearchEngineFactory.createSearchEngine(criteria, result, context, rid, messageBroker);
      engine.setResourceLinkBuilder(rBuild);
      if (iSearchTime > 0) {
        engine.setConnectionTimeoutMs(iSearchTime);
        engine.setResponseTimeout(iSearchTime);
      }
      engine.doSearch();

    }

    // set the OpenSearch properties
    String basePath = RequestContext.resolveBaseContextPath(request);
    String osURL = basePath + "/openSearchDescription";
    //String osURL = request.getRequestURL().toString();
    //osURL = osURL.replaceAll("/rest/find/document","/openSearchDescription");
    OpenSearchProperties osProps = new OpenSearchProperties();
    osProps.setShortName(messageBroker.retrieveMessage("catalog.openSearch.shortName"));
    osProps.setDescriptionURL(osURL);
    osProps.setNumberOfHits(result.getMaxQueryHits());
    osProps.setStartRecord(query.getFilter().getStartRecord());
    osProps.setRecordsPerPage(query.getFilter().getMaxRecords());
    result.getRecords().setOpenSearchProperties(osProps);
    return result;

  }
View Full Code Here

TOP

Related Classes of com.esri.gpt.catalog.search.SearchResult

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.