Package org.fao.geonet.repository

Examples of org.fao.geonet.repository.MetadataRepository


      this.log = log;
    log.info("Retrieving metadata fragments for : " + params.name);
       
    //--- collect all existing metadata uuids before we update
        final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        localUuids = new UUIDMapper(metadataRepository, params.uuid);

    //--- parse the xml query from the string - TODO: default should be
    //--- get everything
    Element wfsQuery = null;
View Full Code Here


        dataMan.setTemplateExt(iId, MetadataType.lookup(isTemplate));
        dataMan.setHarvestedExt(iId, params.uuid);


        MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        Metadata metadata = metadataRepository.findOne(iId);

        addCategories(metadata, params.getCategories(), localCateg, context, log, null);

        metadata = metadataRepository.findOne(iId);

    if(!localRating) {
      String rating = general.getChildText("rating");
      if (rating != null) {
                metadata.getDataInfo().setRating(Integer.valueOf(rating));
            }
    }

    if (popularity != null) {
            metadata.getDataInfo().setPopularity(Integer.valueOf(popularity));
        }


    String pubDir = Lib.resource.getDir(context, "public",  id);
    String priDir = Lib.resource.getDir(context, "private", id);

    IO.mkdirs(new File(pubDir), "Geonet Aligner public resources directory for metadata " + id);
    IO.mkdirs(new File(priDir), "Geonet Aligner private resources directory for metadata " + id);

        if (params.createRemoteCategory) {
        Element categs = info.getChild("categories");
        if (categs != null) {
            Importer.addCategoriesToMetadata(metadata, categs, context);
        }
    }
        if (((ArrayList<Group>)params.getGroupCopyPolicy()).size() == 0) {
            addPrivileges(id, params.getPrivileges(), localGroups, dataMan, context, log);
        } else {
            addPrivilegesFromGroupPolicy(id, info.getChild("privileges"));
        }
        metadataRepository.save(metadata);
//        dataMan.flush();

        dataMan.indexMetadata(id, false);
    result.addedMetadata++;
View Full Code Here

                log.info("Ignoring invalid metadata");
                result.doesNotValidate++;
                return;
            }
        }
        final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        Metadata metadata;
        if (!ri.isMoreRecentThan(date))
    {
            if(log.isDebugEnabled())
                log.debug("  - XML not changed for local metadata with uuid:"+ ri.uuid);
      result.unchangedMetadata++;
            metadata = metadataRepository.findOne(id);
            if (metadata == null) {
                throw new NoSuchElementException("Unable to find a metadata with ID: "+id);
            }
    } else {
            if (!params.xslfilter.equals("")) {
                md = HarvesterUtil.processMetadata(dataMan.getSchema(ri.schema),
                        md, processName, processParams, log);
            }
            // update metadata
            if(log.isDebugEnabled())
                log.debug("  - Updating local metadata with id="+ id);

            boolean validate = false;
            boolean ufo = params.mefFormatFull;
            boolean index = false;
            boolean updateDateStamp = true;
            String language = context.getLanguage();
            dataMan.updateMetadata(context, id, md, validate, ufo, index, language, ri.changeDate,
                    updateDateStamp);
            metadata = metadataRepository.findOne(id);
            result.updatedMetadata++;
    }

        metadata.getCategories().clear();
        addCategories(metadata, params.getCategories(), localCateg, context, log, null);
        metadata = metadataRepository.findOne(id);

    Element general = info.getChild("general");

    String popularity = general.getChildText("popularity");

    if(!localRating) {
      String rating = general.getChildText("rating");
      if (rating != null) {
        metadata.getDataInfo().setRating(Integer.valueOf(rating));
            }
    }
   
    if (popularity != null) {
            metadata.getDataInfo().setPopularity(Integer.valueOf(popularity));
        }

    if (params.createRemoteCategory) {
            Element categs = info.getChild("categories");
            if (categs != null) {
                Importer.addCategoriesToMetadata(metadata, categs, context);
            }
        }
   
        OperationAllowedRepository repository = context.getBean(OperationAllowedRepository.class);
        repository.deleteAllByIdAttribute(OperationAllowedId_.metadataId, Integer.parseInt(id));
        if (((ArrayList<Group>)params.getGroupCopyPolicy()).size() == 0) {
            addPrivileges(id, params.getPrivileges(), localGroups, dataMan, context, log);
        } else {
            addPrivilegesFromGroupPolicy(id, info.getChild("privileges"));
        }

        metadataRepository.save(metadata);
