Package org.fao.geonet.kernel

Examples of org.fao.geonet.kernel.Thesaurus


    // Get parameters
    String name = Util.getParam(params, Params.REF);
   

    // Load file
    Thesaurus thesaurus = manager.getThesaurusByName(name);
    File item = thesaurus.getFile();
   
    // Remove old file from thesaurus manager
    manager.remove(name);
   
    // Remove file
    if (item.exists()) {
      IO.delete(item, true, Geonet.THESAURUS);

            // Delete thesaurus record in the database
            ThesaurusActivationRepository repo = context.getBean(ThesaurusActivationRepository.class);
            String thesaurusId = thesaurus.getFname();
            if (repo.exists(thesaurusId)) {
                repo.delete(thesaurusId);
            }
        } else {
            throw new IllegalArgumentException("Thesaurus not found --> " + name);
View Full Code Here


        }
    String thesaType = Util.getParam(params, "refType");
    Element elResp = new Element(Jeeves.Elem.RESPONSE);

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

      thesaurus.addElement(keyword);

      elResp.addContent(new Element("selected").setText(ref));
      elResp.addContent(new Element("mode").setText("edit"));
    } else {
      elResp.addContent(new Element("error").addContent(new Element("message").setText("Code value already exists in thesaurus")));
View Full Code Here

        this.localesToLoad = Collections.unmodifiableSet(localesToLoad);
    }
   
    @Override
    public Request createSearchRequest(ServiceContext context) throws Exception {
        Thesaurus thesaurus = getThesaurus(context);

        return new ThesaurusRequest(context, this.categoryIdMap , localesToLoad, thesaurus);
    }
View Full Code Here

    }

    private synchronized Thesaurus getThesaurus(ServiceContext context) throws Exception {
        GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
        ThesaurusManager th = gc.getBean(ThesaurusManager.class);
        Thesaurus regions = th.getThesaurusByName(thesaurusName);
        if(regions != null) {
            return regions;
        }
        Set<Entry<String, Thesaurus>> all = th.getThesauriMap().entrySet();
        for (Entry<String, Thesaurus> entry : all) {
View Full Code Here

  public Collection<String> getRegionCategoryIds(final ServiceContext context) throws Exception{
      return JeevesCacheManager.findInTenSecondCache(CATEGORY_ID_CACHE_KEY, new Callable<Collection<String>>(){

            @Override
            public Collection<String> call() throws Exception {
                Thesaurus thesaurus = getThesaurus(context);
                if (thesaurus != null) {
                    QueryBuilder<String> queryBuilder = QueryBuilder.builder().interpreter(CATEGORY_ID_READER);
                    queryBuilder.distinct(true);
                    queryBuilder.select(Selectors.BROADER, true);
                    return queryBuilder.build().execute(thesaurus);
View Full Code Here

    }
    private List<KeywordBean> executeOne(QueryBuilder<KeywordBean> queryBuilder, ThesaurusFinder finder) throws IOException, MalformedQueryException, QueryEvaluationException, AccessDeniedException {
        List<KeywordBean> results = new ArrayList<KeywordBean>();
        int id = 0;
        String thesaurusName = thesauriNames.iterator().next();
        Thesaurus thesaurus = finder.getThesaurusByName(thesaurusName);
        Query<KeywordBean> query = queryBuilder.limit(maxResults-results.size()).build();
        if (thesaurus == null) {
            throw new IllegalArgumentException("The thesaurus "+thesaurusName+" does not exist, there for the query cannot be excuted: '"+query+"'" );
        }
        for (KeywordBean keywordBean : query.execute(thesaurus)) {
View Full Code Here

    private Thesaurus createThesaurus(File directory, String string) throws Exception {
        File thesaurusBlahFile = new  File(directory, string+".rdf");
        GenericXmlApplicationContext appContext = new GenericXmlApplicationContext();
        appContext.getBeanFactory().registerSingleton("IsoLangMapper", isoLangMapper);

        Thesaurus thes = new Thesaurus(appContext, string+".rdf", Geonet.CodeList.EXTERNAL, string, thesaurusBlahFile, "http://"+string+".com");
        setRepository(thes);
        if(!thesaurusBlahFile.exists() || thesaurusBlahFile.length() == 0) {
            populateThesaurus(thes, smallWords, "http://"+string+".com#", string+"Val", string+"Note", languages);
        }
        return thes;
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.