Package org.fao.geonet.repository

Examples of org.fao.geonet.repository.MetadataCategoryRepository


     * @throws Exception
     */
    public void addCategories(Metadata metadata, Iterable<String> categories, CategoryMapper localCateg, ServiceContext context,
                              Logger log, String serverCategory) {

        final MetadataCategoryRepository categoryRepository = context.getBean(MetadataCategoryRepository.class);
        Map<String, MetadataCategory> nameToCategoryMap = new HashMap<String, MetadataCategory>();
        for (MetadataCategory metadataCategory : categoryRepository.findAll()) {
            nameToCategoryMap.put(""+metadataCategory.getId(), metadataCategory);
        }
        for(String catId : categories)  {
            String name = localCateg.getName(catId);

View Full Code Here


  //--------------------------------------------------------------------------

  public CategoryMapper(ServiceContext context) throws Exception
  {

        final MetadataCategoryRepository categoryRepository = context.getBean(MetadataCategoryRepository.class);


    for (MetadataCategory record : categoryRepository.findAll()) {
            String id = "" + record.getId();
            String name = record.getName();

            add(name, id);
        }
View Full Code Here

    // -- build a map of collection code versus repository name for
    // -- assigning the categories
    Map <String,String> codes = new HashMap<String,String>();
    Map <String,String> catCodes = new HashMap<String,String>();

        final MetadataCategoryRepository categoryRepository = this.context.getBean(MetadataCategoryRepository.class);
        // -- add new category for each repository
    boolean addcateg = false;
    for (String repo : params.getRepositories()) {
      Element repoElem = Xml.selectElement(repositories, "record[id='"+repo+"']");
      if (repoElem != null) {
        Element repoId  = repoElem.getChild("id");
        String repoName = repoElem.getChildText("name");
        codes.put(repoId.getAttributeValue("serverCode")+":"+repoId.getAttributeValue("code"), repoName);
        // create a result holder for this repository
        serverResults.getServerResult(repoName);

        // sanitize the name of the category
        String categName = repoName.replaceAll("[^\\w]","");
        categName = categName.toLowerCase();
        catCodes.put(repoId.getAttributeValue("serverCode")+":"+repoId.getAttributeValue("code"), categName);

        if (categoryRepository.findOneByNameIgnoreCase(categName) == null) {
                    MetadataCategory category = new MetadataCategory();
                    category.setName(categName);
                    categoryRepository.save(category);
          addcateg = true;
        }
      }
    }

    if (addcateg) {
            categoryRepository.flush();
        }

    // --- return only maximum hits as directed by the harvest params
    int nrGroups = (numberOfHits / groupSize) + 1;
    for (int i = 1; i <= nrGroups; i++) {
View Full Code Here

      hsMetadataCat.add(cat.getId() + "");
    }

    //-----------------------------------------------------------------------
    //--- retrieve groups operations
        final MetadataCategoryRepository categoryRepository = context.getBean(MetadataCategoryRepository.class);

        Element elCateg = categoryRepository.findAllAsXml();

        @SuppressWarnings("unchecked")
        List<Element> list = elCateg.getChildren();
        for (Element el : list) {
View Full Code Here

        //--- set new ones
        @SuppressWarnings("unchecked")
                List<Element> list = params.getChildren();

                final MetadataCategoryRepository categoryRepository = context.getBean(MetadataCategoryRepository.class);
                for (Element el : list) {
          String name = el.getName();

          if (name.startsWith("_"))  {
                        final MetadataCategory category = categoryRepository.findOne(Integer.valueOf(name.substring(1)));
                        if (category != null) {
                            info.getCategories().add(category);
                        } else {
                            context.warning("Unable to find category with name: "+name.substring(1));
                        }
View Full Code Here

     * @param mdId
     * @param categId
     * @throws Exception
     */
    public void setCategory(ServiceContext context, String mdId, String categId) throws Exception {
        final MetadataCategoryRepository categoryRepository = _applicationContext.getBean(MetadataCategoryRepository.class);

        final MetadataCategory newCategory = categoryRepository.findOne(Integer.valueOf(categId));
        final boolean[] changed = new boolean[1];
        _metadataRepository.update(Integer.valueOf(mdId), new Updater<Metadata>() {
            @Override
            public void apply(@Nonnull Metadata entity) {
                changed[0] = !entity.getCategories().contains(newCategory);
View Full Code Here

TOP

Related Classes of org.fao.geonet.repository.MetadataCategoryRepository

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.