Package org.fao.geonet.domain

Examples of org.fao.geonet.domain.Metadata


     * @throws Exception
     */

    public void notifyMetadataChange (Element md, String metadataId) throws Exception {

        final Metadata metadata = _metadataRepository.findOne(metadataId);
        if (metadata != null && metadata.getDataInfo().getType() == MetadataType.METADATA) {
            MetadataSchema mds = servContext.getBean(DataManager.class).getSchema(metadata.getDataInfo().getSchemaId());
            Pair<String, Element> editXpathFilter = mds.getOperationFilter(ReservedOperation.editing);
            XmlSerializer.removeFilteredElement(md, editXpathFilter, mds.getNamespaces());

            String uuid = getMetadataUuid( metadataId);
            servContext.getBean(MetadataNotifierManager.class).updateMetadata(md, metadataId, uuid, servContext);
View Full Code Here


    public void testDeleteDeletesFromMetadata() throws Exception {

        MetadataCategory cat1 = _repo.save(newMetadataCategory(_inc));
        MetadataCategory cat2 = _repo.save(newMetadataCategory(_inc));

        Metadata metadata1 = MetadataRepositoryTest.newMetadata(_inc);
        metadata1.getCategories().add(cat1);
        metadata1.getCategories().add(cat2);
        metadata1 = _metadataRepo.save(metadata1);

        Metadata metadata2 = MetadataRepositoryTest.newMetadata(_inc);
        metadata2.getCategories().add(cat1);
        metadata2 = _metadataRepo.save(metadata2);

        _repo.deleteCategoryAndMetadataReferences(cat1.getId());

        _entityManager.flush();
        _entityManager.clear();

        // org.fao.geonet.services.category.Remove assumes that this test passes.  If this test can't pass
        // then there needs to be a way to fix Remove as well.
        final Set<MetadataCategory> foundCategories = _metadataRepo.findOne(metadata1.getId()).getCategories();
        assertEquals(1, foundCategories.size());
        assertEquals(cat2.getId(), foundCategories.iterator().next().getId());

        assertEquals(0, _metadataRepo.findOne(metadata2.getId()).getCategories().size());
    }
View Full Code Here

    //
    // setting schemaLocation - if there isn't one then use the schemaLocation
    // that is in the GeoNetwork schema identification and if there isn't one
    // of those then build one pointing to the XSD in GeoNetwork

    Metadata info = context.getBean(MetadataRepository.class).findOne(id);
    Attribute schemaLocAtt = sm.getSchemaLocation(info.getDataInfo().getSchemaId(), context);

    if (schemaLocAtt != null) {
      if (elMd.getAttribute(schemaLocAtt.getName(), schemaLocAtt.getNamespace()) == null) {
        elMd.setAttribute(schemaLocAtt);
        // make sure namespace declaration for schemalocation is present -
View Full Code Here

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

  private String getHarvestingUuid(ServiceContext context, String id) throws Exception
  {
        final Metadata metadata = context.getBean(MetadataRepository.class).findOne(id);

    //--- if we don't have any metadata, just return

    if (metadata == null) {
      throw new MetadataNotFoundEx("id:"+ id);
        }

    String harvUuid = metadata.getHarvestInfo().getUuid();

    //--- metadata not harvested

    return (harvUuid == null || harvUuid.length() == 0) ? null : harvUuid;
  }
View Full Code Here

    //-----------------------------------------------------------------------
    //--- check access
    int iLocalId = Integer.parseInt(id);

        final Metadata metadata = context.getBean(MetadataRepository.class).findOne(iLocalId);
        if (metadata == null) {
      throw new IllegalArgumentException("Metadata not found --> " + id);
        }

    Element isOwner = new Element("owner");
    if (am.isOwner(context, id)) {
      isOwner.setText("true");
        } else {
      isOwner.setText("false");
        }

    //-----------------------------------------------------------------------
    //--- retrieve metadata categories

    HashSet<String> hsMetadataCat = new HashSet<String>();

    for (MetadataCategory cat : metadata.getCategories()) {
      hsMetadataCat.add(cat.getId() + "");
    }

    //-----------------------------------------------------------------------
    //--- retrieve groups operations
View Full Code Here

    private MetadataRelation newMetadataRelation() {
        return newMetadataRelation(_inc, _metadataRepo);
    }
    public static MetadataRelation newMetadataRelation(AtomicInteger inc, MetadataRepository metadataRepo) {
        Metadata metadata1 = metadataRepo.save(newMetadata(inc));
        Metadata metadata2 = metadataRepo.save(newMetadata(inc));

        MetadataRelation relation = new MetadataRelation();
        relation.setId(new MetadataRelationId(metadata1.getId(), metadata2.getId()));

        return relation;
    }
View Full Code Here

     * @throws Exception
     */
  public boolean isOwner(final ServiceContext context, final String id) throws Exception {

    //--- retrieve metadata info
    Metadata info = _metadataRepository.findOne(id);

        if (info == null)
            return false;
        final MetadataSourceInfo sourceInfo = info.getSourceInfo();
        return isOwner(context, sourceInfo);
  }
View Full Code Here

     * @param metadataId the id of the metadata
     * @return
     * @throws Exception
     */
    public boolean isVisibleToAll(final String metadataId) throws Exception {
        Metadata metadata = _metadataRepository.findOne(metadataId);
        if (metadata == null) {
            return false;
        } else {
            Group allGroup = _groupRepository.findReservedGroup(ReservedGroup.all);
            int opId = ReservedOperation.view.getId();
View Full Code Here

      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));
                        }
                    }
        }
View Full Code Here

    //--- get XSLT converter name from params
    String styleSheet = Util.getParam(params, Params.STYLESHEET);

    //--- get metadata info and create an env that works with oai translators
        final Metadata metadata = context.getBean(MetadataRepository.class).findOne(id);
    String schemaDir = sm.getSchemaDir(metadata.getDataInfo().getSchemaId());
        final String baseUrl = context.getBaseUrl();
        final ISODate changeDate = metadata.getDataInfo().getChangeDate();
        final String uuid = metadata.getUuid();
        final String siteURL = context.getBean(SettingManager.class).getSiteURL(context);
        final String siteName = gc.getBean(SettingManager.class).getSiteName();
        Element env = Lib.prepareTransformEnv(uuid, changeDate.getDateAndTime(), baseUrl, siteURL, siteName);

    //--- transform the metadata with the created env and specified stylesheet
View Full Code Here

TOP

Related Classes of org.fao.geonet.domain.Metadata

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.