Package org.fao.geonet.kernel

Examples of org.fao.geonet.kernel.Thesaurus


        String fname = Util.getParam(params, Params.REF);
        String activated = Util.getParam(params, "activated");

        ThesaurusManager tm = gc.getBean(ThesaurusManager.class);
        Thesaurus t = tm.getThesaurusByName(fname);

        if (t != null) {
            // Save activated status in the database
            final ThesaurusActivationRepository thesaurusRepository = context.getBean(ThesaurusActivationRepository.class);
View Full Code Here


    String filePath = tm.buildThesaurusFilePath(fname, type, dname);
   
    File rdfFile = new File(filePath);
        final String siteURL = context.getBean(SettingManager.class).getSiteURL(context);
        Thesaurus thesaurus = new Thesaurus(context.getApplicationContext(), fname, tname, tnamespace, type, dname, rdfFile, siteURL, false);
    tm.addThesaurus(thesaurus, true);

    // Save activated status in the database
        ThesaurusActivation activation = new ThesaurusActivation();
        activation.setActivated(Constants.toBoolean_fromYNChar(activated.charAt(0)));
        activation.setId(fname);

        context.getBean(ThesaurusActivationRepository.class).save(activation);

    Element elResp = new Element(Jeeves.Elem.RESPONSE);
    Element elRef = new Element("ref");   
    elRef.addContent(thesaurus.getKey());
    elResp.addContent(elRef);
    Element elName = new Element("thesaName").setText(fname);
    elResp.addContent(elName);
   
    return elResp;
View Full Code Here

        String fname = Util.getParam(params, Params.REF);
       

        ThesaurusManager tm = gc.getBean(ThesaurusManager.class);
        Thesaurus t = tm.getThesaurusByName(fname);

        if (t != null) {
            t.clear();
        } else {
            // Thesaurus does not exist
            throw new Exception("Thesaurus not found");
        }
View Full Code Here

      File newFile = new File(path);
      Xml.writeResponse(new Document(tsXml), new FileOutputStream(
          newFile));

            final String siteURL = context.getBean(SettingManager.class).getSiteURL(context);
            Thesaurus gst = new Thesaurus(context.getApplicationContext(), fname, type, dir, newFile, siteURL);
      thesaurusMan.addThesaurus(gst, false);
    } else {
      IO.delete(rdfFile, false, Geonet.THESAURUS);
      throw new Exception("Unknown format (Must be in SKOS format).");
    }
View Full Code Here

        UserSession session = context.getUserSession();

        // Retrieve thesaurus
        String sThesaurusName = Util.getParam(params, "pThesaurus");
        ThesaurusManager thesaurusMan = gc.getBean(ThesaurusManager.class);
        Thesaurus thesaurus = thesaurusMan.getThesaurusByName(sThesaurusName);

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

        } else {
            thesaurus.removeElement(code);
        }

        Element elResp = new Element(Jeeves.Elem.RESPONSE);
        return elResp;
    }
View Full Code Here

     * @throws Exception
     */
  public KeywordBean searchById(String id, String sThesaurusName, String... languages) throws Exception {
        Query<KeywordBean> query = QueryBuilder.keywordQueryBuilder(_isoLanguageMapper, languages).where(Wheres.ID(id)).build();

        Thesaurus thesaurus = _thesaurusFinder.getThesaurusByName(sThesaurusName);
        List<KeywordBean> kws = query.execute(thesaurus);
        if(kws.isEmpty()) {
            return null;
        } else {
            return kws.get(0);
View Full Code Here

     * @param languages the languages to load
     * @throws Exception hmm
     */
  public void searchForRelated(String id, String sThesaurusName, KeywordRelation request, String... languages) throws Exception {
      _results.clear();
        Thesaurus thesaurus = _thesaurusFinder.getThesaurusByName(sThesaurusName);
      Query<KeywordBean> query = QueryBuilder.keywordQueryBuilder(_isoLanguageMapper, languages).select(Selectors.related(id,request), true).build();
      for (KeywordBean keywordBean : query.execute(thesaurus)) {
            _results.add(keywordBean);
        }
  }
View Full Code Here

    String newid = Util.getParam(params, "newid");
    String namespace = Util.getParam(params, "namespace");
    String thesaType = Util.getParam(params, "refType");

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

    if (!(oldid.equals(newid))) {
      if (thesaurus.isFreeCode(null, newid)) {
        thesaurus.updateCodeByURI(oldid, newid);
      }else{
        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"));
        }
       
        thesaurus.updateElement(bean, false);

    Element elResp = new Element(Jeeves.Elem.RESPONSE);
    elResp.addContent(new Element("selected").setText(ref));
    elResp.addContent(new Element("mode").setText("edit"));
    return elResp;
View Full Code Here

    ThesaurusManager tm = gc.getBean(ThesaurusManager.class);
   

    String theKey = tm.createUpdateThesaurusFromRegister(uuid, type, context);

    Thesaurus gst = tm.getThesaurusByName(theKey);
    String fname = gst.getFname();

        final ThesaurusActivationRepository activationRepository = context.getBean(ThesaurusActivationRepository.class);

        final ThesaurusActivation activation = new ThesaurusActivation();
        activation.setId(fname);
View Full Code Here

    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    ThesaurusManager manager = gc.getBean(ThesaurusManager.class);
   
    String name  = Util.getParam(params, Params.REF);
   
    Thesaurus directory = manager.getThesaurusByName(name);
    if (directory == null)
      throw new IllegalArgumentException("Thesaurus not found --> " + name);
   
    File directoryFile = directory.getFile();
    if (!directoryFile.exists())
      throw new IllegalArgumentException("Thesaurus file not found --> " + name);

    return BinaryFile.encode(200,directoryFile.getAbsolutePath());
  }
View Full Code Here

TOP

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

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.