Package org.fao.geonet.kernel.search

Examples of org.fao.geonet.kernel.search.MetaSearcher


  public Element exec(Element params, ServiceContext context) throws Exception
  {
    // build result data
    UserSession session = context.getUserSession();

    MetaSearcher searcher = (MetaSearcher) session.getProperty(Geonet.Session.SEARCH_RESULT);

        String fast = _config.getValue("fast","");

        if (StringUtils.isNotEmpty(fast)) {
            params.addContent(new Element("fast").setText(fast));
        }

    String range = _config.getValue("range");

    if (range != null)
      if (range.equals("all"))
      {
        params.addContent(new Element("from").setText("1"));
        params.addContent(new Element("to").setText(searcher.getSize() +""));
      } else {
        params.addContent(new Element("from").setText("1"));
        params.addContent(new Element("to").setText(range));
      }


    Element result = searcher.present(context, params, _config);

    // Update result elements to present
    SelectionManager.updateMDResult(context.getUserSession(), result);

    // Restore last search if set
View Full Code Here


    {
      UserSession session = context.getUserSession();
      session.setProperty(Geonet.Session.METADATA_SHOW, elCurrTab.getText());
    }
    // build result data
    MetaSearcher searcher = (MetaSearcher) context.getUserSession().getProperty(Geonet.Session.SEARCH_RESULT);
    return searcher.get(context, params, _config);
  }
View Full Code Here

    Element       params = buildParams(par);
    ServiceConfig config = new ServiceConfig();

    SearchManager searchMan = gc.getBean(SearchManager.class);
    MetaSearcher  searcher  = searchMan.newSearcher(SearchManager.LUCENE, Geonet.File.SEARCH_LUCENE);

    searcher.search(context, params, config);

    params.addContent(new Element("from").setText("1"));
    params.addContent(new Element("to").setText(searcher.getSize() +""));
    params.addContent(new Element("fast").setText("index"));

    Element result = searcher.present(context, params, config);

    searcher.close();

    return result;
  }
View Full Code Here

    // perform the search and save search result into session

    context.info("Creating UnusedSearcher");

    MetaSearcher searcher = searchMan.newSearcher(SearchManager.UNUSED, Geonet.File.SEARCH_LUCENE);

    searcher.search(context, params, null);
    session.setProperty(Geonet.Session.SEARCH_RESULT, searcher);

    context.info("Getting unused summary");

    return searcher.getSummary();
  }
View Full Code Here

    SearchManager searchMan = gc.getBean(SearchManager.class);
    Element searchParams = new Element("parameters")
    searchParams.addContent(new Element("_schema").setText(schema));

     MetaSearcher  searcher  = searchMan.newSearcher(SearchManager.LUCENE, Geonet.File.SEARCH_LUCENE);
    try {
       searcher.search(context, searchParams, config);
      int results = searcher.getSize();
      if (results == 0) { // check for templates
        searchParams.addContent(new Element("_isTemplate").setText("y"));
         searcher.search(context, searchParams, config);
        results = searcher.getSize();
      }
      if (results > 0) {
        String errStr = "Cannot remove schema "+schema+" because there are records that belong to this schema in the catalog";
        context.error(errStr);
        response.setAttribute("status", "error");
        response.setAttribute("message", errStr);
        return response;
      }
    } catch (Exception e) {
      e.printStackTrace();
      String errStr = "Cannot remove schema "+schema+" because the search for records that belong to this schema FAILED ("+e.getMessage()+")";
      context.error(errStr);
      response.setAttribute("status", "error");
      response.setAttribute("message", errStr);
      return response;
    } finally {
       searcher.close();
    }

    // check for any schemas that may be dependent on the schema to be deleted
    List<String> dependsOnMe = scm.getSchemasThatDependOnMe(schema);
    if (dependsOnMe.size() > 0) {
View Full Code Here

TOP

Related Classes of org.fao.geonet.kernel.search.MetaSearcher

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.