Package com.esri.gpt.catalog.search

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


    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());
    }
View Full Code Here


    html += event.getSearchStatus().getRid();
    html += "</div>";
    html += "<div class=\"abstract\">";
    if(event.getSource() instanceof SearchThread) {
      SearchThread searchThread = (SearchThread) event.getSource();
      ASearchEngine engine = searchThread.getSearchEngine();
      try {
        html += engine.getKeyAbstract();
      } catch (SearchException e) {
        LOG.log(Level.FINE,"Could not get summary", e.getMessage());
        e.printStackTrace();
      }
    }
View Full Code Here

    /*if(page == pageCursor.getTotalPageCount() || pageCursor.getTotalPageCount()
        == 0) {
      pageCursor.setRecordsPerPage(recordsPerPage + 1);
    }*/

    ASearchEngine dao = this.getSearchDao();

    double time = 0;
    // checks if we are at the beginning border (totalPages == 0) or we
    // are at a late border (totalPages > 0
    int border = 0;


    border = 1;

    dao.doSearch();

    // If search criteria changes while you are in a page more than 1
    // then reset to page 1 if no results exists for this search
    /*
    if(page > 1 && this.getSearchResult().getRecords().size() < 1) {
      this.doSearch(urlBuilder, 1, doPrefetch);
    }
    */
   // RequestContext context = this.extractRequestContext();
   // this.getSearchResult().getRecords().buildResourceLinks(context);
    this.getSearchResult().setSearchTimeInSeconds(time += dao.getTimeInSeconds());

    // Insert maximum query hits if provided
    int maxQueryHits = this.getSearchResult().getMaxQueryHits();
    if (getSearchResult().getRecords().size() == 0) {
      maxQueryHits = 0;
View Full Code Here

throws SearchException {
  if(uuid == null || "".equals(uuid)) {
    throw new SearchException("UUID given for document requested is either null"
        + " or empty");
  }
  ASearchEngine dao = this.getSearchDao();

  try {
    if(catalogUri != null){
      dao.setConnectionUri(new URI(catalogUri));
    }
    return dao.getMetadataAsText(uuid);
  } catch (URISyntaxException e) {
    throw new SearchException
    ("Invalid Search URL given for catalog "+ catalogUri + " "
        + e.getMessage() , e);
  }
View Full Code Here

* Gets the search dao.
* @return the search dao
* @throws SearchException the search exception
*/
protected ASearchEngine getSearchDao() throws SearchException {
  ASearchEngine dao = SearchEngineFactory.createSearchEngine(
      this.getSearchCriteria(),
      this.getSearchResult(), this.extractRequestContext(),
      SearchEngineLocal.ID,
      (new FacesContextBroker()).extractMessageBroker());
  return dao;
View Full Code Here

    }
   
    // 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,
          msgBroker);

    switch (format) {
      case html: {
          String [] styleUrl = extractStyle(request);
          SearchResultRecord record = dao.getMetadataAsSearchResultRecord(id);
          printHtml(msgBroker, writer, record, styleUrl);
        }
        break;
      case htmlfragment: {
          SearchResultRecord record = dao.getMetadataAsSearchResultRecord(id);
          printHtmlFragment(msgBroker, writer, record);
        }
        break;
      case kml: {
          SearchResultRecord record = dao.getMetadataAsSearchResultRecord(id);
          printKml(msgBroker, writer, record);
        }
        break;
      case json:
      case pjson: {     
          SearchResultRecord record = dao.getMetadataAsSearchResultRecord(id);
          printPjson(msgBroker, writer, record,format);
        }
        break;    
      default:
      case xml: {
          ASearchEngine.ARecord aRecord = dao.getARecord(id);
          String sMetadata = aRecord.getMetadataAsText();
          Date lastModified = aRecord.getModifiedDate();
          if (lastModified!=null) {
            response.addHeader("Last-Modified", new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss z", request.getLocale()).format(lastModified));
          }
View Full Code Here

    String harvestID = Val.chkStr(request.getParameter("id"));
    if("".equals(harvestID)) {
      harvestID = Val.chkStr(request.getParameter("rid"));
    }
   
    ASearchEngine engine = null;
    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));
   
  } catch (Exception e) {
    MessageBroker broker = this.extractMessageBroker();
    FacesMessage message = new FacesMessage();
    message.setSeverity(FacesMessage.SEVERITY_ERROR);
View Full Code Here

  }
 
  // Make the threads
  CountDownLatch countDownLatch = new CountDownLatch(mapEngines.size());
  for(String rid : mapEngines.keySet()) {
    ASearchEngine engine = mapEngines.get(rid);
    SearchThread searchThread = new SearchThread(this.getSearchContext(), rid,
         engine, countDownLatch);
    searchThread.setName(rid + System.currentTimeMillis());
   
    if(listeners != null && listeners.size() > 0) {
View Full Code Here

      "catalog.search.distributedSearch.linkLabel"));
    link.setUrl(this.getRestUrl() + "&rid=" + event.getSearchStatus().getRid());
    ae.addResourceLink(link);
    if(event.getSource() instanceof SearchThread) {
      SearchThread searchThread = (SearchThread) event.getSource();
      ASearchEngine engine = searchThread.getSearchEngine();
      try {
        ae.setSummary(engine.getKeyAbstract());
      } catch (SearchException e) {
        LOG.log(Level.FINE,"Could not get summary", e.getMessage());
        e.printStackTrace();
      }
    }
View Full Code Here

          RequestContext context,
          MessageBroker messageBroker,
          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);
View Full Code Here

TOP

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

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.