Package org.fao.geonet.kernel

Examples of org.fao.geonet.kernel.KeywordBean


       
        Pair<String, String> upperCorner = parseCorner(resultsTable, columnNameMap, row, Selectors.UPPER_CORNER.id);
        String coordEast = upperCorner.one();
        String coordNorth = upperCorner.two();

        KeywordBean keywordBean = new KeywordBean(thesaurus.getIsoLanguageMapper())
            .setThesaurusInfo(thesaurus)
            .setId(row)
            .setUriCode(columnValue(resultsTable, columnNameMap, row, Selectors.ID.id))
            .setCoordEast(coordEast)
            .setCoordNorth(coordNorth)
            .setCoordSouth(coordSouth)
            .setCoordWest(coordWest)
      .setDownloadUrl(thesaurus.getDownloadUrl())
      .setKeywordUrl(thesaurus.getKeywordUrl());
           
        for (String lang : this.languages) {
            String value = columnValue(resultsTable, columnNameMap, row, lang+Selectors.LABEL_POSTFIX);
            keywordBean.setValue(value, lang);
            String definition = columnValue(resultsTable, columnNameMap, row, lang+Selectors.NOTE_POSTFIX);
            keywordBean.setDefinition(definition, lang);
        }

        return keywordBean;
    }
View Full Code Here


    String modeType   = "add";
   
    Element elResp = new Element(Jeeves.Elem.RESPONSE);
   
    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("#"));
    }
   
   
View Full Code Here

                    .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);
            }

        } else {
            thesaurus.removeElement(code);
View Full Code Here

    int nbResults = this.getNbResults();

    //for (int i = from; i <= to; i++) {
    for (int i = 0; i <= nbResults - 1; i++) {
      KeywordBean kb = _results.get(i);
            toRawElement(elDescKeys, kb);
    }

    return elDescKeys;
  }
View Full Code Here

   */
  public Element getSelectedKeywordsAsXml() {
    Element elDescKeys = new Element("descKeys");
    int nbSelectedKeywords = 0;
    for (int i = 0; i < this.getNbResults(); i++) {
      KeywordBean kb = _results.get(i);
      if (kb.isSelected()) {
        toRawElement(elDescKeys, kb);
        nbSelectedKeywords++;
      }
    }
    Element elNbTot = new Element("nbtot");
View Full Code Here

     * @return list of keywordbeans
     */
  public List<KeywordBean> getSelectedKeywordsInList() {
    List<KeywordBean> keywords = new ArrayList<KeywordBean>();
    for (int i = 0; i < this.getNbResults(); i++) {
      KeywordBean kb = _results.get(i);
      if (kb.isSelected()) {
          keywords.add(kb);
        }
      }
    return keywords;
  }
View Full Code Here

        Element elResp = new Element(Jeeves.Elem.RESPONSE);
        elResp.addContent(new Element("error").addContent(new Element("message").setText("Code value already exists in thesaurus")));
        return elResp;
      }
    }
    KeywordBean bean = new KeywordBean(thesaurus.getIsoLanguageMapper())
      .setNamespaceCode(namespace)
            .setUriCode(newid);
   
        Map<Pair<String, String>, String> localizations = getLocalizedElements(params);
        if (localizations.isEmpty()) {
            String prefLab = Util.getParam(params, PREF_LAB);
            String lang = Util.getParam(params, "lang");
            String definition = Util.getParam(params, DEFINITION, "");

            bean.setValue(prefLab, lang).setDefinition(definition, lang);
        } else {
            Set<Map.Entry<Pair<String, String>, String>> entries = localizations.entrySet();

            for (Map.Entry<Pair<String, String>, String> entry : entries) {
                String lang = entry.getKey().one();
                if (entry.getKey().two().equals(DEFINITION)) {
                    final String definition = entry.getValue();
                    bean.setDefinition(definition, lang);
                } else if (entry.getKey().two().equals(PREF_LAB)) {
                    final String label = entry.getValue();
                    bean.setValue(label, lang);
                } else {
                    throw new IllegalArgumentException("Unknown localization type: "+entry.getKey().two());
                }

            }
        }

        if (thesaType.equals("place")) {
            bean.setCoordEast(Util.getParam(params, "east"))
                .setCoordNorth(Util.getParam(params, "north"))
                .setCoordSouth(Util.getParam(params, "south"))
                .setCoordWest(Util.getParam(params, "west"));
        }
       
