Package org.fao.geonet.kernel.search

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


  public Element exec(Element params, ServiceContext context)
      throws Exception {

    Element response = new Element(Jeeves.Elem.RESPONSE);
    UserSession session = context.getUserSession();
    KeywordsSearcher searcher = (KeywordsSearcher)session.getProperty(Geonet.Session.SEARCH_KEYWORDS_RESULT);

    searcher.selectUnselectKeywords(params);
   
    // send ok   
    response.addContent(new Element("ok"));   

    return response;
View Full Code Here


    if (!id.equals("") || !uri.equals("")) {
      KeywordBean kb = null;
     
      if (!id.equals("")){
        UserSession session = context.getUserSession();
        KeywordsSearcher searcher = (KeywordsSearcher) session
          .getProperty(Geonet.Session.SEARCH_KEYWORDS_RESULT);
        kb = searcher.getKeywordFromResultsById(id);
      }else{
        GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
        ThesaurusManager thesaurusMan = gc.getBean(ThesaurusManager.class);
        KeywordsSearcher searcher = new KeywordsSearcher(context, thesaurusMan);
       
        kb = searcher.searchById(uri, ref, lang);
       
      }
      // Add info needed by thesaurus.edit
      elResp.addContent(new Element("prefLab").setText(kb.getDefaultValue()));
      elResp.addContent(new Element("definition").setText(kb.getDefaultDefinition()));

      elResp.addContent(new Element("relCode").setText(kb.getRelativeCode()));
      elResp.addContent(new Element("nsCode").setText(kb.getNameSpaceCode()));
      if (kb.getCoordEast() != null) {
                elResp.addContent(new Element("east").setText(kb.getCoordEast()));
            }
      if (kb.getCoordWest() != null) {
                elResp.addContent(new Element("west").setText(kb.getCoordWest()));
            }
      if (kb.getCoordSouth() != null) {
                elResp.addContent(new Element("south").setText(kb.getCoordSouth()));
            }
      if (kb.getCoordNorth() != null) {
                elResp.addContent(new Element("north").setText(kb.getCoordNorth()));
            }
     

      modeType   = "edit";
      uri     = kb.getRelativeCode();
    } else {
      elResp.addContent(new Element("nsCode").setText("#"));
    }
   
   
    // Only if consult (ie. external thesaurus) search for related concept
    if (mode.equals("consult")){
      ArrayList<KeywordRelation> reqType = new ArrayList<KeywordRelation>();
      reqType.add(KeywordRelation.BROADER);
      reqType.add(KeywordRelation.NARROWER);
      reqType.add(KeywordRelation.RELATED);
     
      GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
      ThesaurusManager thesaurusMan = gc.getBean(ThesaurusManager.class);
      KeywordsSearcher searcherBNR = new KeywordsSearcher(context, thesaurusMan);
     
      for (int i = 0; i <= reqType.size() - 1; i++) {
        searcherBNR.searchForRelated(uri, ref, reqType.get(i), lang);
     
        searcherBNR.sortResults(KeywordSort.defaultLabelSorter(SortDirection.DESC));
        String type;
       
        if (reqType.get(i) == KeywordRelation.BROADER) {
            // If looking for broader search concept in a narrower element
          type = "narrower";
                } else if (reqType.get(i) == KeywordRelation.NARROWER) {
          type = "broader";
                } else {
                        type = "related";
                }
        Element keywordType = new Element(type);
        keywordType.addContent(searcherBNR.getResults());
       
        elResp.addContent(keywordType);
      }
    }
   
View Full Code Here

      throws Exception {

    // Get thesaurus manager
    Element response = new Element(Jeeves.Elem.RESPONSE);
    UserSession session = context.getUserSession();
    KeywordsSearcher searcher = (KeywordsSearcher)session.getProperty(Geonet.Session.SEARCH_KEYWORDS_RESULT);   
   
    // get the results
    response.addContent(searcher.getSelectedKeywordsAsXml());

    return response;
  }
View Full Code Here

        // Optional keyword info - if none, selection is used
        String code = Util.getParam(params, "id", "");

        if ("".equals(code)) {
            KeywordsSearcher searcher = (KeywordsSearcher) session
                    .getProperty(Geonet.Session.SEARCH_KEYWORDS_RESULT);
            List<?> keywords = searcher.getSelectedKeywordsInList();

            Iterator<?> iter = keywords.iterator();
            while (iter.hasNext()) {
                KeywordBean keyword = (KeywordBean) iter.next();
                thesaurus.removeElement(keyword);
View Full Code Here

  public Element exec(Element params, ServiceContext context)
      throws Exception {
    Element response = new Element(Jeeves.Elem.RESPONSE);
    UserSession session = context.getUserSession();

    KeywordsSearcher searcher = null;
   
    boolean newSearch = Util.getParam(params, "pNewSearch").equals("true");
    if (newSearch) {     
      // perform the search and save search result into session
      GeonetContext gc = (GeonetContext) context
          .getHandlerContext(Geonet.CONTEXT_NAME);
      ThesaurusManager thesaurusMan = gc.getBean(ThesaurusManager.class);

            if(Log.isDebugEnabled("KeywordsManager")) Log.debug("KeywordsManager","Creating new keywords searcher");
      searcher = new KeywordsSearcher(context, thesaurusMan);
      searcher.search(context.getLanguage(), params);
      searcher.sortResults(KeywordSort.defaultLabelSorter(SortDirection.DESC));
      session
          .setProperty(Geonet.Session.SEARCH_KEYWORDS_RESULT,
              searcher);
    } else {
      searcher = (KeywordsSearcher) session
          .getProperty(Geonet.Session.SEARCH_KEYWORDS_RESULT);
    }

    // get the results
    response.addContent(searcher.getXmlResults());

   
   
    // If editing
    if (params.getChild("pMode") != null) {
View Full Code Here

            lang[i] = mapper.iso639_2_to_iso639_1(lang[i]);
        }

        boolean multiple = Util.getParam(params, "multiple", false);

        KeywordsSearcher searcher = null;

        // perform the search and save search result into session
        GeonetContext gc = (GeonetContext) context
                .getHandlerContext(Geonet.CONTEXT_NAME);
        ThesaurusManager thesaurusMan = gc.getBean(ThesaurusManager.class);
       
       
        Element root = null;
       
        if (uri == null) {
            root = new Element("descKeys");
        } else {
            searcher = new KeywordsSearcher(context, thesaurusMan);
            KeywordBean kb = null;
           
            if (!multiple) {
                kb = searcher.searchById(uri, sThesaurusName, lang);
                if (kb == null) {
                    root = new Element("descKeys");
                } else {
                    root = KeywordsSearcher.toRawElement(new Element("descKeys"),
                            kb);
                }
            } else {
                String[] url = uri.split(",");
                List<KeywordBean> kbList = new ArrayList<KeywordBean>();
                for (int i = 0; i < url.length; i++) {
                    String currentUri = url[i];
                    kb = searcher.searchById(currentUri, sThesaurusName, lang);
                    if (kb == null) {
                        root = new Element("null");
                    } else {
                        kbList.add(kb);
                        kb = null;
View Full Code Here

  public Element exec(Element params, ServiceContext context)
      throws Exception {
    Element response = new Element(Jeeves.Elem.RESPONSE);

    KeywordsSearcher searcher = null;
   
     
    // perform the search and save search result into session
    GeonetContext gc = (GeonetContext) context
        .getHandlerContext(Geonet.CONTEXT_NAME);
    ThesaurusManager thesaurusMan = gc.getBean(ThesaurusManager.class);

        if(Log.isDebugEnabled("KeywordsManager")) Log.debug("KeywordsManager","Creating new keywords searcher");
    searcher = new KeywordsSearcher(context, thesaurusMan);
   
    String request = Util.getParam(params, "request");
        String conceptId = Util.getParam(params, "id");
   
    if (request.equals("broader")
        || request.equals("narrower")
        || request.equals("related")) {
        KeywordRelation reqType;
     
      if(request.equals("broader"))    // If looking for broader search concept in a narrower element
        reqType = KeywordRelation.NARROWER;
      else if(request.equals("narrower"))
        reqType = KeywordRelation.BROADER;
      else
        reqType = KeywordRelation.RELATED;
     
      searcher.searchForRelated(params, reqType, context.getLanguage());
   
      searcher.sortResults(KeywordSort.defaultLabelSorter(SortDirection.DESC));
     
      // Build response
      response.setAttribute("relation", request);
            response.setAttribute("to", conceptId);
      response.addContent(searcher.getXmlResults());
    }else 
      throw new Exception("unknown request type: " + request);
     
   
    return response;
View Full Code Here

TOP

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

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.