//        dataMan.flush();

        dataMan.indexMetadata(id, false);
  }
View Full Code Here

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

  public UriMapper(ServiceContext context, String harvestUuid) throws Exception
  {
        final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        final List<Metadata> metadataList = metadataRepository.findAll(MetadataSpecs.hasHarvesterUuid(harvestUuid));

    for (Metadata record : metadataList) {
      String uri  = record.getHarvestInfo().getUri();

      List<RecordInfo> records = hmUriRecords.get(uri);
View Full Code Here

        for (Integer grpId : groups) {
            spec = spec.and(OperationAllowedSpecs.hasGroupId(grpId));
        }
        final List<Integer> list = operationAllowedRepository.findAllIds(spec, OperationAllowedId_.metadataId);

        final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        Sort sortByChangeDateDesc = new Sort(Sort.Direction.DESC, Metadata_.dataInfo.getName()+"."+MetadataDataInfo_.changeDate);

        Element result = metadataRepository.findAllAsXml(MetadataSpecs.hasMetadataIdIn(list), sortByChangeDateDesc);


        Element formatEl = new Element("format");
        formatEl.setText(format.toLowerCase());
View Full Code Here

            privCount++;
        }

        // Set owner for all records to be modified.
        for (Integer i : metadata) {
            final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
            final Metadata metadata1 = metadataRepository.findOne(i);
            metadata1.getSourceInfo().setGroupOwner(targetGrp).setOwner(targetUsr);
            metadataRepository.save(metadata1);
        }

        dm.flush();

        //--- reindex metadata
View Full Code Here

    public Element exec(Element params, ServiceContext context)
            throws Exception {
        String uuid = Util.getParam(params, Params.UUID);
       
        // Retrieve template
        final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        final Metadata metadata = metadataRepository.findOneByUuid(uuid);

        if (metadata.getDataInfo().getType() != MetadataType.SUB_TEMPLATE) {
            throw new IllegalArgumentException("Metadata uuid="+uuid+" is not a subtemplate");
        }
View Full Code Here

    AccessManager accessMan = gc.getBean(AccessManager.class);

    if (context.isDebugEnabled())
      context.debug("Extracting subtemplates from metadata with uuid:"+ uuid);

        final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
        Metadata metadataEntity = metadataRepository.findOneByUuid(uuid);

    // Metadata may have been deleted since selection
    if (metadataEntity != null) {
            String id   = "" + metadataEntity.getId();
View Full Code Here

         String language = context.getLanguage();
         dataMan.updateMetadata(context, id, template, validate, ufo, index, language, df.format(date), false);

         int iId = Integer.parseInt(id);

         final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
         Metadata metadata = metadataRepository.findOne(iId);
         OperationAllowedRepository repository = context.getBean(OperationAllowedRepository.class);
         repository.deleteAllByIdAttribute(OperationAllowedId_.metadataId, iId);
         addPrivileges(id, params.privileges, localGroups, dataMan, context, log);

         metadata.getCategories().clear();
View Full Code Here

     
        // FIXME: Should be able to get stats only on template
//        String isTemplate = Util.getParam(params, "isTemplate", "n");
        String type = Util.getParam(params, "by", "group");
        Element response = new Element("statistics");
        MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);

        if (type.equals("owner")) {
          Map<User, Integer> statsMap = metadataRepository.getMetadataStatistics().getOwnerToStatMap(metadataCount());
          for (Entry<User, Integer> stat : statsMap.entrySet()) {
            Element entry = new Element("stat");
            entry.addContent(new Element("label").setText(stat.getKey().getName()));
            entry.addContent(new Element("total").setText(stat.getValue() + ""));
            response.addContent(entry);
          }
        } else if (type.equals("source")) {
          Map<Source, Integer> statsMap = metadataRepository.getMetadataStatistics().getSourceToStatMap(metadataCount());
          for (Entry<Source, Integer> stat : statsMap.entrySet()) {
            Element entry = new Element("stat");
            entry.addContent(new Element("label").setText(stat.getKey().getName()));
            entry.addContent(new Element("total").setText(stat.getValue() + ""));
            response.addContent(entry);
          }
        } else if (type.equals("schema")) {
          Map<String, Integer> statsMap = metadataRepository.getMetadataStatistics().getSchemaToStatMap(metadataCount());
          for (Entry<String, Integer> stat : statsMap.entrySet()) {
            Element entry = new Element("stat");
            entry.addContent(new Element("label").setText(stat.getKey()));
            entry.addContent(new Element("total").setText(stat.getValue() + ""));
            response.addContent(entry);
          }
        } else if (type.equals("template")) {
          Map<MetadataType, Integer> statsMap = metadataRepository.getMetadataStatistics().getMetadataTypeToStatMap(metadataCount());
          for (Entry<MetadataType, Integer> stat : statsMap.entrySet()) {
            Element entry = new Element("stat");
            entry.addContent(new Element("label").setText(stat.getKey().toString()));
            entry.addContent(new Element("total").setText(stat.getValue() + ""));
            response.addContent(entry);
          }
        } else if (type.equals("harvested")) {
          Map<Boolean, Integer> statsMap = metadataRepository.getMetadataStatistics().getIsHarvestedToStatMap(metadataCount());
          for (Entry<Boolean, Integer> stat : statsMap.entrySet()) {
            Element entry = new Element("stat");
            entry.addContent(new Element("label").setText(stat.getKey().toString()));
            entry.addContent(new Element("total").setText(stat.getValue() + ""));
            response.addContent(entry);
          }
        } else if (type.equals("category")) {
          Map<MetadataCategory, Integer> statsMap = metadataRepository.getMetadataStatistics().getMetadataCategoryToStatMap(metadataCount());
          for (Entry<MetadataCategory, Integer> stat : statsMap.entrySet()) {
            Element entry = new Element("stat");
            entry.addContent(new Element("label").setText(stat.getKey().getLabel(context.getLanguage())));
            entry.addContent(new Element("total").setText(stat.getValue() + ""));
            response.addContent(entry);
          }
        } else if (type.equals("status")) {
          Map<StatusValue, Integer> statsMap = metadataRepository.getMetadataStatistics().getStatusValueToStatMap(metadataCount());
          for (Entry<StatusValue, Integer> stat : statsMap.entrySet()) {
            Element entry = new Element("stat");
            entry.addContent(new Element("label").setText(stat.getKey().getLabel(context.getLanguage())));
            entry.addContent(new Element("total").setText(stat.getValue() + ""));
            response.addContent(entry);
          }
        } else if (type.equals("validity")) {
          Map<MetadataValidationStatus, Integer> statsMap = metadataRepository.getMetadataStatistics().getMetadataValidationStatusToStatMap(metadataCount());
          for (Entry<MetadataValidationStatus, Integer> stat : statsMap.entrySet()) {
            Element entry = new Element("stat");
            entry.addContent(new Element("label").setText(stat.getKey().toString()));
            entry.addContent(new Element("total").setText(stat.getValue() + ""));
            response.addContent(entry);
          }
        } else {
          Map<Group, Integer> statsMap = metadataRepository.getMetadataStatistics().getGroupOwnerToStatMap(metadataCount());
          for (Entry<Group, Integer> stat : statsMap.entrySet()) {
            Element entry = new Element("stat");
            entry.addContent(new Element("label").setText(stat.getKey().getLabel(context.getLanguage())));
            entry.addContent(new Element("total").setText(stat.getValue() + ""));
            response.addContent(entry);
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.