View Full Code Here

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

    ThesaurusManager manager = gc.getBean(ThesaurusManager.class);
    Thesaurus thesaurus = manager.getThesaurusByName(ref);

    if (thesaurus.isFreeCode(null, newid)) {

        KeywordBean keyword = new KeywordBean(context.getBean(IsoLanguagesMapper.class))
              .setNamespaceCode(namespace)
              .setUriCode(newid);

            Map<Pair<String, String>, String> localizations = getLocalizedElements(params);
            if (localizations.isEmpty()) {
                String prefLab = Util.getParam(params, PREF_LAB);
                String lang = Util.getParam(params, "lang");
                String definition = Util.getParam(params, DEFINITION,"");

                keyword.setValue(prefLab, lang)
              .setDefinition(definition, lang);
            } else {
                Set<Map.Entry<Pair<String, String>, String>> entries = localizations.entrySet();

                for (Map.Entry<Pair<String, String>, String> entry : entries) {
                    String lang = entry.getKey().one();
                    if (entry.getKey().two().equals(DEFINITION)) {
                        final String definition = entry.getValue();
                        keyword.setDefinition(definition, lang);
                    } else if (entry.getKey().two().equals(PREF_LAB)) {
                        final String label = entry.getValue();
                        keyword.setValue(label, lang);
                    } else {
                        throw new IllegalArgumentException("Unknown localization type: "+entry.getKey().two());
                    }

                }
            }

      if (thesaType.equals("place")) {
        String east = Util.getParam(params, "east");
        String west = Util.getParam(params, "west");
        String south = Util.getParam(params, "south");
        String north = Util.getParam(params, "north");
        keyword.setCoordEast(east)
                    .setCoordNorth(north)
                    .setCoordSouth(south)
                    .setCoordWest(west);
      }
View Full Code Here

    @Test
    public void testSearchByIdStringStringString() throws Exception {
        KeywordsSearcher searcher = new KeywordsSearcher(isoLangMapper, thesaurusFinder);
       
        KeywordBean kw = searcher.searchById(FOO_COM_NS+"4", thesaurusFoo.getKey(), "eng");
       
        assertNotNull(kw);
        assertEquals(createFooLabel(4, "eng"), kw.getDefaultValue());
        assertEquals(createFooNote(4, "eng"), kw.getDefaultDefinition());
       
        kw = searcher.searchById(BLAH_COM_NS+"4", thesaurusBlah.getKey(), "eng", "fre", "ita", "ger", "chi");
        assertEquals(createBlahLabel(4, "eng"), kw.getDefaultValue());
        assertEquals(createBlahNote(4, "eng"), kw.getDefaultDefinition());
        assertEquals("eng", kw.getDefaultLang());
        assertNotNull(kw);
        assertEquals(createBlahLabel(4, "fre"), kw.getValues().get("fre"));
        assertEquals(createBlahNote(4, "ger"), kw.getDefinitions().get("ger"));
        assertEquals(createBlahLabel(4, "ita"), kw.getValues().get("ita"));
        assertEquals(createBlahNote(4, "eng"), kw.getDefinitions().get("eng"));
        assertEquals("", kw.getDefinitions().get("chi"));
       
        kw = searcher.searchById(FOO_COM_NS+"4", thesaurusBlah.getKey(), "eng");

        assertNull(kw);
    }
View Full Code Here

TOP

Related Classes of org.fao.geonet.kernel.KeywordBean

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.