Package org.fao.geonet.repository

Examples of org.fao.geonet.repository.MetadataRepository


        // And reload services
        String newUuid = values.get(SettingManager.SYSTEM_SITE_SITE_ID_PATH);

        if (newUuid != null && !currentUuid.equals(newUuid)) {
            final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
            final SourceRepository sourceRepository = context.getBean(SourceRepository.class);
            final Source source = sourceRepository.findOne(currentUuid);
            Source newSource = new Source(newUuid, source.getName(), source.isLocal());
            sourceRepository.save(newSource);

            PathSpec<Metadata, String> servicesPath = new PathSpec<Metadata, String>() {
                @Override
                public Path<String> getPath(Root<Metadata> root) {
                    return root.get(Metadata_.sourceInfo).get(MetadataSourceInfo_.sourceId);
                }
            };
            metadataRepository.createBatchUpdateQuery(servicesPath, newUuid, MetadataSpecs.isHarvested(false));

            sourceRepository.delete(source);
        }

        SettingInfo info = context.getBean(SettingInfo.class);
View Full Code Here


        if (group == null) {
            throw new IllegalArgumentException("Group with identifier '" + groupOwner + "' not found.");
        }

        //--- Update groupOwner
        MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        Metadata metadata = metadataRepository.findOne(iLocalId);
        metadata.getSourceInfo().setGroupOwner(iGroupOwner);
        metadataRepository.save(metadata);

        //--- index metadata
        dataMan.indexMetadata(id, true);

        //--- return id for showing
View Full Code Here

        Element response = new Element("response");
       
        // Add parameter by source catalog
        // Add parameter by group and owner

        final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        final Specifications<Metadata> isMetadataType = where(isType(MetadataType.METADATA));
        final long totalNonTemplateMetadata = metadataRepository.count(isMetadataType);
        final long totalTemplateMetadata = metadataRepository.count(isType(MetadataType.TEMPLATE));
        final long totalSubTemplateMetadata = metadataRepository.count(isType(MetadataType.SUB_TEMPLATE));
        final long totalHarvestedNonTemplateMetadata = metadataRepository.count(isMetadataType.and(MetadataSpecs.isHarvested(true)));
        final long totalPublicMetadata = metadataRepository.getMetadataStatistics().getStatBasedOnOperationAllowed
                (MetadataStatisticSpec.StandardSpecs.metadataCount(), OperationAllowedSpecs.isPublic(ReservedOperation.view));

        // Total number of metadata by type
        SearchStatistics.addSingleDBValueToElement(response, totalNonTemplateMetadata, "nb_metadata", "total");
        SearchStatistics.addSingleDBValueToElement(response, totalHarvestedNonTemplateMetadata, "nb_harvested", "total");
View Full Code Here

      String uuid = (String) iter.next();
      String id   = dm.getMetadataId(uuid);
               
      //--- check access

            final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
            Metadata info = metadataRepository.findOne(id);
      if (info == null) {
        notFound.add(Integer.valueOf(id));
      } else if (!accessMan.isOwner(context, id)) {
        notOwner.add(Integer.valueOf(id));
      } else {

        //--- remove old operations
                info.getCategories().clear();

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

                metadataRepository.save(info);
        metadata.add(Integer.valueOf(id));
      }
    }
    }
View Full Code Here

    Set<Integer> metadata = new HashSet<Integer>();
    Set<Integer> notFound = new HashSet<Integer>();
    Set<Integer> notOwner = new HashSet<Integer>();

        final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        synchronized(sm.getSelection("metadata")) {
    for (Iterator<String> iter = sm.getSelection("metadata").iterator(); iter.hasNext();) {
      String uuid = (String) iter.next();
      String id   = dm.getMetadataId(uuid);


            final Integer iId = Integer.valueOf(id);
            if (! metadataRepository.exists(iId)) {
        notFound.add(iId);
      } else if (!accessMan.isOwner(context, id)) {
        notOwner.add(iId);
      } else {
        metadata.add(iId);
View Full Code Here

TOP

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

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.